refactor(forklifts): more refactoring to improve during production
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { getServers } from "@/lib/querys/admin/getServers";
|
||||
import { getForklifts } from "@/lib/querys/forklifts/getForklifts";
|
||||
import { getLeases } from "@/lib/querys/forklifts/getLeases";
|
||||
import { useAppForm } from "../../../../lib/formStuff";
|
||||
|
||||
@@ -52,6 +53,7 @@ const pfc: any = [
|
||||
export default function NewForklift({ setOpenDialog }: { setOpenDialog: any }) {
|
||||
//const search = useSearch({ from: "/_app/(auth)/login" });
|
||||
const { data: s, isLoading: es } = useQuery(getServers());
|
||||
const { refetch: refetchLifts } = useQuery(getForklifts());
|
||||
const {
|
||||
data: leases,
|
||||
isLoading: leaseError,
|
||||
@@ -91,6 +93,7 @@ export default function NewForklift({ setOpenDialog }: { setOpenDialog: any }) {
|
||||
form.reset();
|
||||
setOpenDialog(false);
|
||||
refetch();
|
||||
refetchLifts();
|
||||
toast.success(`${value.serialNumber} was just created `);
|
||||
} catch (error) {
|
||||
// @ts-ignore
|
||||
|
||||
@@ -34,6 +34,7 @@ export default function NewInvoice({
|
||||
invoiceNumber: "",
|
||||
invoiceDate: "",
|
||||
totalAmount: "",
|
||||
comment: "",
|
||||
forklifts: [{ forklift_id: "", serialNumber: "", amount: "" }],
|
||||
},
|
||||
onSubmit: async ({ value }) => {
|
||||
@@ -198,6 +199,16 @@ export default function NewInvoice({
|
||||
<field.DateField label="Invoice Date" required={true} />
|
||||
)}
|
||||
/>
|
||||
<form.AppField
|
||||
name="comment"
|
||||
children={(field) => (
|
||||
<field.TextArea
|
||||
label="Comment"
|
||||
placeHolder="Enter your comment if needed."
|
||||
required={false}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<hr className="mt-2 mb-2" />
|
||||
{/* Dynamic forklift section */}
|
||||
|
||||
@@ -11,6 +11,7 @@ type Invoices = {
|
||||
id: string;
|
||||
invoiceNumber: string;
|
||||
invoiceDate: Date;
|
||||
comment: string;
|
||||
totalAmount: string;
|
||||
add_date: Date;
|
||||
};
|
||||
@@ -83,6 +84,26 @@ function RouteComponent() {
|
||||
return <span>{format(date, "MM/dd/yyyy")}</span>;
|
||||
},
|
||||
}),
|
||||
columnHelper.accessor("comment", {
|
||||
header: ({ column }) => {
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
>
|
||||
<span className="flex flex-row gap-2">Invoice Date</span>
|
||||
{column.getIsSorted() === "asc" ? (
|
||||
<ArrowUp className="ml-2 h-4 w-4" />
|
||||
) : (
|
||||
<ArrowDown className="ml-2 h-4 w-4" />
|
||||
)}
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
cell: ({ getValue }) => {
|
||||
return <span>{getValue()}</span>;
|
||||
},
|
||||
}),
|
||||
// columnHelper.accessor("add_date", {
|
||||
// header: ({ column }) => {
|
||||
// return (
|
||||
|
||||
Reference in New Issue
Block a user