Skip to content

Commit

Permalink
refactor: theme form
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloCarnevale committed Sep 16, 2024
1 parent 478e662 commit f1e3ba1
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 32 deletions.
3 changes: 3 additions & 0 deletions src/app/app/_components/user-dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client"

import { Button } from "@/components/ui/button";
import {
DropdownMenu,
Expand All @@ -21,6 +23,7 @@ type UserdropdwonProps = {

export function UserDropdown({ user }: UserdropdwonProps) {
if (!user) return;

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand Down
46 changes: 31 additions & 15 deletions src/app/app/projects/(main)/_components/new-project-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<DialogTrigger asChild>
<div ref={ref}>{children}</div>
</DialogTrigger>
<DialogContent>
<DialogContent className="dark:bg-[#1a1a1a]">
<DialogHeader>
<DialogTitle>Criar um novo projeto</DialogTitle>
<DialogDescription>Crie um novo projeto.</DialogDescription>
Expand All @@ -101,7 +101,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormItem>
<FormLabel>Nome</FormLabel>
<FormControl>
<Input {...field} />
<Input {...field} placeholder="Projeto novo" />
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -114,7 +114,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormItem>
<FormLabel>Número</FormLabel>
<FormControl>
<Input {...field} />
<Input {...field} placeholder="BM-000000001" />
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -127,7 +127,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormItem>
<FormLabel>Descritivo (Opcional)</FormLabel>
<FormControl>
<Textarea {...field} />
<Textarea {...field} placeholder="Breve descrição sobre o projeto..." />
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -140,7 +140,15 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormItem>
<FormLabel>Cliente</FormLabel>
<FormControl>
<Input {...field} />
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o cliente..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="Bosch BR">Bosch BR</SelectItem>
<SelectItem value="Toyota">Toyota</SelectItem>
</SelectContent>
</Select>
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -153,7 +161,15 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormItem>
<FormLabel>Motor</FormLabel>
<FormControl>
<Input {...field} />
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o motor..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="Motor 1">Motor 2</SelectItem>
<SelectItem value="Motor 2">Motor 1</SelectItem>
</SelectContent>
</Select>
</FormControl>
<FormMessage />
</FormItem>
Expand Down Expand Up @@ -207,7 +223,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o tipo de injeção" />
<SelectValue placeholder="Selecione o tipo de aspiração" />
</SelectTrigger>
<SelectContent>
<SelectItem value="direta">Simples</SelectItem>
Expand All @@ -224,11 +240,11 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
name="fuel"
render={({ field }) => (
<FormItem>
<FormLabel>Fuel</FormLabel>
<FormLabel>Combustível</FormLabel>
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o tipo de combustível" />
<SelectValue placeholder="Selecione o tipo de combustível..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="gasolina">Gasolina</SelectItem>
Expand All @@ -251,7 +267,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o tipo de câmbio" />
<SelectValue placeholder="Selecione o tipo de câmbio..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="teste">Teste</SelectItem>
Expand All @@ -276,7 +292,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o tipo de injeção" />
<SelectValue placeholder="Selecione o tipo de injeção..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="direta">Simples</SelectItem>
Expand All @@ -297,7 +313,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o mercado" />
<SelectValue placeholder="Selecione o mercado..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="direta">Simples</SelectItem>
Expand All @@ -318,7 +334,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione a legislação" />
<SelectValue placeholder="Selecione a legislação..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="direta">Simples</SelectItem>
Expand All @@ -339,7 +355,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o tipo de injeção" />
<SelectValue placeholder="Selecione o ciclo..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="direta">Simples</SelectItem>
Expand All @@ -360,7 +376,7 @@ export function NewProjectDialog({ children }: PropsWithChildren) {
<FormControl>
<Select required onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue placeholder="Selecione o tipo de injeção" />
<SelectValue placeholder="Selecione a diagnose..." />
</SelectTrigger>
<SelectContent>
<SelectItem value="direta">Simples</SelectItem>
Expand Down
24 changes: 12 additions & 12 deletions src/app/app/projects/(main)/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ export const createProjectSchema = z.object({
name: z.string().min(1, { message: "É preciso inserir o nome do projeto" }),
number: z.string().min(1, { message: "É preciso inserir o número do projeto" }),
description: z.string().optional(),
client: z.string().min(1),
motor: z.string().min(1),
motorFamily: z.string().min(1),
injection: z.string().min(1),
aspiration: z.string().min(1),
fuel: z.string().min(1),
gearBox: z.string().min(1),
powertrain: z.string().min(1),
market: z.string().min(1),
legislation: z.string().min(1),
cicle: z.string().min(1),
diagnose: z.string().min(1),
client: z.string().min(1, { message: "É preciso selecionar um cliente" }),
motor: z.string().min(1, { message: "É preciso selecionar o motor" }),
motorFamily: z.string().min(1, { message: "É preciso selecionar a família motor" }),
injection: z.string().min(1, { message: "É preciso selecionar o tipo de injeção" }),
aspiration: z.string().min(1, { message: "É preciso selecionar o tipo de aspiração" }),
fuel: z.string().min(1, { message: "É preciso selecionar o tipo da injeção" }),
gearBox: z.string().min(1, { message: "É preciso selecionar o câmbio" }),
powertrain: z.string().min(1, { message: "É preciso selecionar o powertrain" }),
market: z.string().min(1, { message: "É preciso selecionar o mercado" }),
legislation: z.string().min(1, { message: "É preciso selecionar a legislação" }),
cicle: z.string().min(1, { message: "É preciso selecionar o ciclo" }),
diagnose: z.string().min(1, { message: "É preciso selecionar a diagnose" }),
})

export type FormDataCreateProject = z.infer<typeof createProjectSchema>
4 changes: 2 additions & 2 deletions src/app/app/settings/theme/_components/ThemeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export function ThemeForm() {
</CardContent>
</Card>
<Button disabled={form.formState.isSubmitting} type="submit">
{form.formState.isSubmitting && "Salvando..."}
{!form.formState.isSubmitting && "Salvar"}
{form.formState.isSubmitting && "Atualizando..."}
{!form.formState.isSubmitting && "Atualizar"}
</Button>
</form>
</Form >)
Expand Down
5 changes: 3 additions & 2 deletions src/app/auth/signin/_components/sign-in-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export function SignInForm() {
Login para funcionários
</h2>
</div>
<Button className="w-full" type='submit' variant="default">
Bosch Login
<Button className="w-full" type='submit' variant="default" disabled={form.formState.isSubmitting}>
{form.formState.isSubmitting && "Entrando..."}
{!form.formState.isSubmitting && "Bosch Login"}
</Button>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const DialogContent = React.forwardRef<
<DialogPrimitive.Content
ref={ref}
className={cn(
"dark:bg-[#1a1a1a] fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
Expand Down

0 comments on commit f1e3ba1

Please sign in to comment.