fix i18n add help page

This commit is contained in:
Julien Aldon
2026-02-16 16:38:34 +01:00
parent be8e32ebed
commit 5354a74cac
21 changed files with 524 additions and 224 deletions

View File

@@ -77,6 +77,7 @@ export default function FormModal({ opened, onClose, currentForm, handleSubmit }
<TextInput
label={t("form name", { capfirst: true })}
placeholder={t("form name", { capfirst: true })}
description={t("form name recommandation", { capfirst: true })}
radius="sm"
withAsterisk
{...form.getInputProps("name")}

View File

@@ -14,7 +14,7 @@ export function Navbar() {
<NavLink
className={"navLink"}
aria-label={t("dashboard")}
to="/dashboard/productors"
to="/dashboard/help"
>
{t("dashboard", { capfirst: true })}
</NavLink>

View File

@@ -35,7 +35,7 @@ export function ProductForm({ inputForm, product, shipment }: ProductFormProps)
placeholder={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t(ProductUnit[product.unit])}`}
{...inputForm.getInputProps(
shipment
? `products.planned-${shipment.id}-${product.id}`
? `products.occasional-${shipment.id}-${product.id}`
: `products.recurrent-${product.id}`,
)}
/>

View File

@@ -41,19 +41,19 @@ export function ProductModal({ opened, onClose, currentProduct, handleSubmit }:
},
validate: {
name: (value) =>
!value ? `${t("name", { capfirst: true })} ${t("is required")}` : null,
!value ? `${t("a name", { capfirst: true })} ${t("is required")}` : null,
unit: (value) =>
!value ? `${t("unit", { capfirst: true })} ${t("is required")}` : null,
!value ? `${t("a sell unit", { capfirst: true })} ${t("is required")}` : null,
price: (value, values) =>
!value && !values.price_kg
? `${t("price or price_kg", { capfirst: true })} ${t("is required")}`
? `${t("a price or priceKg", { capfirst: true })} ${t("is required")}`
: null,
price_kg: (value, values) =>
!value && !values.price
? `${t("price or price_kg", { capfirst: true })} ${t("is required")}`
? `${t("a price or priceKg", { capfirst: true })} ${t("is required")}`
: null,
type: (value) =>
!value ? `${t("type", { capfirst: true })} ${t("is required")}` : null,
!value ? `${t("a type", { capfirst: true })} ${t("is required")}` : null,
productor_id: (value) =>
!value ? `${t("productor", { capfirst: true })} ${t("is required")}` : null,
},
@@ -79,35 +79,27 @@ export function ProductModal({ opened, onClose, currentProduct, handleSubmit }:
data={productorsSelect || []}
{...form.getInputProps("productor_id")}
/>
<Group grow>
<TextInput
label={t("product name", { capfirst: true })}
placeholder={t("product name", { capfirst: true })}
radius="sm"
{...form.getInputProps("name")}
/>
<Select
label={
<InputLabel
label={t("product type", { capfirst: true })}
info={t(
"recurrent product is for all shipments, planned product is for a specific shipment (see shipment form)",
{ capfirst: true },
)}
isRequired
/>
}
placeholder={t("product type", { capfirst: true })}
radius="sm"
searchable
clearable
data={[
{ value: "1", label: t("planned", { capfirst: true }) },
{ value: "2", label: t("recurrent", { capfirst: true }) },
]}
{...form.getInputProps("type")}
/>
</Group>
<TextInput
label={t("product name", { capfirst: true })}
placeholder={t("product name", { capfirst: true })}
radius="sm"
withAsterisk
{...form.getInputProps("name")}
/>
<Select
label={t("product type", { capfirst: true })}
placeholder={t("product type", { capfirst: true })}
radius="sm"
description={t("a product type define the way it will be organized on the final contract form (showed to users) it can be reccurent or occassional. Recurrent products will be set for all shipments if selected by user, Occasional products can be choosen for each shipments", {capfirst: true})}
searchable
clearable
withAsterisk
data={[
{ value: "1", label: t("occasional", { capfirst: true }) },
{ value: "2", label: t("recurrent", { capfirst: true }) },
]}
{...form.getInputProps("type")}
/>
<Select
label={t("product unit", { capfirst: true })}
placeholder={t("product unit", { capfirst: true })}

View File

@@ -22,7 +22,7 @@ export default function ShipmentForm({
}: ShipmentFormProps) {
const shipmentPrice = useMemo(() => {
const values = Object.entries(inputForm.getValues().products).filter(
([key]) => key.includes("planned") && key.split("-")[1] === String(shipment.id),
([key]) => key.includes("occasional") && key.split("-")[1] === String(shipment.id),
);
return computePrices(values, shipment.products);
}, [inputForm, shipment.products, shipment.id]);

View File

@@ -101,7 +101,7 @@ export default function ShipmentModal({
label={t("shipment products", { capfirst: true })}
placeholder={t("shipment products", { capfirst: true })}
description={t(
"shipment products is necessary only for planned products (if all products are recurrent leave empty)",
"shipment products is necessary only for occasional products (if all products are recurrent leave empty)",
{ capfirst: true },
)}
data={productsSelect || []}

View File

@@ -1,5 +1,5 @@
import i18next from "i18next";
// import LanguageDetector from "i18next-browser-languagedetector";
import LanguageDetector from "i18next-browser-languagedetector";
import { Settings } from "luxon";
import { initReactI18next } from "react-i18next";
@@ -13,6 +13,7 @@ const resources = {
};
i18next
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: resources,

View File

@@ -114,7 +114,7 @@ export function Contract() {
form.shipments.forEach((shipment) => {
shipment.products.forEach((product) => {
const key = `planned-${shipment.id}-${product.id}`;
const key = `occasional-${shipment.id}-${product.id}`;
if (result[key] === undefined || result[key] === "") {
result[key] = 0;
}
@@ -250,7 +250,7 @@ export function Contract() {
) : null}
{shipments.some((shipment) => shipment.products.length > 0) ? (
<>
<Title order={3}>{t("planned products")}</Title>
<Title order={3}>{t("occasional products")}</Title>
<Text>{t("select products per shipment")}</Text>
<Accordion defaultValue={"0"}>
{shipments.map((shipment, index) => (

View File

@@ -11,10 +11,11 @@ export default function Dashboard() {
w={{ base: "100%", md: "80%", lg: "60%" }}
orientation={"horizontal"}
value={location.pathname.split("/")[2]}
defaultValue={"productors"}
defaultValue={"help"}
onChange={(value) => navigate(`/dashboard/${value}`)}
>
<Tabs.List>
<Tabs.Tab value="help">{t("help", { capfirst: true })}</Tabs.Tab>
<Tabs.Tab value="productors">{t("productors", { capfirst: true })}</Tabs.Tab>
<Tabs.Tab value="products">{t("products", { capfirst: true })}</Tabs.Tab>
<Tabs.Tab value="forms">{t("forms", { capfirst: true })}</Tabs.Tab>

View File

@@ -0,0 +1,231 @@
import { t } from "@/config/i18n";
import { Accordion, ActionIcon, Blockquote, Group, NumberInput, Paper, Select, Stack, TableOfContents, Text, TextInput, Title } from "@mantine/core";
import { IconEdit, IconInfoCircle, IconLink, IconPlus, IconTestPipe, IconX } from "@tabler/icons-react";
import { Link } from "react-router";
export function Help() {
return (
<Stack>
<Title order={2}>{t("how to use dashboard", {capfirst: true})}</Title>
<Text>
{t("dashboard is for referers only, with this dashboard you can create productors, products, forms and shipments", {capfirst: true})}
</Text>
<TableOfContents
variant="filled"
color="blue"
size="sm"
radius="sm"
scrollSpyOptions={{
selector: 'h3, h4',
}}
getControlProps={({ data }) => ({
onClick: () => data.getNode().scrollIntoView(),
children: data.value,
})}
/>
<Title order={3}>{t("creation order", {capfirst: true})}</Title>
<Stack gap="1">
<Title order={4}>{t("a productor", {capfirst: true})}</Title>
<Text>
{t("start to create a productor in the productors section", {capfirst: true})}
<ActionIcon
ml="4"
size="xs"
component={Link}
to="/dashboard/productors"
aria-label={t("link to the section", {capfirst: true, section: t("productors")})}
style={{cursor: "pointer", alignSelf: "center"}}
><IconLink/></ActionIcon>
</Text>
<Text>{t("a productor can be edited if its informations change, it should not be recreated for each contracts", {capfirst: true})}</Text>
<Blockquote
mt="md"
icon={<IconInfoCircle/>}
>
<Text>{t("to add a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm"><IconPlus/></ActionIcon> {t("button in top left of the page", {section: t("productors")})}</Text>
<Text>{t("to edit a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm"><IconEdit/></ActionIcon> {t("button in front of the line you want to edit")}</Text>
<Text>{t("to delete a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm" color="red"><IconX/></ActionIcon> {t("button in front of the line you want to delete")}</Text>
</Blockquote>
</Stack>
<Stack gap="1">
<Title order={4}>{t("the products", {capfirst: true})}</Title>
<Text>
{t("add all products linked to this productor in the products section", {capfirst: true})}
<ActionIcon
ml="4"
size="xs"
component={Link}
to="/dashboard/products"
aria-label={t("link to the section", {capfirst: true, section: t("products")})}
style={{cursor: "pointer", alignSelf: "center"}}
><IconLink/></ActionIcon>
</Text>
<Text>{t("a product can be edited if its informations change, it should not be recreated for each contracts", {capfirst: true})}</Text>
<Blockquote
mt="md"
icon={<IconInfoCircle/>}
>
<Text>{t("to add a use the", {capfirst: true, section: t("a product")})} <ActionIcon size="sm"><IconPlus/></ActionIcon> {t("button in top left of the page", {section: t("products")})}</Text>
<Text>{t("to edit a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm"><IconEdit/></ActionIcon> {t("button in front of the line you want to edit")}</Text>
<Text>{t("to delete a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm" color="red"><IconX/></ActionIcon> {t("button in front of the line you want to delete")}</Text>
</Blockquote>
</Stack>
<Stack gap="1">
<Title order={4}>{t("a form", {capfirst: true})}</Title>
<Text>
{t("create your contract form, it will create a form in the home page (accessible to users)", {capfirst: true})}
<ActionIcon
ml="4"
size="xs"
component={Link}
to="/dashboard/products"
aria-label={t("link to the section", {capfirst: true, section: t("forms")})}
style={{cursor: "pointer", alignSelf: "center"}}
><IconLink/></ActionIcon>
</Text>
<Text>{t("a new contract form should be created for each new season, do not edit a previous contract and change it's values (for history purpose)", {capfirst: true})}</Text>
<Blockquote
mt="md"
icon={<IconInfoCircle/>}
>
<Text>{t("to add a use the", {capfirst: true, section: t("a form")})} <ActionIcon size="sm"><IconPlus/></ActionIcon> {t("button in top left of the page", {section: t("forms")})}</Text>
<Text>{t("to edit a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm"><IconEdit/></ActionIcon> {t("button in front of the line you want to edit")}</Text>
<Text>{t("to delete a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm" color="red"><IconX/></ActionIcon> {t("button in front of the line you want to delete")}</Text>
</Blockquote>
</Stack>
<Stack gap="1">
<Title order={4}>{t("the shipments", {capfirst: true})}</Title>
<Text>
{t("create shipments for your contract form", {capfirst: true})}
<ActionIcon
ml="4"
size="xs"
component={Link}
to="/dashboard/products"
aria-label={t("link to the section", {capfirst: true, section: t("shipments")})}
style={{cursor: "pointer", alignSelf: "center"}}
><IconLink/></ActionIcon>
</Text>
<Text>
{t("all shipments should be recreated for each form creation", {capfirst: true})}
</Text>
<Blockquote
mt="md"
icon={<IconInfoCircle/>}
>
<Text>{t("to add a use the", {capfirst: true, section: t("a shipment")})} <ActionIcon size="sm"><IconPlus/></ActionIcon> {t("button in top left of the page", {section: t("shipments")})}</Text>
<Text>{t("to edit a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm"><IconEdit/></ActionIcon> {t("button in front of the line you want to edit")}</Text>
<Text>{t("to delete a use the", {capfirst: true, section: t("a productor")})} <ActionIcon size="sm" color="red"><IconX/></ActionIcon> {t("button in front of the line you want to delete")}</Text>
</Blockquote>
</Stack>
<Title order={3}>{t("glossary", {capfirst: true})}</Title>
<Stack>
<Title order={4} fw={700}>{t("product type", {capfirst: true})}</Title>
<Text>{t("a product type define the way it will be organized on the final contract form (showed to users) it can be reccurent or occassional. Recurrent products will be set for all shipments if selected by user, Occasional products can be choosen for each shipments", {capfirst: true})}</Text>
<Stack>
<Text>{t("example in user forms", {capfirst: true})} ({t("recurrent product")}) :</Text>
<Blockquote
color="black"
icon={<IconTestPipe/>}
>
<Title order={5}>{t('recurrent products')}</Title>
<Text size="sm">
{t("your selection in this category will apply for all shipments", {
capfirst: true,
})}
</Text>
<NumberInput
label={t("product example", {capfirst: true})}
description={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("piece")}`}
aria-label={t("enter quantity")}
placeholder={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("piece")}`}
/>
</Blockquote>
<Text>{t("example in user forms", {capfirst: true})} ({t("occasional product")}) :</Text>
<Blockquote
color="black"
icon={<IconTestPipe/>}
>
<Title order={5}>{t('occasional products')}</Title>
<Text>{t("select products per shipment")}</Text>
<Accordion defaultValue={"0"}>
<Accordion.Item value={"example1"}>
<Accordion.Control>{t("shipment", {capfirst: true})} 1</Accordion.Control>
<Accordion.Panel>
<NumberInput
label={t("product example", {capfirst: true})}
description={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("piece")}`}
aria-label={t("enter quantity")}
placeholder={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("piece")}`}
/>
</Accordion.Panel>
</Accordion.Item>
<Accordion.Item value={"example2"}>
<Accordion.Control>{t("shipment", {capfirst: true})} 2</Accordion.Control>
<Accordion.Panel>
<NumberInput
label={t("product example", {capfirst: true})}
description={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("piece")}`}
aria-label={t("enter quantity")}
placeholder={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("piece")}`}
/>
</Accordion.Panel>
</Accordion.Item>
</Accordion>
</Blockquote>
</Stack>
<Title order={4} fw={700}>{t("sell unit", {capfirst: true})}</Title>
<Text>{t("the product unit will be assigned to the quantity requested in the form")}</Text>
<Stack w={"100%"}>
<Text>{t("example in user forms", {capfirst: true})} ({t("with grams as product unit selected")}) :</Text>
<Blockquote
color="black"
icon={<IconTestPipe/>}
>
<NumberInput
label={t("product example", {capfirst: true})}
description={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("grams")}`}
aria-label={t("enter quantity")}
placeholder={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("grams")}`}
/>
</Blockquote>
</Stack>
<Title order={4} fw={700}>{t("payment methods", {capfirst: true})}</Title>
<Text>{t("payment methods are defined for a productor. At the end of a form a section payment method let the user select his prefered payment method", {capfirst: true})}</Text>
<Stack>
<Text>{t("example in user forms", {capfirst: true})} ({t("with cheque and transfer")}) :</Text>
<Blockquote
color="black"
icon={<IconTestPipe/>}
>
<Title order={5}>{t("payment method", { capfirst: true })}</Title>
<Select
label={t("payment method", { capfirst: true })}
placeholder={t("enter payment method", { capfirst: true })}
description={t("choose payment method", { capfirst: true })}
data={[t("cheque", {capfirst: true}), t("transfer", {capfirst: true})]}
/>
</Blockquote>
</Stack>
<Title order={4} fw={700}>{t("product quantity", {capfirst: true})}</Title>
<Text>{t("this field is optionnal a product can have a quantity if configured inside the product it will be shown inside the form", {capfirst: true})}</Text>
<Title order={4} fw={700}>{t("product quantity unit", {capfirst: true})}</Title>
<Text>{t("this field is also optionnal if a product have a quantity you can select the correct unit (metric system). It will be shown next to product quantity inside the form", {capfirst: true})}</Text>
<Text>{t("example in user forms", {capfirst: true})} ({t("with 150 set as quantity and g as quantity unit in product")}):</Text>
<Blockquote
color="black"
icon={<IconTestPipe/>}
>
<NumberInput
label={`${t("product example", {capfirst: true})} 150g`}
description={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("pieces")}`}
aria-label={t("enter quantity")}
placeholder={`${t("enter quantity", { capfirst: true })} ${t("in")} ${t("pieces")}`}
/>
</Blockquote>
</Stack>
</Stack>
);
}

