Skip to content

Commit

Permalink
refactor: change dto type rule
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Nov 24, 2024
1 parent e752564 commit 5330d70
Show file tree
Hide file tree
Showing 31 changed files with 506 additions and 729 deletions.
6 changes: 3 additions & 3 deletions client/features/tasks/TaskList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useAspidaSWR from '@aspida/swr';
import type { TaskDto } from 'common/types/task';
import { labelValidator } from 'common/validators/task';
import { taskValidator } from 'common/validators/task';
import { Loading } from 'components/loading/Loading';
import { useAlert } from 'hooks/useAlert';
import type { FormEvent } from 'react';
Expand All @@ -22,15 +22,15 @@ export const TaskList = () => {
const createTask = async (e: FormEvent) => {
e.preventDefault();

const parsedLabel = labelValidator.safeParse(label);
const parsedLabel = taskValidator.createBodyBase.safeParse({ label });

if (parsedLabel.error) {
await setAlert(parsedLabel.error.issues[0].message);
return;
}

await apiClient.private.tasks
.$post({ body: { label: parsedLabel.data, image } })
.$post({ body: { label: parsedLabel.data.label, image } })
.then((task) => mutateTasks((tasks) => [task, ...(tasks ?? [])]))
.catch(catchApiErr);
setLabel('');
Expand Down
Loading

0 comments on commit 5330d70

Please sign in to comment.