Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Oct 27, 2024
1 parent 7f5360e commit ab7510c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
11 changes: 7 additions & 4 deletions task_yell/src/lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ export async function createEvent(
}

export async function readEvents(userId: string): Promise<Event[]> {
return (await readData<Event>(`users/${userId}/${COLLECTION_NAME}`))
.map((event) => ({
return (await readData<Event>(`users/${userId}/${COLLECTION_NAME}`)).map(
(event) => ({
...event,
start: event.start ? (event.start as unknown as Timestamp).toDate() : null,
start: event.start
? (event.start as unknown as Timestamp).toDate()
: null,
end: event.end ? (event.end as unknown as Timestamp).toDate() : null,
}));
}),
);
}

export async function readSingleEvent(
Expand Down
18 changes: 11 additions & 7 deletions task_yell/src/lib/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@ export async function createNotification(
}

export async function readNotification(): Promise<Notification[]> {
return (await readData<Notification>(COLLECTION_NAME))
.map((notification) => ({
return (await readData<Notification>(COLLECTION_NAME)).map(
(notification) => ({
...notification,
datetime: (notification.datetime as unknown as Timestamp).toDate(),
}));
}),
);
}

export async function readSingleNotification(
id: string,
): Promise<Notification | null> {
return readSingleData<Notification>(COLLECTION_NAME, id).then((notification) => notification && ({
...notification,
datetime: (notification.datetime as unknown as Timestamp).toDate(),
}));
return readSingleData<Notification>(COLLECTION_NAME, id).then(
(notification) =>
notification && {
...notification,
datetime: (notification.datetime as unknown as Timestamp).toDate(),
},
);
}

export async function updateNotification(
Expand Down
10 changes: 7 additions & 3 deletions task_yell/src/lib/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export async function createTask(userId: string, task: Task): Promise<void> {
*/
export async function readTasks(userId: string): Promise<Task[]> {
return readData<Task>(`users/${userId}/${COLLECTION_NAME}`).then((tasks) =>
tasks.map((task) => ({ ...task, due: (task.due as unknown as Timestamp).toDate() })),
tasks.map((task) => ({
...task,
due: (task.due as unknown as Timestamp).toDate(),
})),
);
}

Expand All @@ -40,8 +43,9 @@ export async function readSingleTask(
userId: string,
id: string,
): Promise<Task | null> {
return readSingleData<Task>(`users/${userId}/${COLLECTION_NAME}`, id).then((task) =>
task && ({ ...task, due: (task.due as unknown as Timestamp).toDate() }),
return readSingleData<Task>(`users/${userId}/${COLLECTION_NAME}`, id).then(
(task) =>
task && { ...task, due: (task.due as unknown as Timestamp).toDate() },
);
}

Expand Down

0 comments on commit ab7510c

Please sign in to comment.