Skip to content

Commit

Permalink
Merge pull request #3 from delphinegesse/feat/add-reminder-notification
Browse files Browse the repository at this point in the history
Feat/add reminder notification
  • Loading branch information
delphinegesse authored Dec 19, 2023
2 parents e37b3b7 + aad01a5 commit c4cebdb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,26 @@
.todo-text {
border: none;
}

.reminder-notification-container {
display: flex;
flex-direction: column;
position: absolute;
top: 10px;
right: 10px;
background-color: white;
padding: 20px;
gap: 20px;
border-radius: 10px;
border: solid rgb(117, 9, 117) 2px;
}

.reminder-notification-title {
font-size: 28px;
}

.reminder-notification-content {
display: flex;
gap: 8px;
flex-direction: column;
}
21 changes: 21 additions & 0 deletions src/components/reminderNotification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

interface ReminderNotificationProps {
name: string
date: string
}

export default function ReminderNotification({
name,
date
}: ReminderNotificationProps) {
return (
<div className="reminder-notification-container">
<h1 className="reminder-notification-title">Task reminder</h1>
<div className="reminder-notification-content">
<p>{name}</p>
<p>{`Due ${date.split('T')[0]}`}</p>
</div>
</div>
)
}
21 changes: 20 additions & 1 deletion src/components/taskList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { gql, useQuery, useSubscription } from '@apollo/client'

import TaskElement from './taskElement'
import { Task } from '../customTypes'
import ReminderNotification from './reminderNotification'

const GET_TASKS = gql`
query GetTasks($order: String, $where: SequelizeJSON) {
Expand Down Expand Up @@ -72,10 +73,28 @@ export default function TaskList({ status }: { status: string }) {

if (error) return <p>An error occured while loading the tasks !</p>

const today = new Date().toISOString().split('T')[0]

const isReminderNotificationToBeDisplayed = (
date: string,
active: boolean
) => {
if (date !== undefined && active) {
const formattedDate = date?.split('T')[0]
return today === formattedDate
}
return false
}

return (
<ul id="todos" className="todos" aria-label="List of to do tasks">
{data.task.map((task: Task) => (
<TaskElement task={task} key={task.id} reloadList={refetch} />
<>
<TaskElement task={task} key={task.id} reloadList={refetch} />
{isReminderNotificationToBeDisplayed(task.date, task.active) && (
<ReminderNotification name={task.name} date={task.date} />
)}
</>
))}
</ul>
)
Expand Down

0 comments on commit c4cebdb

Please sign in to comment.