Skip to content

Commit

Permalink
add content validation and text wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaniyaps committed Jun 29, 2024
1 parent 1c76b34 commit a9a2375
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 28 deletions.
19 changes: 13 additions & 6 deletions client/src/components/home-page/Todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ export const TodoFragment = graphql`
}
`;

// TODO: handle TodoNotFoundErrors
const deleteTodoMutation = graphql`
mutation TodoDeleteMutation($todoId: ID!, $connections: [ID!]!) {
deleteTodo(todoId: $todoId) {
__typename
... on Todo {
id @deleteEdge(connections: $connections)
}
... on TodoNotFoundError {
message
}
}
}
`;
Expand Down Expand Up @@ -52,14 +57,16 @@ export default function Todo({ todo, connectionId }: Props) {
return (
<Card className="mb-4 group">
<CardHeader>
<div className="flex justify-between">
<CardTitle className={clsx({ "line-through": data.completed })}>
{data.content}
</CardTitle>
</div>
<CardTitle
className={clsx({
"line-through": data.completed,
})}
>
<p className="break-all">{data.content}</p>
</CardTitle>
</CardHeader>
<CardFooter className="flex">
<p className="text-xs">
<p className="text-xs text-muted-foreground">
created at {dtf.format(new Date(data.createdAt))}
</p>
<div className="flex gap-2 grow justify-end opacity-0 group-hover:opacity-100 transition-opacity">
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/home-page/TodoController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const TodoControllerCreateMutation = graphql`
`;

const createTodoSchema = z.object({
content: z.string().max(250, {
message: "content cannot be more than 250 characters.",
content: z.string().min(1, { message: "content is required" }).max(250, {
message: "content cannot be more than 250 characters",
}),
});

Expand Down Expand Up @@ -80,7 +80,7 @@ export default function TodoController({ rootQuery }: Props) {
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col gap-8 w-full px-4"
className="flex flex-col gap-4 w-full px-4"
>
<FormField
control={form.control}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9a2375

Please sign in to comment.