Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👯‍♀️ Update team information validation in team step #222

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { specificLengthStringSchema } from "@/constants/validationSchemas";
import { zodResolver } from "@hookform/resolvers/zod";
import { useFieldArray, useForm } from "react-hook-form";
import { z } from "zod";
Expand All @@ -8,11 +9,13 @@ import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormCounter,
FormDescription,
FormField,
FormFooter,
FormItem,
FormLabel,
FormMessage,
FormMessages,
} from "@/components/ui/form";
import { Textarea } from "@/components/ui/textarea";
Expand All @@ -25,8 +28,15 @@ import {

import { MemberField } from "./memberField";

const FORM_FIELD_PARAMS = {
teamSummary: { min: 1, max: 280 },
};

export const teamInformationSchema = z.object({
teamSummary: z.string(),
teamSummary: specificLengthStringSchema(
"Team summary",
FORM_FIELD_PARAMS.teamSummary,
),
members: z.array(
z.object({
imageId: z.string().optional(),
Expand Down Expand Up @@ -77,13 +87,18 @@ export function TeamInformation() {
control={form.control}
name="teamSummary"
render={({ field }) => (
<FormItem>
<FormItem aria-required>
<FormLabel>Team summary</FormLabel>
<FormControl>
<Textarea {...field} placeholder="Tell us about your team" />
</FormControl>
<FormMessages>
<FormDescription>
<FormMessages className="grid grid-cols-[1fr_auto]">
<FormMessage />
<FormCounter
className="col-start-2"
limit={FORM_FIELD_PARAMS.teamSummary.max}
/>
<FormDescription className="col-span-2">
<p>Tell us about your team.</p>
<ul className="list-disc pl-4">
<li>Humanize your company</li>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const FormMessages = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
return (
<div
ref={ref}
className={cn("flex gap-4 [&>*]:mt-0.5", className)}
className={cn("flex gap-x-4 [&:not(:empty)]:mt-0.5", className)}
{...props}
>
{children}
Expand Down
Loading