diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..3867a0f --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npm run lint diff --git a/package.json b/package.json index 230fd80..a3bc873 100644 --- a/package.json +++ b/package.json @@ -6,17 +6,21 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "prepare": "husky" }, "dependencies": { "@hookform/resolvers": "^3.9.0", "@radix-ui/react-avatar": "^1.1.0", + "@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", + "@radix-ui/react-popover": "^1.1.1", "@radix-ui/react-radio-group": "^1.2.0", "@radix-ui/react-select": "^2.1.1", + "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-tabs": "^1.1.0", "@radix-ui/react-toast": "^1.2.1", @@ -24,11 +28,14 @@ "@tanstack/react-table": "^8.20.5", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "cmdk": "1.0.0", + "date-fns": "^4.0.0", "lucide-react": "^0.439.0", "next": "14.2.9", "next-auth": "5.0.0-beta.20", "next-themes": "^0.3.0", "react": "^18", + "react-day-picker": "8.10.1", "react-dom": "^18", "react-hook-form": "^7.53.0", "sot": "file:", @@ -42,6 +49,7 @@ "@types/react-dom": "^18", "eslint": "^8", "eslint-config-next": "14.2.9", + "husky": "^9.1.6", "postcss": "^8", "tailwindcss": "^3.4.1", "typescript": "^5" diff --git a/src/app/app/(main)/_components/create-service-order-workshop-dialog.tsx b/src/app/app/(main)/_components/create-service-order-workshop-dialog.tsx new file mode 100644 index 0000000..f172a84 --- /dev/null +++ b/src/app/app/(main)/_components/create-service-order-workshop-dialog.tsx @@ -0,0 +1,218 @@ +"use client" + +import { Button } from '@/components/ui/button' +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog' +import { FormField, FormItem, FormLabel, FormControl, FormMessage, FormDescription, Form } from '@/components/ui/form' +import { Input } from '@/components/ui/input' +import { Textarea } from '@/components/ui/textarea' +import { PropsWithChildren, useRef, useState } from 'react' +import { useForm } from 'react-hook-form' +import { zodResolver } from '@hookform/resolvers/zod' +import { CreateNewWorkshopServiceOrder, createNewWorkshopServiceOrderSchema } from '../schema' +import { createNewWorkshopServiceOrder } from '../action' +import { toast } from '@/hooks/use-toast' +import { Checkbox } from '@/components/ui/checkbox' +import { useRouter } from 'next/navigation' +import { CheckIcon } from '@radix-ui/react-icons' + +export default function CreateServiceOrderWorkshopDialog({ children }: PropsWithChildren) { + const ref = useRef(null) + const [open, setOpen] = useState(false) + const form = useForm({ + resolver: zodResolver(createNewWorkshopServiceOrderSchema), + defaultValues: { + automaker: '', + project: '', + isIntern: true, + model: '', + chassis: '', + fleet: '', + vehicleLocation: '', + keyLocation: '', + serviceInformations: null, + deliveryDate: '', + requestedBy: '' + }, + }) + const router = useRouter() + async function onSubmit(values: CreateNewWorkshopServiceOrder) { + await createNewWorkshopServiceOrder(values) + setOpen(false) + router.refresh() + toast({ + description: ( +
+ + Ordem de serviço da oficina criada com sucesso. +
+ ) + }) + } + + return ( + + +
{children}
+
+ + + Criar ordem de serviço da oficina + + Insira os detalhes da ordem de serviço abaixo. + + +
+ +
+ ( + + Montadora + + + + + + )} + /> + ( + + Projeto + + + + + + )} + /> + ( + + Modelo + + + + + + )} + /> + ( + + Chassi + + + + + + )} + /> + ( + + Frota + + + + + + )} + /> + ( + + Localização do veículo + + + + + + )} + /> + ( + + Localização da chave + + + + + + )} + /> + ( + + Data de entrega + + + + + + )} + /> +
+ ( + + + + +
+ + Interno + + + Marque se o projeto for interno + +
+
+ )} + /> + ( + + Informações do serviço + +