Skip to content

Commit

Permalink
feat: OrderSignals collection et create once at button call
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNumericite committed Nov 7, 2024
1 parent 20bea0f commit 7799dd5
Show file tree
Hide file tree
Showing 7 changed files with 4,445 additions and 4 deletions.
6 changes: 6 additions & 0 deletions webapp/src/pages/dashboard/order/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default function OrderObizPage() {

const { data: order } = resultOrder || {};

const { mutateAsync: mutateCreateSignal } =
api.order.createSignal.useMutation({});

const amount = useMemo(() => {
return formatter2Digits.format(
order?.articles?.reduce((acc, curr) => {
Expand Down Expand Up @@ -126,6 +129,9 @@ export default function OrderObizPage() {
};

const signalIssueWithOrder = () => {
mutateCreateSignal({
id: order.id,
});
onOpenModalSignalIssue();
};

Expand Down
26 changes: 26 additions & 0 deletions webapp/src/payload/collections/OrderSignal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { type CollectionConfig } from "payload/types";
import { isAdmin } from "../access/isAdmin";

export const OrderSignals: CollectionConfig = {
slug: "ordersignals",
labels: {
singular: "Signalement",
plural: "Signalements",
},
access: {
read: isAdmin,
create: isAdmin,
update: isAdmin,
delete: isAdmin,
},
fields: [
{
name: "order",
type: "relationship",
label: "Signalement",
relationTo: "orders",
required: true,
unique: true,
},
],
};
Loading

0 comments on commit 7799dd5

Please sign in to comment.