View File

@@ -142,7 +142,7 @@ export default function Shipments() {
<Table.Tr>
<Table.Th>{t("name", { capfirst: true })}</Table.Th>
<Table.Th>{t("date", { capfirst: true })}</Table.Th>
<Table.Th>{t("formulare", { capfirst: true })}</Table.Th>
<Table.Th>{t("form", { capfirst: true })}</Table.Th>
<Table.Th>{t("actions", { capfirst: true })}</Table.Th>
</Table.Tr>
</Table.Thead>

View File

@@ -11,6 +11,7 @@ import Shipments from "./pages/Shipments";
import { Contract } from "./pages/Contract";
import { NotFound } from "./pages/NotFound";
import Contracts from "./pages/Contracts";
import { Help } from "./pages/Help";
export const router = createBrowserRouter([
{
@@ -24,6 +25,7 @@ export const router = createBrowserRouter([
path: "/dashboard",
Component: Dashboard,
children: [
{ path: "help", Component: Help },
{ path: "productors", Component: Productors },
{ path: "productors/create", Component: Productors },
{ path: "productors/:id/edit", Component: Productors },

View File

@@ -58,14 +58,14 @@ export function useCreateShipment() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully created shipment", { capfirst: true }),
message: t("success create", { capfirst: true, entity: t("shipment") }),
});
await queryClient.invalidateQueries({ queryKey: ["shipments"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing shipment`, { capfirst: true }),
message: error?.message || t(`error create`, { capfirst: true, entity: t("of the shipment") }),
color: "red",
});
},
@@ -88,14 +88,14 @@ export function useEditShipment() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully edited shipment", { capfirst: true }),
message: t("success edit", { capfirst: true, entity: t("shipment") }),
});
await queryClient.invalidateQueries({ queryKey: ["shipments"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing shipment`, { capfirst: true }),
message: error?.message || t(`error edit`, { capfirst: true, entity: t("of the shipment") }),
color: "red",
});
},
@@ -116,14 +116,14 @@ export function useDeleteShipment() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully deleted shipment", { capfirst: true }),
message: t("success delete", { capfirst: true, entity: t("shipment") }),
});
await queryClient.invalidateQueries({ queryKey: ["shipments"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error deleting shipment`, { capfirst: true }),
message: error?.message || t(`error delete`, { capfirst: true, entity: t("of the contract") }),
color: "red",
});
},
@@ -169,14 +169,14 @@ export function useCreateProductor() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully created productor", { capfirst: true }),
message: t("success create", { capfirst: true, entity: t("productor") }),
});
await queryClient.invalidateQueries({ queryKey: ["productors"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing productor`, { capfirst: true }),
message: error?.message || t(`error create`, { capfirst: true, entity: t("of the productor") }),
color: "red",
});
},
@@ -199,14 +199,14 @@ export function useEditProductor() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully edited productor", { capfirst: true }),
message: t("success edit", { capfirst: true, entity: t("productor") }),
});
await queryClient.invalidateQueries({ queryKey: ["productors"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing productor`, { capfirst: true }),
message: error?.message || t(`error edit`, { capfirst: true, entity: t("of the productor") }),
color: "red",
});
},
@@ -227,14 +227,14 @@ export function useDeleteProductor() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully deleted productor", { capfirst: true }),
message: t("success delete", { capfirst: true, entity: t("productor") }),
});
await queryClient.invalidateQueries({ queryKey: ["productors"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error deleting productor`, { capfirst: true }),
message: error?.message || t(`error delete`, { capfirst: true, entity: t("of the productor") }),
color: "red",
});
},
@@ -297,14 +297,14 @@ export function useDeleteForm() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully deleted form", { capfirst: true }),
message: t("success delete", { capfirst: true, entity: t("form") }),
});
await queryClient.invalidateQueries({ queryKey: ["forms"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error deleting form`, { capfirst: true }),
message: error?.message || t(`error delete`, { capfirst: true, entity: t("of the form") }),
color: "red",
});
},
@@ -327,14 +327,14 @@ export function useEditForm() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully edited form", { capfirst: true }),
message: t("success edit", { capfirst: true, entity: t("form") }),
});
await queryClient.invalidateQueries({ queryKey: ["forms"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing form`, { capfirst: true }),
message: error?.message || t(`error edit`, { capfirst: true, entity: t("of the form") }),
color: "red",
});
},
@@ -380,14 +380,14 @@ export function useCreateProduct() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully created product", { capfirst: true }),
message: t("success create", { capfirst: true, entity: t("product") }),
});
await queryClient.invalidateQueries({ queryKey: ["products"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing product`, { capfirst: true }),
message: error?.message || t(`error create`, { capfirst: true, entity: t("of the productor") }),
color: "red",
});
},
@@ -408,14 +408,14 @@ export function useDeleteProduct() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully deleted product", { capfirst: true }),
message: t("success delete", { capfirst: true, entity: t("product") }),
});
await queryClient.invalidateQueries({ queryKey: ["products"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error deleting product`, { capfirst: true }),
message: error?.message || t(`error delete`, { capfirst: true, entity: t("of the product") }),
color: "red",
});
},
@@ -438,14 +438,14 @@ export function useEditProduct() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully edited product", { capfirst: true }),
message: t("success edit", { capfirst: true, entity: t("product") }),
});
await queryClient.invalidateQueries({ queryKey: ["products"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing product`, { capfirst: true }),
message: error?.message || t(`error edit`, { capfirst: true, entity: t("of the product") }),
color: "red",
});
},
@@ -491,14 +491,14 @@ export function useCreateUser() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully created user", { capfirst: true }),
message: t("success create", { capfirst: true, entity: t("user") }),
});
await queryClient.invalidateQueries({ queryKey: ["users"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing user`, { capfirst: true }),
message: error?.message || t(`error create`, { capfirst: true, entity: t("of the user") }),
color: "red",
});
},
@@ -519,14 +519,14 @@ export function useDeleteUser() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully deleted user", { capfirst: true }),
message: t("success delete", { capfirst: true, entity: t("user") }),
});
await queryClient.invalidateQueries({ queryKey: ["users"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error deleting user`, { capfirst: true }),
message: error?.message || t(`error delete`, { capfirst: true, entity: t("of the user") }),
color: "red",
});
},
@@ -549,14 +549,14 @@ export function useEditUser() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully edited user", { capfirst: true }),
message: t("success edit", { capfirst: true, entity: t("user") }),
});
await queryClient.invalidateQueries({ queryKey: ["users"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error editing user`, { capfirst: true }),
message: error?.message || t(`error edit`, { capfirst: true, entity: t("of the user") }),
color: "red",
});
},
@@ -625,14 +625,14 @@ export function useDeleteContract() {
onSuccess: async () => {
notifications.show({
title: t("success", { capfirst: true }),
message: t("successfully deleted contract", { capfirst: true }),
message: t("success delete", { capfirst: true, entity: t("contract") }),
});
await queryClient.invalidateQueries({ queryKey: ["contracts"] });
},
onError: (error) => {
notifications.show({
title: t("error", { capfirst: true }),
message: error?.message || t(`error deleting contract`, { capfirst: true }),
message: error?.message || t(`error delete`, { capfirst: true, entity: t("of the contract") }),
color: "red",
});
},

View File

@@ -61,8 +61,8 @@ export function tranformProducts(
return Object.entries(products).map(([key, value]) => {
const quantity = value;
const parts = key.split("-");
const shipment_id = parts[0] === "planned" ? Number(parts[1]) : null;
const product_id = parts[0] === "planned" ? Number(parts[2]) : Number(parts[1]);
const shipment_id = parts[0] === "occasional" ? Number(parts[1]) : null;
const product_id = parts[0] === "occasional" ? Number(parts[2]) : Number(parts[1]);
return {
quantity: Number(quantity),
shipment_id: shipment_id,

View File

@@ -5,7 +5,7 @@ type ProductTypeKey = "1" | "2";
type ProductUnitKey = "1" | "2" | "3";
export const ProductType = {
"1": "planned",
"1": "occasional",
"2": "recurrent",
};