add contract page with dynamic form elements

This commit is contained in:
Julien Aldon
2026-02-13 17:46:24 +01:00
parent ef7403f213
commit 7e42fbe106
34 changed files with 540 additions and 263 deletions

View File

@@ -1,29 +1,37 @@
import { t } from "@/config/i18n";
import type { Productor } from "@/services/resources/productors";
import type { Shipment } from "@/services/resources/shipments";
export const ProductType = [
"none",
t("planned"),
t("reccurent"),
];
type ProductTypeKey = "1" | "2";
type ProductUnitKey = "1" | "2" | "3";
export const ProductUnit = [
"none",
t("grams"),
t("kilo"),
t("piece"),
];
export const ProductType = {
"1": "planned",
"2": "recurrent",
};
export const ProductUnit = {
"1": "grams",
"2": "kilo",
"3": "piece",
};
export const ProductQuantityUnit = {
"ml": "mililiter",
"L": "liter",
"g": "grams",
"kg": "kilo"
}
export type Product = {
id: number;
productor: Productor;
name: string;
unit: string;
price: number;
unit: ProductUnitKey;
price: number | null;
price_kg: number | null;
weight: number;
type: string;
quantity: number | null;
quantity_unit: string | null;
type: ProductTypeKey;
shipments: Shipment[];
}
@@ -31,9 +39,10 @@ export type ProductCreate = {
productor_id: number;
name: string;
unit: string;
price: number;
price: number | null;
price_kg: number | null;
weight: number | null;
quantity: number | null;
quantity_unit: string | null;
type: string;
}
@@ -43,7 +52,8 @@ export type ProductEdit = {
unit: string | null;
price: number | null;
price_kg: number | null;
weight: number | null;
quantity: number | null;
quantity_unit: string | null;
type: string | null;
}
@@ -53,7 +63,8 @@ export type ProductInputs = {
unit: string | null;
price: number | null;
price_kg: number | null;
weight: number | null;
quantity: number | null;
quantity_unit: string | null;
type: string | null;
}
@@ -69,7 +80,8 @@ export function productToProductInputs(product: Product): ProductInputs {
unit: product.unit,
price: product.price,
price_kg: product.price_kg,
weight: product.weight,
quantity: product.quantity,
quantity_unit: product.quantity_unit,
type: product.type,
};
}
@@ -81,7 +93,8 @@ export function productCreateFromProductInputs(productInput: ProductInputs): Pro
unit: productInput.unit!,
price: productInput.price!,
price_kg: productInput.price_kg,
weight: productInput.weight,
quantity: productInput.quantity,
quantity_unit: productInput.quantity_unit,
type: productInput.type!,
}
}