style: do inputs design modification
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import type { ComponentProps } from 'react';
|
||||
import type { FieldErrors, UseFormRegister, UseFormReturn } from 'react-hook-form';
|
||||
import type { FieldErrors, UseFormRegister } from 'react-hook-form';
|
||||
import { Layers, Loader2, MapPin, Route } from 'lucide-react';
|
||||
|
||||
import { FormField } from '@/components/form';
|
||||
@@ -24,7 +24,7 @@ interface ProjectDialogProps {
|
||||
projectId?: string;
|
||||
register: UseFormRegister<ProjectFormValues>;
|
||||
errors: FieldErrors<ProjectFormValues>;
|
||||
touchedFields: UseFormReturn<ProjectFormValues>['formState']['touchedFields'];
|
||||
isSubmitted: boolean;
|
||||
onSubmit: ComponentProps<'form'>['onSubmit'];
|
||||
canSubmit: boolean;
|
||||
isSaving: boolean;
|
||||
@@ -36,16 +36,16 @@ export function ProjectDialog({
|
||||
projectId,
|
||||
register,
|
||||
errors,
|
||||
touchedFields,
|
||||
isSubmitted,
|
||||
onSubmit,
|
||||
canSubmit,
|
||||
isSaving,
|
||||
}: ProjectDialogProps) {
|
||||
const nameErrorMessage = touchedFields.name ? errors.name?.message : undefined;
|
||||
const startLatErrorMessage = touchedFields.start_lat ? errors.start_lat?.message : undefined;
|
||||
const startLngErrorMessage = touchedFields.start_lng ? errors.start_lng?.message : undefined;
|
||||
const endLatErrorMessage = touchedFields.end_lat ? errors.end_lat?.message : undefined;
|
||||
const endLngErrorMessage = touchedFields.end_lng ? errors.end_lng?.message : undefined;
|
||||
const nameErrorMessage = isSubmitted ? errors.name?.message : undefined;
|
||||
const startLatErrorMessage = isSubmitted ? errors.start_lat?.message : undefined;
|
||||
const startLngErrorMessage = isSubmitted ? errors.start_lng?.message : undefined;
|
||||
const endLatErrorMessage = isSubmitted ? errors.end_lat?.message : undefined;
|
||||
const endLngErrorMessage = isSubmitted ? errors.end_lng?.message : undefined;
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import type { ColumnDef } from '@tanstack/react-table';
|
||||
import { Edit3, Trash2 } from 'lucide-react';
|
||||
|
||||
import { DataTable } from '@/components/data-table';
|
||||
import type { Project } from '@/types';
|
||||
@@ -35,8 +36,19 @@ export function ProjectTable({
|
||||
title="Projects"
|
||||
data={projects}
|
||||
columns={columns}
|
||||
onEdit={onEdit}
|
||||
onDelete={onDelete}
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Edit3 className="size-4" />,
|
||||
onClick: onEdit,
|
||||
},
|
||||
{
|
||||
label: 'Delete',
|
||||
icon: <Trash2 className="size-4" />,
|
||||
className: 'text-destructive',
|
||||
onClick: onDelete,
|
||||
},
|
||||
]}
|
||||
isLoading={isLoading}
|
||||
emptyTitle="No projects found."
|
||||
pagination={{
|
||||
|
||||
@@ -72,10 +72,10 @@ export function useProjectForm({ onSaved }: { onSaved: () => void }) {
|
||||
handleSubmit,
|
||||
reset,
|
||||
control,
|
||||
formState: { errors, isSubmitting, touchedFields },
|
||||
formState: { errors, isSubmitting, isSubmitted },
|
||||
} = useForm<ProjectFormValues>({
|
||||
defaultValues,
|
||||
mode: 'onTouched',
|
||||
mode: 'onSubmit',
|
||||
reValidateMode: 'onChange',
|
||||
resolver: zodResolver(projectFormSchema),
|
||||
});
|
||||
@@ -139,7 +139,7 @@ export function useProjectForm({ onSaved }: { onSaved: () => void }) {
|
||||
resetForm: () => reset(defaultValues),
|
||||
projectId,
|
||||
errors,
|
||||
touchedFields,
|
||||
isSubmitted,
|
||||
canSubmit,
|
||||
isSaving: isSubmitting || saveMutation.isPending,
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function ProjectPage() {
|
||||
resetForm,
|
||||
projectId,
|
||||
errors,
|
||||
touchedFields,
|
||||
isSubmitted,
|
||||
canSubmit,
|
||||
isSaving,
|
||||
} = projectForm;
|
||||
@@ -107,7 +107,7 @@ export default function ProjectPage() {
|
||||
projectId={projectId}
|
||||
register={register}
|
||||
errors={errors}
|
||||
touchedFields={touchedFields}
|
||||
isSubmitted={isSubmitted}
|
||||
onSubmit={onSubmit}
|
||||
canSubmit={canSubmit}
|
||||
isSaving={isSaving}
|
||||
|
||||
Reference in New Issue
Block a user