diff --git a/package.json b/package.json index fef3323..d1e1e00 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@hookform/resolvers": "^3.9.0", "@next-auth/prisma-adapter": "^1.0.7", "@prisma/client": "^5.18.0", + "@radix-ui/react-checkbox": "^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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a14fb6c..dae5cad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,14 +10,16 @@ importers: dependencies: '@hookform/resolvers': specifier: ^3.9.0 - - version: 3.9.0(react-hook-form@7.52.1(react@18.3.1)) + version: 3.9.0(react-hook-form@7.52.2(react@18.3.1)) '@next-auth/prisma-adapter': specifier: ^1.0.7 - version: 1.0.7(@prisma/client@5.16.1(prisma@5.16.1))(next-auth@4.24.7(next@14.2.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)) + version: 1.0.7(@prisma/client@5.18.0(prisma@5.18.0))(next-auth@4.24.7(next@14.2.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)) '@prisma/client': specifier: ^5.18.0 version: 5.18.0(prisma@5.18.0) + '@radix-ui/react-checkbox': + specifier: ^1.1.1 + version: 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@radix-ui/react-dropdown-menu': specifier: ^2.1.1 version: 2.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -519,6 +521,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-checkbox@1.1.1': + resolution: {integrity: sha512-0i/EKJ222Afa1FE0C6pNJxDq1itzcl3HChE9DwskA4th4KRse8ojx8a1nVcOjwJdbpDLcz7uol77yYnQNMHdKw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-collection@1.1.0': resolution: {integrity: sha512-GZsZslMJEyo1VKm5L1ZJY8tGDxZNPAoUeQUIbKeJfoi7Q4kmig5AsgLMYYuyYbfjd8fBmFORAIwYAkXMnXZgZw==} peerDependencies: @@ -2714,12 +2729,6 @@ snapshots: '@floating-ui/utils@0.2.7': {} - '@hapi/hoek@9.3.0': {} - - '@hapi/topo@5.1.0': - dependencies: - '@hapi/hoek': 9.3.0 - '@hookform/resolvers@3.9.0(react-hook-form@7.52.2(react@18.3.1))': dependencies: react-hook-form: 7.52.2(react@18.3.1) @@ -2762,9 +2771,9 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - '@next-auth/prisma-adapter@1.0.7(@prisma/client@5.16.1(prisma@5.16.1))(next-auth@4.24.7(next@14.2.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))': + '@next-auth/prisma-adapter@1.0.7(@prisma/client@5.18.0(prisma@5.18.0))(next-auth@4.24.7(next@14.2.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))': dependencies: - '@prisma/client': 5.16.1(prisma@5.16.1) + '@prisma/client': 5.18.0(prisma@5.18.0) next-auth: 4.24.7(next@14.2.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@next/env@14.2.4': {} @@ -2855,6 +2864,22 @@ snapshots: '@types/react': 18.3.3 '@types/react-dom': 18.3.0 + '@radix-ui/react-checkbox@1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@radix-ui/primitive': 1.1.0 + '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-context': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-presence': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-use-previous': 1.1.0(@types/react@18.3.3)(react@18.3.1) + '@radix-ui/react-use-size': 1.1.0(@types/react@18.3.3)(react@18.3.1) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + optionalDependencies: + '@types/react': 18.3.3 + '@types/react-dom': 18.3.0 + '@radix-ui/react-collection@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.3)(react@18.3.1) diff --git a/src/app/(admin)/estoque/_components/products/productsCard.tsx b/src/app/(admin)/estoque/_components/products/productsCard.tsx index 8a59e29..41b9eb9 100644 --- a/src/app/(admin)/estoque/_components/products/productsCard.tsx +++ b/src/app/(admin)/estoque/_components/products/productsCard.tsx @@ -1,4 +1,4 @@ -import { CldImage } from "@/components/app/cldImage"; +import CldImage from "@/components/app/cldImage"; import { CardComponent } from "@/components/cardComponent"; import { cn } from "@/lib/utils"; import React from "react"; diff --git a/src/app/(admin)/historico/page.tsx b/src/app/(admin)/historico/page.tsx index cf3c9a6..1d43f6d 100644 --- a/src/app/(admin)/historico/page.tsx +++ b/src/app/(admin)/historico/page.tsx @@ -1,5 +1,5 @@ import { DataTable } from "@/app/_components/data-table"; -import { UsersAction, columns } from "./users-actions-columns"; +import { type UsersAction, columns } from "./users-actions-columns"; async function getData(): Promise { return [ diff --git a/src/app/(admin)/historico/users-actions-columns.tsx b/src/app/(admin)/historico/users-actions-columns.tsx index 5f6bd7a..b826895 100644 --- a/src/app/(admin)/historico/users-actions-columns.tsx +++ b/src/app/(admin)/historico/users-actions-columns.tsx @@ -1,6 +1,5 @@ "use client"; - -import { ColumnDef } from "@tanstack/react-table"; +import type { ColumnDef } from "@tanstack/react-table"; import { ArrowUpDown } from "lucide-react"; import { Button } from "@/components/ui/button"; diff --git a/src/app/_components/data-table-pagination.tsx b/src/app/_components/data-table-pagination.tsx index 3bf0928..453d866 100644 --- a/src/app/_components/data-table-pagination.tsx +++ b/src/app/_components/data-table-pagination.tsx @@ -4,7 +4,7 @@ import { DoubleArrowLeftIcon, DoubleArrowRightIcon, } from "@radix-ui/react-icons"; -import { Table } from "@tanstack/react-table"; +import type { Table } from "@tanstack/react-table"; import { Button } from "@/components//ui/button"; import { diff --git a/src/app/_components/data-table.tsx b/src/app/_components/data-table.tsx index cb1ef3e..6983efa 100644 --- a/src/app/_components/data-table.tsx +++ b/src/app/_components/data-table.tsx @@ -31,7 +31,7 @@ import { } from "@/components/ui/table"; import { DataTablePagination } from "./data-table-pagination"; -const columnTranslations = { +const columnTranslations: Record = { name: "Nome", action: "Ação", product: "Nome do Produto", @@ -95,8 +95,9 @@ export function DataTable({ .getAllColumns() .filter((column) => column.getCanHide()) .map((column) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const translatedName = - columnTranslations[column.id] || column.id; + columnTranslations[column.id] ?? column.id; return (
- + ffff
- + {tabValue}
diff --git a/src/app/page.tsx b/src/app/page.tsx index fea693e..067aaa3 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -6,4 +6,4 @@ export default async function Home() { ); -} \ No newline at end of file +} diff --git a/src/components/formComponent/example.tsx b/src/components/formComponent/example.tsx new file mode 100644 index 0000000..046fecb --- /dev/null +++ b/src/components/formComponent/example.tsx @@ -0,0 +1,109 @@ +"use client"; +import { Form } from "."; +import { useState } from "react"; + +export const FormsExample = () => { + const [name, setName] = useState(""); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [checked1, setChecked1] = useState(false); + const [checked2, setChecked2] = useState(false); + + const onCancel = () => { + setName(""); + setEmail(""); + setPassword(""); + setConfirmPassword(""); + setChecked1(false); + setChecked2(false); + }; + + const onSave = (data: { + name: string; + email: string; + password: string; + confirmPassword: string; + cheked1: string; + cheked2: string; + }) => { + console.log(data); + }; + + return ( +
+
+ Criar Usuário + + + Digite o nome do funcionário + + + + + Digite o email de acesso + + + + + Digite a senha + + + + + Confirme a senha + + + + + + Este usuário vai poder: + + + Texto1 + + + + Texto2 + + + + console.log("criar usuario")} + className="border-none bg-[#34A853]" + > + Criar Usuário + +
+
+ ); +}; diff --git a/src/components/formComponent/example2.tsx b/src/components/formComponent/example2.tsx new file mode 100644 index 0000000..390818a --- /dev/null +++ b/src/components/formComponent/example2.tsx @@ -0,0 +1,121 @@ +"use client"; +import { Form } from "."; +import { useState } from "react"; + +export const FormsExample2 = () => { + const [supplier, setSupplier] = useState(""); + const [category, setCategory] = useState(""); + const [name, setName] = useState(""); + const [manufactureDate, setManufactureDate] = useState(""); + const [currentQuantity, setCurrentQuantity] = useState("0"); + const [idealQuantity, setIdealQuantity] = useState("0"); + + const onCancel = () => { + setSupplier(""); + setCategory(""); + setName(""); + setManufactureDate(""); + setCurrentQuantity(""); + setIdealQuantity(""); + }; + + const onSave = (data: { + supplier: string; + category: string; + name: string; + manufactureDate: string; + currentQuantity: string; + idealQuantity: string; + }) => { + console.log(data); + }; + + return ( +
+
+ console.log("editou foto")} + publicId="cld-sample-5" + > + Nome do Produto - Código do Produto + +
+ + Fornecedor + + + + + Nome + + + + + Data de Fabricação + setManufactureDate(value)} + type="date" + > + + + + Cancelar + +
+ +
+ + Categoria: + + + + + Quantidade ideal: + + + + + Situação: + + + + + Salvar + +
+
+
+
+ ); +}; diff --git a/src/components/formComponent/index.tsx b/src/components/formComponent/index.tsx new file mode 100644 index 0000000..761f88b --- /dev/null +++ b/src/components/formComponent/index.tsx @@ -0,0 +1,181 @@ +import { cn } from "@/lib/utils"; +import React, { type HTMLInputTypeAttribute } from "react"; +import { Checkbox } from "../ui/checkbox"; +import CldImage from "../app/cldImage"; +import type { CldImageProps } from "next-cloudinary"; +import { Edit } from "lucide-react"; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +type FormProps = { + className?: string; + children: React.ReactNode[]; + onCancel: () => void; + onSave: (data: any) => void; +}; + +export const Form = (props: FormProps) => { + const style = cn( + "flex flex-col justify-around border-[#E0E0E0] border-[2px] rounded-[20px]", + props.className, + ); + return ( +
+ {props.children} +
+ ); +}; + +type FormTitleProps = { + className?: string; + children: string; +}; + +Form.Title = function FormTitle(props: FormTitleProps) { + const style = cn("font-inter font-semibold text-[24px]", props.className); + return

{props.children}

; +}; + +type FormContentProps = { + className?: string; + children: React.ReactNode[]; +}; + +Form.Content = function FormContent(props: FormContentProps) { + const style = cn("flex flex-col w-full gap-[15px]", props.className); + return
{props.children}
; +}; + +type FormFieldProps = { + className?: string; + children: React.ReactNode[]; +}; + +Form.Field = function FormField(props: FormFieldProps) { + const style = cn( + "flex flex-col justify-start items-start w-full gap-[10px] ", + props.className, + ); + return
{props.children}
; +}; + +type FormLabelProps = { + className?: string; + children: string; +}; + +Form.Label = function FormLabel(props: FormLabelProps) { + const style = cn( + "justify-start font-inter font-regular text-[16px]", + props.className, + ); + return

{props.children}

; +}; + +type FormInputProps = { + className?: string; + placeholder?: string; + value: string; + setValue: (value: string) => void; + type?: HTMLInputTypeAttribute; +}; + +Form.Input = function FormInput(props: FormInputProps) { + const style = cn( + "w-full px-[10px] py-[3px] rounded-[8px] border-[2px] border-[#E0E0E0] font-inter font-medium text-[20px] placeholder-text-[#828282]", + props.className, + ); + return ( + props.setValue(event.target.value)} + type={props.type} + className={style} + /> + ); +}; + +type FormBoxSelectProps = { + className?: string; + children: string; + checked: boolean; + setChecked: (value: boolean) => void; +}; + +Form.BoxSelect = function FormBoxSelect(props: FormBoxSelectProps) { + const style = cn( + "font-inter font-regular text-[15px] leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", + props.className, + ); + return ( +
+ { + if (typeof checked === "boolean") props.setChecked(checked); + }} + /> + +
+ ); +}; + +type FormButtonProps = { + className?: string; + children: string; + onClick?: (data: any) => void; + type?: "button" | "submit" | "reset" | undefined; +}; + +Form.Button = function FormButton(props: FormButtonProps) { + const style = cn( + "rounded-[8px] border-[2px] border-[#D9D9D9] py-[10px] items-center justify-center font-inter font-medium text-[16px] text-white bg-primary", + props.className, + ); + return ( + + ); +}; + +type FormImageProps = { + className?: string; + publicId: string; + onImageInput: (image: any) => void; + imageProps?: CldImageProps; +}; + +Form.Image = function FormImage(props: FormImageProps) { + const style = cn( + "w-fit h-fit rounded-[8px] border-[2px] border-[#D9D9D9] flex items-start justify-center relative", + props.className, + ); + return ( +
+ + + +
+ ); +}; diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx new file mode 100644 index 0000000..df61a13 --- /dev/null +++ b/src/components/ui/checkbox.tsx @@ -0,0 +1,30 @@ +"use client" + +import * as React from "react" +import * as CheckboxPrimitive from "@radix-ui/react-checkbox" +import { Check } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Checkbox = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + +)) +Checkbox.displayName = CheckboxPrimitive.Root.displayName + +export { Checkbox }