@vicacha-devs/medusa-plugin-b2b 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -797,83 +797,502 @@ var GuardedB2BOverview = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
|
797
797
|
permission: "b2b.read",
|
|
798
798
|
children: /* @__PURE__ */ jsx(B2BOverview, {})
|
|
799
799
|
});
|
|
800
|
-
// src/admin/routes/b2b/
|
|
800
|
+
// src/admin/routes/b2b/approvals/components/approval-actions.tsx
|
|
801
|
+
var ApprovalActions = ({ cart }) => {
|
|
802
|
+
const { t } = useTranslation();
|
|
803
|
+
const dialog = usePrompt();
|
|
804
|
+
const [rejectOpen, setRejectOpen] = useState(false);
|
|
805
|
+
const [reason, setReason] = useState("");
|
|
806
|
+
const pendingApproval = cart.approvals?.find((a) => a.type === ApprovalType.ADMIN && a.status === ApprovalStatusType.PENDING) ?? cart.approvals?.find((a) => a.type === ApprovalType.SALES_MANAGER && a.status === ApprovalStatusType.PENDING);
|
|
807
|
+
const { mutateAsync: updateApproval } = useUpdateApproval(pendingApproval?.id);
|
|
808
|
+
const approveCart = async () => {
|
|
809
|
+
if (!await dialog({
|
|
810
|
+
title: t("approvals.prompts.approve.title"),
|
|
811
|
+
description: t("approvals.prompts.approve.description")
|
|
812
|
+
})) return;
|
|
813
|
+
try {
|
|
814
|
+
await updateApproval({ status: ApprovalStatusType.APPROVED });
|
|
815
|
+
toast.success(t("approvals.toasts.approved"));
|
|
816
|
+
} catch {
|
|
817
|
+
toast.error(t("approvals.toasts.approveError"));
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
const openRejectDialog = () => {
|
|
821
|
+
setReason("");
|
|
822
|
+
setRejectOpen(true);
|
|
823
|
+
};
|
|
824
|
+
const confirmReject = async () => {
|
|
825
|
+
try {
|
|
826
|
+
await updateApproval({
|
|
827
|
+
status: ApprovalStatusType.REJECTED,
|
|
828
|
+
reason: reason.trim() || null
|
|
829
|
+
});
|
|
830
|
+
toast.success(t("approvals.toasts.rejected"));
|
|
831
|
+
setRejectOpen(false);
|
|
832
|
+
} catch {
|
|
833
|
+
toast.error(t("approvals.toasts.rejectError"));
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
if (!pendingApproval || cart.approval_status?.status !== ApprovalStatusType.PENDING) return null;
|
|
837
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ActionMenu, { groups: [{ actions: [{
|
|
838
|
+
label: t("actions.reject"),
|
|
839
|
+
onClick: openRejectDialog,
|
|
840
|
+
icon: /* @__PURE__ */ jsx(XMark, {})
|
|
841
|
+
}] }, { actions: [{
|
|
842
|
+
label: t("actions.approve"),
|
|
843
|
+
onClick: approveCart,
|
|
844
|
+
icon: /* @__PURE__ */ jsx(Check, {})
|
|
845
|
+
}] }] }), /* @__PURE__ */ jsx(Drawer, {
|
|
846
|
+
open: rejectOpen,
|
|
847
|
+
onOpenChange: setRejectOpen,
|
|
848
|
+
children: /* @__PURE__ */ jsxs(Drawer.Content, { children: [
|
|
849
|
+
/* @__PURE__ */ jsxs(Drawer.Header, { children: [/* @__PURE__ */ jsx(Drawer.Title, { children: t("approvals.prompts.reject.title") }), /* @__PURE__ */ jsx(Drawer.Description, { children: t("approvals.prompts.reject.description") })] }),
|
|
850
|
+
/* @__PURE__ */ jsxs(Drawer.Body, {
|
|
851
|
+
className: "flex flex-col gap-y-3",
|
|
852
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
853
|
+
htmlFor: "reject-reason",
|
|
854
|
+
children: t("approvals.table.reason")
|
|
855
|
+
}), /* @__PURE__ */ jsx(Textarea, {
|
|
856
|
+
id: "reject-reason",
|
|
857
|
+
value: reason,
|
|
858
|
+
onChange: (e) => setReason(e.target.value),
|
|
859
|
+
placeholder: t("approvals.prompts.reject.reasonPlaceholder")
|
|
860
|
+
})]
|
|
861
|
+
}),
|
|
862
|
+
/* @__PURE__ */ jsxs(Drawer.Footer, { children: [/* @__PURE__ */ jsx(Drawer.Close, {
|
|
863
|
+
asChild: true,
|
|
864
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
865
|
+
variant: "secondary",
|
|
866
|
+
size: "small",
|
|
867
|
+
children: t("actions.cancel")
|
|
868
|
+
})
|
|
869
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
870
|
+
variant: "danger",
|
|
871
|
+
size: "small",
|
|
872
|
+
onClick: confirmReject,
|
|
873
|
+
children: t("actions.reject")
|
|
874
|
+
})] })
|
|
875
|
+
] })
|
|
876
|
+
})] });
|
|
877
|
+
};
|
|
878
|
+
// src/admin/routes/b2b/approvals/components/approvals-items-popover.tsx
|
|
879
|
+
var ItemsPopover = ({ items, currencyCode }) => {
|
|
880
|
+
const { t } = useTranslation();
|
|
881
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
882
|
+
className: "flex text-right items-center gap-1 hover:cursor-pointer",
|
|
883
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
884
|
+
className: "underline underline-offset-4 min-w-14 ",
|
|
885
|
+
children: [
|
|
886
|
+
items?.length,
|
|
887
|
+
" item",
|
|
888
|
+
items?.length !== 1 ? "s" : ""
|
|
889
|
+
]
|
|
890
|
+
}), /* @__PURE__ */ jsx(MagnifyingGlass, {})]
|
|
891
|
+
}), /* @__PURE__ */ jsx(Popover.Content, {
|
|
892
|
+
className: "p-0 mr-10",
|
|
893
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
894
|
+
className: "max-h-1/3 overflow-y-auto",
|
|
895
|
+
children: /* @__PURE__ */ jsx(Table, { children: /* @__PURE__ */ jsx(Table.Body, { children: items?.map((item) => /* @__PURE__ */ jsxs(Table.Row, {
|
|
896
|
+
className: "py-2 hover:bg-transparent",
|
|
897
|
+
children: [/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx("div", {
|
|
898
|
+
className: "w-10 h-10 overflow-hidden flex items-center justify-center",
|
|
899
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
900
|
+
src: item.thumbnail,
|
|
901
|
+
alt: item.product_title,
|
|
902
|
+
className: "h-10 object-contain mr-4"
|
|
903
|
+
})
|
|
904
|
+
}) }), /* @__PURE__ */ jsxs(Table.Cell, {
|
|
905
|
+
className: "py-2",
|
|
906
|
+
children: [
|
|
907
|
+
/* @__PURE__ */ jsx(Text, {
|
|
908
|
+
className: "font-medium truncate max-w-60",
|
|
909
|
+
children: item.product_title
|
|
910
|
+
}),
|
|
911
|
+
/* @__PURE__ */ jsx(Text, {
|
|
912
|
+
className: "text-sm text-gray-500",
|
|
913
|
+
children: item.variant_title
|
|
914
|
+
}),
|
|
915
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
916
|
+
className: "text-sm text-gray-500",
|
|
917
|
+
children: [
|
|
918
|
+
item.quantity,
|
|
919
|
+
" x",
|
|
920
|
+
" ",
|
|
921
|
+
formatCurrency(item.unit_price, currencyCode),
|
|
922
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
923
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
924
|
+
className: "font-medium",
|
|
925
|
+
children: [
|
|
926
|
+
t("approvals.items.itemTotal"),
|
|
927
|
+
" ",
|
|
928
|
+
formatCurrency(item.quantity * item.unit_price, currencyCode)
|
|
929
|
+
]
|
|
930
|
+
})
|
|
931
|
+
]
|
|
932
|
+
})
|
|
933
|
+
]
|
|
934
|
+
})]
|
|
935
|
+
}, item.id)) }) })
|
|
936
|
+
})
|
|
937
|
+
})] });
|
|
938
|
+
};
|
|
939
|
+
// src/admin/routes/b2b/approvals/components/approval-status-badge.tsx
|
|
940
|
+
var StatusColors = {
|
|
941
|
+
approved: "green",
|
|
942
|
+
pending: "purple",
|
|
943
|
+
rejected: "red"
|
|
944
|
+
};
|
|
945
|
+
function ApprovalStatusBadge({ status }) {
|
|
946
|
+
const { t } = useTranslation();
|
|
947
|
+
const titles = {
|
|
948
|
+
approved: t("approvals.filters.approved"),
|
|
949
|
+
pending: t("approvals.filters.pending"),
|
|
950
|
+
rejected: t("approvals.filters.rejected")
|
|
951
|
+
};
|
|
952
|
+
return /* @__PURE__ */ jsx(DataTableStatusCell, {
|
|
953
|
+
color: StatusColors[status],
|
|
954
|
+
children: titles[status]
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
// src/admin/routes/b2b/approvals/components/table/columns.tsx
|
|
801
958
|
var columnHelper$4 = legacyCreateColumnHelper();
|
|
802
|
-
var
|
|
959
|
+
var useApprovalsTableColumns = () => {
|
|
803
960
|
const { t } = useTranslation();
|
|
804
961
|
return useMemo(() => [
|
|
805
|
-
columnHelper$4.accessor("
|
|
806
|
-
header: "",
|
|
962
|
+
columnHelper$4.accessor("id", {
|
|
963
|
+
header: t("fields.id"),
|
|
964
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { text: `#${getValue().slice(-4)}` })
|
|
965
|
+
}),
|
|
966
|
+
columnHelper$4.accessor("updated_at", {
|
|
967
|
+
header: t("approvals.table.updatedAt"),
|
|
968
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(DateCell, { date: getValue() })
|
|
969
|
+
}),
|
|
970
|
+
columnHelper$4.accessor("company.name", {
|
|
971
|
+
header: () => /* @__PURE__ */ jsx(TextHeader, { text: t("fields.company") }),
|
|
972
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { text: getValue() })
|
|
973
|
+
}),
|
|
974
|
+
columnHelper$4.accessor("approvals", {
|
|
975
|
+
id: "approvals_type",
|
|
976
|
+
header: t("approvals.table.type"),
|
|
807
977
|
cell: ({ getValue }) => {
|
|
808
|
-
const
|
|
809
|
-
if (!
|
|
810
|
-
return /* @__PURE__ */ jsx("
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
978
|
+
const approvals = getValue() ?? [];
|
|
979
|
+
if (!approvals.length) return /* @__PURE__ */ jsx(TextCell, { text: "—" });
|
|
980
|
+
return /* @__PURE__ */ jsx("div", {
|
|
981
|
+
className: "flex flex-wrap gap-1",
|
|
982
|
+
children: approvals.map((a) => /* @__PURE__ */ jsx(Badge, {
|
|
983
|
+
size: "2xsmall",
|
|
984
|
+
rounded: "full",
|
|
985
|
+
color: a.type === "admin" ? "blue" : "purple",
|
|
986
|
+
children: a.type === "admin" ? "Admin" : "Sales Mgr"
|
|
987
|
+
}, a.id))
|
|
814
988
|
});
|
|
815
989
|
}
|
|
816
990
|
}),
|
|
817
|
-
columnHelper$4.accessor("
|
|
818
|
-
header: t("fields.
|
|
819
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(
|
|
820
|
-
className: "txt-compact-small font-medium",
|
|
821
|
-
children: getValue()
|
|
822
|
-
})
|
|
823
|
-
}),
|
|
824
|
-
columnHelper$4.accessor("email", {
|
|
825
|
-
header: t("fields.email"),
|
|
826
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
827
|
-
className: "txt-compact-small",
|
|
828
|
-
children: getValue() || "—"
|
|
829
|
-
})
|
|
991
|
+
columnHelper$4.accessor("approval_status.status", {
|
|
992
|
+
header: t("fields.status"),
|
|
993
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(ApprovalStatusBadge, { status: getValue() })
|
|
830
994
|
}),
|
|
831
|
-
columnHelper$4.accessor("
|
|
832
|
-
header: t("fields.
|
|
833
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(
|
|
834
|
-
|
|
835
|
-
|
|
995
|
+
columnHelper$4.accessor("items", {
|
|
996
|
+
header: t("fields.items"),
|
|
997
|
+
cell: ({ getValue, row }) => /* @__PURE__ */ jsx(ItemsPopover, {
|
|
998
|
+
items: getValue(),
|
|
999
|
+
currencyCode: row.original.currency_code
|
|
836
1000
|
})
|
|
837
1001
|
}),
|
|
838
|
-
columnHelper$4.accessor("
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1002
|
+
columnHelper$4.accessor("approvals", {
|
|
1003
|
+
id: "approvals_handled_by",
|
|
1004
|
+
header: t("approvals.table.handledBy"),
|
|
1005
|
+
cell: ({ getValue }) => {
|
|
1006
|
+
const names = (getValue() ?? []).filter((a) => a.handled_by).map((a) => a.handled_by);
|
|
1007
|
+
return /* @__PURE__ */ jsx(TextCell, { text: names.length ? names.join(", ") : "—" });
|
|
1008
|
+
}
|
|
844
1009
|
}),
|
|
845
|
-
columnHelper$4.accessor("
|
|
846
|
-
|
|
1010
|
+
columnHelper$4.accessor("approvals", {
|
|
1011
|
+
id: "approvals_handled_at",
|
|
1012
|
+
header: t("approvals.table.handledAt"),
|
|
847
1013
|
cell: ({ getValue }) => {
|
|
848
|
-
const
|
|
849
|
-
return /* @__PURE__ */ jsx("
|
|
850
|
-
className: "txt-compact-small",
|
|
851
|
-
children: code ? code.toUpperCase() : "—"
|
|
852
|
-
});
|
|
1014
|
+
const dates = (getValue() ?? []).filter((a) => a.handled_at).map((a) => a.handled_at).toSorted().toReversed();
|
|
1015
|
+
return dates.length ? /* @__PURE__ */ jsx(DateCell, { date: dates[0] }) : /* @__PURE__ */ jsx(TextCell, { text: "—" });
|
|
853
1016
|
}
|
|
854
1017
|
}),
|
|
855
|
-
columnHelper$4.accessor("
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1018
|
+
columnHelper$4.accessor("approvals", {
|
|
1019
|
+
id: "approvals_reason",
|
|
1020
|
+
header: t("approvals.table.reason"),
|
|
1021
|
+
cell: ({ getValue }) => {
|
|
1022
|
+
const reason = (getValue() ?? []).find((a) => a.reason)?.reason;
|
|
1023
|
+
return /* @__PURE__ */ jsx(TextCell, { text: reason ?? "—" });
|
|
1024
|
+
}
|
|
861
1025
|
}),
|
|
862
|
-
columnHelper$4.accessor("
|
|
863
|
-
header: t("
|
|
864
|
-
cell: ({
|
|
1026
|
+
columnHelper$4.accessor("actions", {
|
|
1027
|
+
header: t("approvals.table.actions"),
|
|
1028
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(ApprovalActions, { cart: row.original })
|
|
865
1029
|
})
|
|
866
1030
|
], [t]);
|
|
867
1031
|
};
|
|
868
|
-
// src/admin/routes/b2b/
|
|
869
|
-
var
|
|
1032
|
+
// src/admin/routes/b2b/approvals/components/table/filters.tsx
|
|
1033
|
+
var useApprovalsTableFilters = () => {
|
|
870
1034
|
const { t } = useTranslation();
|
|
871
|
-
return [
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
1035
|
+
return [{
|
|
1036
|
+
label: t("approvals.filters.status"),
|
|
1037
|
+
key: "status",
|
|
1038
|
+
type: "select",
|
|
1039
|
+
options: [
|
|
1040
|
+
{
|
|
1041
|
+
label: t("approvals.filters.pending"),
|
|
1042
|
+
value: ApprovalStatusType.PENDING
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
label: t("approvals.filters.approved"),
|
|
1046
|
+
value: ApprovalStatusType.APPROVED
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
label: t("approvals.filters.rejected"),
|
|
1050
|
+
value: ApprovalStatusType.REJECTED
|
|
1051
|
+
}
|
|
1052
|
+
]
|
|
1053
|
+
}];
|
|
1054
|
+
};
|
|
1055
|
+
// src/admin/routes/b2b/approvals/components/table/query.tsx
|
|
1056
|
+
var useApprovalsTableQuery = ({ pageSize = 50, prefix }) => {
|
|
1057
|
+
const raw = useQueryParams([
|
|
1058
|
+
"q",
|
|
1059
|
+
"offset",
|
|
1060
|
+
"order",
|
|
1061
|
+
"created_at",
|
|
1062
|
+
"updated_at",
|
|
1063
|
+
"status"
|
|
1064
|
+
], prefix);
|
|
1065
|
+
const { offset, created_at, updated_at, ...rest } = raw;
|
|
1066
|
+
return {
|
|
1067
|
+
searchParams: {
|
|
1068
|
+
...rest,
|
|
1069
|
+
limit: pageSize,
|
|
1070
|
+
offset: offset ? Number(offset) : 0,
|
|
1071
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
1072
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0
|
|
1073
|
+
},
|
|
1074
|
+
raw
|
|
1075
|
+
};
|
|
1076
|
+
};
|
|
1077
|
+
// src/admin/routes/b2b/approvals/components/approvals-table.tsx
|
|
1078
|
+
var PAGE_SIZE$2 = 50;
|
|
1079
|
+
var ApprovalsTable = () => {
|
|
1080
|
+
const { t } = useTranslation();
|
|
1081
|
+
const { searchParams, raw } = useApprovalsTableQuery({ pageSize: PAGE_SIZE$2 });
|
|
1082
|
+
const { data, isPending } = useApprovals({
|
|
1083
|
+
...searchParams,
|
|
1084
|
+
order: "-updated_at"
|
|
1085
|
+
});
|
|
1086
|
+
const columns = useApprovalsTableColumns();
|
|
1087
|
+
const filters = useApprovalsTableFilters();
|
|
1088
|
+
const { table } = useDataTable$1({
|
|
1089
|
+
data: data?.carts_with_approvals,
|
|
1090
|
+
columns,
|
|
1091
|
+
enablePagination: true,
|
|
1092
|
+
count: data?.count,
|
|
1093
|
+
pageSize: PAGE_SIZE$2
|
|
1094
|
+
});
|
|
1095
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
1096
|
+
className: "divide-y p-0",
|
|
1097
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1098
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
1099
|
+
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Heading, { children: t("approvals.title") }), /* @__PURE__ */ jsx(Text, {
|
|
1100
|
+
className: "text-ui-fg-subtle",
|
|
1101
|
+
size: "small",
|
|
1102
|
+
children: t("overview.nav.approvals.description")
|
|
1103
|
+
})] })
|
|
1104
|
+
}), /* @__PURE__ */ jsx(DataTable$1, {
|
|
1105
|
+
columns,
|
|
1106
|
+
table,
|
|
1107
|
+
pagination: true,
|
|
1108
|
+
filters,
|
|
1109
|
+
count: data?.count,
|
|
1110
|
+
search: true,
|
|
1111
|
+
isLoading: isPending,
|
|
1112
|
+
pageSize: PAGE_SIZE$2,
|
|
1113
|
+
orderBy: ["id", "created_at"],
|
|
1114
|
+
queryObject: raw,
|
|
1115
|
+
noRecords: {
|
|
1116
|
+
title: t("approvals.table.noRecordsTitle"),
|
|
1117
|
+
message: t("approvals.table.noRecordsMessage")
|
|
1118
|
+
}
|
|
1119
|
+
})]
|
|
1120
|
+
});
|
|
1121
|
+
};
|
|
1122
|
+
// src/admin/routes/b2b/approvals/components/approvals-table-renderers.tsx
|
|
1123
|
+
defineCellRenderer("b2b-short-id", { render: (value) => typeof value === "string" ? `#${value.slice(-4)}` : "-" });
|
|
1124
|
+
defineCellRenderer("b2b-approval-status", { render: (value) => /* @__PURE__ */ jsx(ApprovalStatusBadge, { status: value }) });
|
|
1125
|
+
defineCellRenderer("b2b-items", { render: (value, row) => /* @__PURE__ */ jsx(ItemsPopover, {
|
|
1126
|
+
items: value,
|
|
1127
|
+
currencyCode: row.currency_code
|
|
1128
|
+
}) });
|
|
1129
|
+
defineCellRenderer("b2b-approval-type", { render: (value) => {
|
|
1130
|
+
const approvals = Array.isArray(value) ? value : [];
|
|
1131
|
+
if (!approvals.length) return "-";
|
|
1132
|
+
const t = getI18n().t;
|
|
1133
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1134
|
+
className: "flex flex-wrap gap-1",
|
|
1135
|
+
children: approvals.map((a) => /* @__PURE__ */ jsx(Badge, {
|
|
1136
|
+
size: "2xsmall",
|
|
1137
|
+
rounded: "full",
|
|
1138
|
+
color: a.type === "admin" ? "blue" : "purple",
|
|
1139
|
+
children: a.type === "admin" ? t("approvals.types.admin") : t("approvals.types.salesManager")
|
|
1140
|
+
}, a.id))
|
|
1141
|
+
});
|
|
1142
|
+
} });
|
|
1143
|
+
defineCellRenderer("b2b-approval-handled-by", { render: (value) => {
|
|
1144
|
+
const names = (Array.isArray(value) ? value : []).filter((a) => a.handled_by).map((a) => a.handled_by);
|
|
1145
|
+
return names.length ? names.join(", ") : "-";
|
|
1146
|
+
} });
|
|
1147
|
+
defineCellRenderer("b2b-approval-handled-at", { render: (value) => {
|
|
1148
|
+
const dates = (Array.isArray(value) ? value : []).filter((a) => a.handled_at).map((a) => a.handled_at).toSorted().toReversed();
|
|
1149
|
+
if (!dates.length) return "-";
|
|
1150
|
+
return new Date(dates[0]).toLocaleDateString();
|
|
1151
|
+
} });
|
|
1152
|
+
defineCellRenderer("b2b-approval-reason", { render: (value) => {
|
|
1153
|
+
return (Array.isArray(value) ? value : []).find((a) => a.reason)?.reason ?? "-";
|
|
1154
|
+
} });
|
|
1155
|
+
// src/admin/routes/b2b/approvals/components/approvals-table-adapter.tsx
|
|
1156
|
+
function useApprovalsTableAdapter() {
|
|
1157
|
+
const { t } = useTranslation();
|
|
1158
|
+
return useMemo(() => createTableAdapter({
|
|
1159
|
+
entity: "b2b-approvals",
|
|
1160
|
+
queryPrefix: "apv",
|
|
1161
|
+
pageSize: 50,
|
|
1162
|
+
useData: (_fields, params) => {
|
|
1163
|
+
const { data, isPending, isError, error } = useApprovals({
|
|
1164
|
+
...params,
|
|
1165
|
+
order: "-updated_at"
|
|
1166
|
+
});
|
|
1167
|
+
return {
|
|
1168
|
+
data: data?.carts_with_approvals,
|
|
1169
|
+
count: data?.count,
|
|
1170
|
+
isLoading: isPending,
|
|
1171
|
+
isError,
|
|
1172
|
+
error
|
|
1173
|
+
};
|
|
1174
|
+
},
|
|
1175
|
+
renderRowActions: (row) => /* @__PURE__ */ jsx(ApprovalActions, { cart: row }),
|
|
1176
|
+
emptyState: {
|
|
1177
|
+
empty: {
|
|
1178
|
+
heading: t("approvals.table.noRecordsTitle"),
|
|
1179
|
+
description: t("approvals.table.noRecordsMessage")
|
|
1180
|
+
},
|
|
1181
|
+
filtered: {
|
|
1182
|
+
heading: t("approvals.table.noRecordsTitle"),
|
|
1183
|
+
description: t("approvals.table.noRecordsMessage")
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}), [t]);
|
|
1187
|
+
}
|
|
1188
|
+
// src/admin/routes/b2b/approvals/page.tsx
|
|
1189
|
+
var Approvals = () => {
|
|
1190
|
+
const { t } = useTranslation();
|
|
1191
|
+
const isViewConfigEnabled = useFeatureFlag("view_configurations");
|
|
1192
|
+
const adapter = useApprovalsTableAdapter();
|
|
1193
|
+
return /* @__PURE__ */ jsx(LayoutComposer, {
|
|
1194
|
+
widgetsZonePrefix: "approvals_list.list",
|
|
1195
|
+
preferredLayoutId: CORE_LAYOUT_IDS.SINGLE_COLUMN,
|
|
1196
|
+
sections: { main: /* @__PURE__ */ jsxs(LayoutComposer.Entry, {
|
|
1197
|
+
id: "ApprovalsListTable",
|
|
1198
|
+
children: [isViewConfigEnabled ? /* @__PURE__ */ jsx(ConfigurableDataTable, {
|
|
1199
|
+
adapter,
|
|
1200
|
+
heading: t("approvals.title"),
|
|
1201
|
+
subHeading: t("overview.nav.approvals.description")
|
|
1202
|
+
}) : /* @__PURE__ */ jsx(ApprovalsTable, {}), /* @__PURE__ */ jsx(Toaster, {})]
|
|
1203
|
+
}) }
|
|
1204
|
+
});
|
|
1205
|
+
};
|
|
1206
|
+
var Breadcrumb$4 = () => {
|
|
1207
|
+
const { t } = useTranslation();
|
|
1208
|
+
return t("approvals.title");
|
|
1209
|
+
};
|
|
1210
|
+
var config$2 = defineRouteConfig({
|
|
1211
|
+
label: "Approvals",
|
|
1212
|
+
icon: CheckCircle
|
|
1213
|
+
});
|
|
1214
|
+
var handle$4 = { breadcrumb: () => /* @__PURE__ */ jsx(Breadcrumb$4, {}) };
|
|
1215
|
+
var GuardedApprovals = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
1216
|
+
permission: "b2b.read",
|
|
1217
|
+
children: /* @__PURE__ */ jsx(Approvals, {})
|
|
1218
|
+
});
|
|
1219
|
+
// src/admin/routes/b2b/companies/components/table/columns.tsx
|
|
1220
|
+
var columnHelper$3 = legacyCreateColumnHelper();
|
|
1221
|
+
var useCompaniesTableColumns = () => {
|
|
1222
|
+
const { t } = useTranslation();
|
|
1223
|
+
return useMemo(() => [
|
|
1224
|
+
columnHelper$3.accessor("logo_url", {
|
|
1225
|
+
header: "",
|
|
1226
|
+
cell: ({ getValue }) => {
|
|
1227
|
+
const url = getValue();
|
|
1228
|
+
if (!url) return null;
|
|
1229
|
+
return /* @__PURE__ */ jsx("img", {
|
|
1230
|
+
src: url,
|
|
1231
|
+
alt: "",
|
|
1232
|
+
className: "h-6 w-auto max-w-[48px] object-contain"
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
}),
|
|
1236
|
+
columnHelper$3.accessor("name", {
|
|
1237
|
+
header: t("fields.name"),
|
|
1238
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
1239
|
+
className: "txt-compact-small font-medium",
|
|
1240
|
+
children: getValue()
|
|
1241
|
+
})
|
|
1242
|
+
}),
|
|
1243
|
+
columnHelper$3.accessor("email", {
|
|
1244
|
+
header: t("fields.email"),
|
|
1245
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
1246
|
+
className: "txt-compact-small",
|
|
1247
|
+
children: getValue() || "—"
|
|
1248
|
+
})
|
|
1249
|
+
}),
|
|
1250
|
+
columnHelper$3.accessor("phone", {
|
|
1251
|
+
header: t("fields.phone"),
|
|
1252
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
1253
|
+
className: "txt-compact-small",
|
|
1254
|
+
children: getValue() || "—"
|
|
1255
|
+
})
|
|
1256
|
+
}),
|
|
1257
|
+
columnHelper$3.accessor("country", {
|
|
1258
|
+
header: t("fields.country"),
|
|
1259
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
1260
|
+
className: "txt-compact-small",
|
|
1261
|
+
children: getValue() || "—"
|
|
1262
|
+
})
|
|
1263
|
+
}),
|
|
1264
|
+
columnHelper$3.accessor("currency_code", {
|
|
1265
|
+
header: t("fields.currency"),
|
|
1266
|
+
cell: ({ getValue }) => {
|
|
1267
|
+
const code = getValue();
|
|
1268
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1269
|
+
className: "txt-compact-small",
|
|
1270
|
+
children: code ? code.toUpperCase() : "—"
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
}),
|
|
1274
|
+
columnHelper$3.accessor("employees_count", {
|
|
1275
|
+
header: t("companies.table.employees"),
|
|
1276
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
1277
|
+
className: "txt-compact-small",
|
|
1278
|
+
children: getValue() ?? 0
|
|
1279
|
+
})
|
|
1280
|
+
}),
|
|
1281
|
+
columnHelper$3.accessor("created_at", {
|
|
1282
|
+
header: t("fields.createdAt"),
|
|
1283
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(DateCell, { date: getValue() })
|
|
1284
|
+
})
|
|
1285
|
+
], [t]);
|
|
1286
|
+
};
|
|
1287
|
+
// src/admin/routes/b2b/companies/components/table/filters.tsx
|
|
1288
|
+
var useCompaniesTableFilters = () => {
|
|
1289
|
+
const { t } = useTranslation();
|
|
1290
|
+
return [
|
|
1291
|
+
{
|
|
1292
|
+
label: t("fields.country"),
|
|
1293
|
+
key: "country",
|
|
1294
|
+
type: "string"
|
|
1295
|
+
},
|
|
877
1296
|
{
|
|
878
1297
|
label: t("fields.state"),
|
|
879
1298
|
key: "state",
|
|
@@ -908,12 +1327,12 @@ var useCompaniesTableQuery = ({ pageSize = 50, prefix }) => {
|
|
|
908
1327
|
};
|
|
909
1328
|
};
|
|
910
1329
|
// src/admin/routes/b2b/companies/components/companies-table.tsx
|
|
911
|
-
var PAGE_SIZE$
|
|
1330
|
+
var PAGE_SIZE$1 = 50;
|
|
912
1331
|
var PREFIX$1 = "comp";
|
|
913
1332
|
var CompaniesTable = ({ onCreateClick }) => {
|
|
914
1333
|
const { t } = useTranslation();
|
|
915
1334
|
const { searchParams, raw } = useCompaniesTableQuery({
|
|
916
|
-
pageSize: PAGE_SIZE$
|
|
1335
|
+
pageSize: PAGE_SIZE$1,
|
|
917
1336
|
prefix: PREFIX$1
|
|
918
1337
|
});
|
|
919
1338
|
const { data, isPending } = useCompanies({
|
|
@@ -929,7 +1348,7 @@ var CompaniesTable = ({ onCreateClick }) => {
|
|
|
929
1348
|
columns,
|
|
930
1349
|
count,
|
|
931
1350
|
enablePagination: true,
|
|
932
|
-
pageSize: PAGE_SIZE$
|
|
1351
|
+
pageSize: PAGE_SIZE$1,
|
|
933
1352
|
prefix: PREFIX$1,
|
|
934
1353
|
getRowId: (row) => row.id
|
|
935
1354
|
});
|
|
@@ -956,7 +1375,7 @@ var CompaniesTable = ({ onCreateClick }) => {
|
|
|
956
1375
|
count,
|
|
957
1376
|
search: true,
|
|
958
1377
|
isLoading: isPending,
|
|
959
|
-
pageSize: PAGE_SIZE$
|
|
1378
|
+
pageSize: PAGE_SIZE$1,
|
|
960
1379
|
orderBy: ["name", "created_at"],
|
|
961
1380
|
prefix: PREFIX$1,
|
|
962
1381
|
queryObject: raw,
|
|
@@ -1721,16 +2140,16 @@ var Companies = () => {
|
|
|
1721
2140
|
}) }
|
|
1722
2141
|
});
|
|
1723
2142
|
};
|
|
1724
|
-
var Breadcrumb$
|
|
2143
|
+
var Breadcrumb$3 = () => {
|
|
1725
2144
|
const { t } = useTranslation();
|
|
1726
2145
|
return t("companies.title");
|
|
1727
2146
|
};
|
|
1728
|
-
var config$
|
|
2147
|
+
var config$1 = defineRouteConfig({
|
|
1729
2148
|
label: "companies.title",
|
|
1730
2149
|
translationNs: "b2b",
|
|
1731
2150
|
icon: Buildings
|
|
1732
2151
|
});
|
|
1733
|
-
var handle$
|
|
2152
|
+
var handle$3 = { breadcrumb: () => /* @__PURE__ */ jsx(Breadcrumb$3, {}) };
|
|
1734
2153
|
var GuardedCompanies = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
1735
2154
|
permission: "b2b.read",
|
|
1736
2155
|
children: /* @__PURE__ */ jsx(Companies, {})
|
|
@@ -1774,263 +2193,132 @@ var GuardedCompanyCreate = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
|
1774
2193
|
permission: "b2b.write",
|
|
1775
2194
|
children: /* @__PURE__ */ jsx(CompanyCreate, {})
|
|
1776
2195
|
});
|
|
1777
|
-
// src/admin/routes/b2b/
|
|
1778
|
-
var
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
const approveCart = async () => {
|
|
1786
|
-
if (!await dialog({
|
|
1787
|
-
title: t("approvals.prompts.approve.title"),
|
|
1788
|
-
description: t("approvals.prompts.approve.description")
|
|
1789
|
-
})) return;
|
|
1790
|
-
try {
|
|
1791
|
-
await updateApproval({ status: ApprovalStatusType.APPROVED });
|
|
1792
|
-
toast.success(t("approvals.toasts.approved"));
|
|
1793
|
-
} catch {
|
|
1794
|
-
toast.error(t("approvals.toasts.approveError"));
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
const openRejectDialog = () => {
|
|
1798
|
-
setReason("");
|
|
1799
|
-
setRejectOpen(true);
|
|
1800
|
-
};
|
|
1801
|
-
const confirmReject = async () => {
|
|
1802
|
-
try {
|
|
1803
|
-
await updateApproval({
|
|
1804
|
-
status: ApprovalStatusType.REJECTED,
|
|
1805
|
-
reason: reason.trim() || null
|
|
1806
|
-
});
|
|
1807
|
-
toast.success(t("approvals.toasts.rejected"));
|
|
1808
|
-
setRejectOpen(false);
|
|
1809
|
-
} catch {
|
|
1810
|
-
toast.error(t("approvals.toasts.rejectError"));
|
|
1811
|
-
}
|
|
1812
|
-
};
|
|
1813
|
-
if (!pendingApproval || cart.approval_status?.status !== ApprovalStatusType.PENDING) return null;
|
|
1814
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ActionMenu, { groups: [{ actions: [{
|
|
1815
|
-
label: t("actions.reject"),
|
|
1816
|
-
onClick: openRejectDialog,
|
|
1817
|
-
icon: /* @__PURE__ */ jsx(XMark, {})
|
|
1818
|
-
}] }, { actions: [{
|
|
1819
|
-
label: t("actions.approve"),
|
|
1820
|
-
onClick: approveCart,
|
|
1821
|
-
icon: /* @__PURE__ */ jsx(Check, {})
|
|
1822
|
-
}] }] }), /* @__PURE__ */ jsx(Drawer, {
|
|
1823
|
-
open: rejectOpen,
|
|
1824
|
-
onOpenChange: setRejectOpen,
|
|
1825
|
-
children: /* @__PURE__ */ jsxs(Drawer.Content, { children: [
|
|
1826
|
-
/* @__PURE__ */ jsxs(Drawer.Header, { children: [/* @__PURE__ */ jsx(Drawer.Title, { children: t("approvals.prompts.reject.title") }), /* @__PURE__ */ jsx(Drawer.Description, { children: t("approvals.prompts.reject.description") })] }),
|
|
1827
|
-
/* @__PURE__ */ jsxs(Drawer.Body, {
|
|
1828
|
-
className: "flex flex-col gap-y-3",
|
|
1829
|
-
children: [/* @__PURE__ */ jsx(Label, {
|
|
1830
|
-
htmlFor: "reject-reason",
|
|
1831
|
-
children: t("approvals.table.reason")
|
|
1832
|
-
}), /* @__PURE__ */ jsx(Textarea, {
|
|
1833
|
-
id: "reject-reason",
|
|
1834
|
-
value: reason,
|
|
1835
|
-
onChange: (e) => setReason(e.target.value),
|
|
1836
|
-
placeholder: t("approvals.prompts.reject.reasonPlaceholder")
|
|
1837
|
-
})]
|
|
1838
|
-
}),
|
|
1839
|
-
/* @__PURE__ */ jsxs(Drawer.Footer, { children: [/* @__PURE__ */ jsx(Drawer.Close, {
|
|
1840
|
-
asChild: true,
|
|
1841
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
1842
|
-
variant: "secondary",
|
|
1843
|
-
size: "small",
|
|
1844
|
-
children: t("actions.cancel")
|
|
1845
|
-
})
|
|
1846
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
1847
|
-
variant: "danger",
|
|
1848
|
-
size: "small",
|
|
1849
|
-
onClick: confirmReject,
|
|
1850
|
-
children: t("actions.reject")
|
|
1851
|
-
})] })
|
|
1852
|
-
] })
|
|
1853
|
-
})] });
|
|
1854
|
-
};
|
|
1855
|
-
// src/admin/routes/b2b/approvals/components/approvals-items-popover.tsx
|
|
1856
|
-
var ItemsPopover = ({ items, currencyCode }) => {
|
|
1857
|
-
const { t } = useTranslation();
|
|
1858
|
-
return /* @__PURE__ */ jsxs(Popover, { children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
1859
|
-
className: "flex text-right items-center gap-1 hover:cursor-pointer",
|
|
1860
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
1861
|
-
className: "underline underline-offset-4 min-w-14 ",
|
|
1862
|
-
children: [
|
|
1863
|
-
items?.length,
|
|
1864
|
-
" item",
|
|
1865
|
-
items?.length !== 1 ? "s" : ""
|
|
1866
|
-
]
|
|
1867
|
-
}), /* @__PURE__ */ jsx(MagnifyingGlass, {})]
|
|
1868
|
-
}), /* @__PURE__ */ jsx(Popover.Content, {
|
|
1869
|
-
className: "p-0 mr-10",
|
|
1870
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
1871
|
-
className: "max-h-1/3 overflow-y-auto",
|
|
1872
|
-
children: /* @__PURE__ */ jsx(Table, { children: /* @__PURE__ */ jsx(Table.Body, { children: items?.map((item) => /* @__PURE__ */ jsxs(Table.Row, {
|
|
1873
|
-
className: "py-2 hover:bg-transparent",
|
|
1874
|
-
children: [/* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx("div", {
|
|
1875
|
-
className: "w-10 h-10 overflow-hidden flex items-center justify-center",
|
|
1876
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
1877
|
-
src: item.thumbnail,
|
|
1878
|
-
alt: item.product_title,
|
|
1879
|
-
className: "h-10 object-contain mr-4"
|
|
1880
|
-
})
|
|
1881
|
-
}) }), /* @__PURE__ */ jsxs(Table.Cell, {
|
|
1882
|
-
className: "py-2",
|
|
1883
|
-
children: [
|
|
1884
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1885
|
-
className: "font-medium truncate max-w-60",
|
|
1886
|
-
children: item.product_title
|
|
1887
|
-
}),
|
|
1888
|
-
/* @__PURE__ */ jsx(Text, {
|
|
1889
|
-
className: "text-sm text-gray-500",
|
|
1890
|
-
children: item.variant_title
|
|
1891
|
-
}),
|
|
1892
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1893
|
-
className: "text-sm text-gray-500",
|
|
1894
|
-
children: [
|
|
1895
|
-
item.quantity,
|
|
1896
|
-
" x",
|
|
1897
|
-
" ",
|
|
1898
|
-
formatCurrency(item.unit_price, currencyCode),
|
|
1899
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
1900
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
1901
|
-
className: "font-medium",
|
|
1902
|
-
children: [
|
|
1903
|
-
t("approvals.items.itemTotal"),
|
|
1904
|
-
" ",
|
|
1905
|
-
formatCurrency(item.quantity * item.unit_price, currencyCode)
|
|
1906
|
-
]
|
|
1907
|
-
})
|
|
1908
|
-
]
|
|
1909
|
-
})
|
|
1910
|
-
]
|
|
1911
|
-
})]
|
|
1912
|
-
}, item.id)) }) })
|
|
1913
|
-
})
|
|
1914
|
-
})] });
|
|
1915
|
-
};
|
|
1916
|
-
// src/admin/routes/b2b/approvals/components/approval-status-badge.tsx
|
|
1917
|
-
var StatusColors = {
|
|
1918
|
-
approved: "green",
|
|
1919
|
-
pending: "purple",
|
|
1920
|
-
rejected: "red"
|
|
2196
|
+
// src/admin/routes/b2b/quotes/components/quote-status-badge.tsx
|
|
2197
|
+
var statusColors = {
|
|
2198
|
+
pending_merchant: "purple",
|
|
2199
|
+
pending_customer: "purple",
|
|
2200
|
+
accepted: "green",
|
|
2201
|
+
customer_rejected: "red",
|
|
2202
|
+
merchant_rejected: "red",
|
|
2203
|
+
expired: "grey"
|
|
1921
2204
|
};
|
|
1922
|
-
function
|
|
2205
|
+
function QuoteStatusBadge({ status }) {
|
|
1923
2206
|
const { t } = useTranslation();
|
|
1924
|
-
const
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2207
|
+
const labels = {
|
|
2208
|
+
pending_merchant: t("quotes.status.pending_merchant"),
|
|
2209
|
+
pending_customer: t("quotes.status.pending_customer"),
|
|
2210
|
+
accepted: t("quotes.status.accepted"),
|
|
2211
|
+
customer_rejected: t("quotes.status.customer_rejected"),
|
|
2212
|
+
merchant_rejected: t("quotes.status.merchant_rejected"),
|
|
2213
|
+
expired: t("quotes.status.expired")
|
|
1928
2214
|
};
|
|
1929
2215
|
return /* @__PURE__ */ jsx(DataTableStatusCell, {
|
|
1930
|
-
color:
|
|
1931
|
-
children:
|
|
2216
|
+
color: statusColors[status] ?? "grey",
|
|
2217
|
+
children: labels[status] ?? status
|
|
1932
2218
|
});
|
|
1933
2219
|
}
|
|
1934
|
-
// src/admin/routes/b2b/
|
|
1935
|
-
var columnHelper$
|
|
1936
|
-
var
|
|
2220
|
+
// src/admin/routes/b2b/quotes/components/table/columns.tsx
|
|
2221
|
+
var columnHelper$2 = legacyCreateColumnHelper();
|
|
2222
|
+
var useQuotesTableColumns = () => {
|
|
1937
2223
|
const { t } = useTranslation();
|
|
1938
2224
|
return useMemo(() => [
|
|
1939
|
-
columnHelper$
|
|
1940
|
-
header: t("fields.
|
|
1941
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(
|
|
1942
|
-
}),
|
|
1943
|
-
columnHelper$3.accessor("updated_at", {
|
|
1944
|
-
header: t("approvals.table.updatedAt"),
|
|
1945
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(DateCell, { date: getValue() })
|
|
1946
|
-
}),
|
|
1947
|
-
columnHelper$3.accessor("company.name", {
|
|
1948
|
-
header: () => /* @__PURE__ */ jsx(TextHeader, { text: t("fields.company") }),
|
|
1949
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { text: getValue() })
|
|
2225
|
+
columnHelper$2.accessor("status", {
|
|
2226
|
+
header: t("fields.status"),
|
|
2227
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(QuoteStatusBadge, { status: getValue() })
|
|
1950
2228
|
}),
|
|
1951
|
-
columnHelper$
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
}, a.id))
|
|
2229
|
+
columnHelper$2.accessor("customer", {
|
|
2230
|
+
header: t("quotes.table.customer"),
|
|
2231
|
+
cell: ({ row }) => {
|
|
2232
|
+
const customer = row.original.customer;
|
|
2233
|
+
if (!customer) return /* @__PURE__ */ jsx("span", {
|
|
2234
|
+
className: "txt-compact-small text-ui-fg-subtle",
|
|
2235
|
+
children: "—"
|
|
2236
|
+
});
|
|
2237
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ") || customer.email || customer.id;
|
|
2238
|
+
return /* @__PURE__ */ jsx(Link$1, {
|
|
2239
|
+
to: `/customers/${customer.id}`,
|
|
2240
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2241
|
+
children: name
|
|
1965
2242
|
});
|
|
1966
2243
|
}
|
|
1967
2244
|
}),
|
|
1968
|
-
columnHelper$
|
|
1969
|
-
header: t("
|
|
1970
|
-
cell: ({
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
header: t("approvals.table.handledBy"),
|
|
1982
|
-
cell: ({ getValue }) => {
|
|
1983
|
-
const names = (getValue() ?? []).filter((a) => a.handled_by).map((a) => a.handled_by);
|
|
1984
|
-
return /* @__PURE__ */ jsx(TextCell, { text: names.length ? names.join(", ") : "—" });
|
|
2245
|
+
columnHelper$2.accessor("draft_order", {
|
|
2246
|
+
header: t("quotes.table.draftOrder"),
|
|
2247
|
+
cell: ({ row }) => {
|
|
2248
|
+
const draftOrder = row.original.draft_order;
|
|
2249
|
+
if (!draftOrder) return /* @__PURE__ */ jsx("span", {
|
|
2250
|
+
className: "txt-compact-small text-ui-fg-subtle",
|
|
2251
|
+
children: "—"
|
|
2252
|
+
});
|
|
2253
|
+
return /* @__PURE__ */ jsxs(Link$1, {
|
|
2254
|
+
to: `/orders/${draftOrder.id}`,
|
|
2255
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2256
|
+
children: ["#", draftOrder.display_id]
|
|
2257
|
+
});
|
|
1985
2258
|
}
|
|
1986
2259
|
}),
|
|
1987
|
-
columnHelper$
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
}
|
|
2260
|
+
columnHelper$2.accessor("messages_count", {
|
|
2261
|
+
header: t("quotes.table.messages"),
|
|
2262
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
2263
|
+
className: "txt-compact-small",
|
|
2264
|
+
children: getValue() ?? 0
|
|
2265
|
+
})
|
|
1994
2266
|
}),
|
|
1995
|
-
columnHelper$
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
cell: ({ getValue }) => {
|
|
1999
|
-
const reason = (getValue() ?? []).find((a) => a.reason)?.reason;
|
|
2000
|
-
return /* @__PURE__ */ jsx(TextCell, { text: reason ?? "—" });
|
|
2001
|
-
}
|
|
2002
|
-
}),
|
|
2003
|
-
columnHelper$3.accessor("actions", {
|
|
2004
|
-
header: t("approvals.table.actions"),
|
|
2005
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(ApprovalActions, { cart: row.original })
|
|
2267
|
+
columnHelper$2.accessor("created_at", {
|
|
2268
|
+
header: t("fields.createdAt"),
|
|
2269
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(DateCell, { date: getValue() })
|
|
2006
2270
|
})
|
|
2007
2271
|
], [t]);
|
|
2008
2272
|
};
|
|
2009
|
-
// src/admin/routes/b2b/
|
|
2010
|
-
var
|
|
2273
|
+
// src/admin/routes/b2b/quotes/components/table/filters.tsx
|
|
2274
|
+
var useQuotesTableFilters = () => {
|
|
2011
2275
|
const { t } = useTranslation();
|
|
2012
|
-
return [
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2276
|
+
return [
|
|
2277
|
+
{
|
|
2278
|
+
label: t("fields.status"),
|
|
2279
|
+
key: "status",
|
|
2280
|
+
type: "select",
|
|
2281
|
+
options: [
|
|
2282
|
+
{
|
|
2283
|
+
label: t("quotes.status.pending_merchant"),
|
|
2284
|
+
value: EQuoteStatus.PendingMerchant
|
|
2285
|
+
},
|
|
2286
|
+
{
|
|
2287
|
+
label: t("quotes.status.pending_customer"),
|
|
2288
|
+
value: EQuoteStatus.PendingCustomer
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
label: t("quotes.status.accepted"),
|
|
2292
|
+
value: EQuoteStatus.Accepted
|
|
2293
|
+
},
|
|
2294
|
+
{
|
|
2295
|
+
label: t("quotes.status.customer_rejected"),
|
|
2296
|
+
value: EQuoteStatus.CustomerRejected
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
label: t("quotes.status.merchant_rejected"),
|
|
2300
|
+
value: EQuoteStatus.MerchantRejected
|
|
2301
|
+
},
|
|
2302
|
+
{
|
|
2303
|
+
label: t("quotes.status.expired"),
|
|
2304
|
+
value: EQuoteStatus.Expired
|
|
2305
|
+
}
|
|
2306
|
+
]
|
|
2307
|
+
},
|
|
2308
|
+
{
|
|
2309
|
+
label: t("quotes.filters.customerId"),
|
|
2310
|
+
key: "customer_id",
|
|
2311
|
+
type: "string"
|
|
2312
|
+
},
|
|
2313
|
+
{
|
|
2314
|
+
label: t("quotes.filters.draftOrderId"),
|
|
2315
|
+
key: "draft_order_id",
|
|
2316
|
+
type: "string"
|
|
2317
|
+
}
|
|
2318
|
+
];
|
|
2031
2319
|
};
|
|
2032
|
-
// src/admin/routes/b2b/
|
|
2033
|
-
var
|
|
2320
|
+
// src/admin/routes/b2b/quotes/components/table/query.tsx
|
|
2321
|
+
var useQuotesTableQuery = ({ pageSize = 50, prefix }) => {
|
|
2034
2322
|
const raw = useQueryParams([
|
|
2035
2323
|
"q",
|
|
2036
2324
|
"offset",
|
|
@@ -2051,599 +2339,769 @@ var useApprovalsTableQuery = ({ pageSize = 50, prefix }) => {
|
|
|
2051
2339
|
raw
|
|
2052
2340
|
};
|
|
2053
2341
|
};
|
|
2054
|
-
// src/admin/routes/b2b/
|
|
2055
|
-
var PAGE_SIZE
|
|
2056
|
-
var
|
|
2342
|
+
// src/admin/routes/b2b/quotes/components/quotes-table.tsx
|
|
2343
|
+
var PAGE_SIZE = 50;
|
|
2344
|
+
var PREFIX = "quot";
|
|
2345
|
+
var QuotesTable = () => {
|
|
2057
2346
|
const { t } = useTranslation();
|
|
2058
|
-
const { searchParams, raw } =
|
|
2059
|
-
|
|
2347
|
+
const { searchParams, raw } = useQuotesTableQuery({
|
|
2348
|
+
pageSize: PAGE_SIZE,
|
|
2349
|
+
prefix: PREFIX
|
|
2350
|
+
});
|
|
2351
|
+
const result = useQuotes({
|
|
2060
2352
|
...searchParams,
|
|
2061
|
-
order: "-
|
|
2353
|
+
order: "-created_at"
|
|
2062
2354
|
});
|
|
2063
|
-
const
|
|
2064
|
-
const
|
|
2355
|
+
const quotes = result.quotes ?? [];
|
|
2356
|
+
const count = result.count;
|
|
2357
|
+
const columns = useQuotesTableColumns();
|
|
2358
|
+
const filters = useQuotesTableFilters();
|
|
2065
2359
|
const { table } = useDataTable$1({
|
|
2066
|
-
data:
|
|
2360
|
+
data: quotes,
|
|
2067
2361
|
columns,
|
|
2362
|
+
count,
|
|
2068
2363
|
enablePagination: true,
|
|
2069
|
-
|
|
2070
|
-
|
|
2364
|
+
pageSize: PAGE_SIZE,
|
|
2365
|
+
prefix: PREFIX,
|
|
2366
|
+
getRowId: (row) => row.id
|
|
2071
2367
|
});
|
|
2072
2368
|
return /* @__PURE__ */ jsxs(Container, {
|
|
2073
2369
|
className: "divide-y p-0",
|
|
2074
2370
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2075
2371
|
className: "flex items-center justify-between px-6 py-4",
|
|
2076
|
-
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Heading, { children: t("
|
|
2372
|
+
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Heading, { children: t("quotes.title") }), /* @__PURE__ */ jsx(Text, {
|
|
2077
2373
|
className: "text-ui-fg-subtle",
|
|
2078
2374
|
size: "small",
|
|
2079
|
-
children: t("overview.nav.
|
|
2375
|
+
children: t("overview.nav.quotes.description")
|
|
2080
2376
|
})] })
|
|
2081
2377
|
}), /* @__PURE__ */ jsx(DataTable$1, {
|
|
2082
2378
|
columns,
|
|
2083
2379
|
table,
|
|
2380
|
+
navigateTo: (row) => `/b2b/quotes/${row.original.id}`,
|
|
2084
2381
|
pagination: true,
|
|
2085
2382
|
filters,
|
|
2086
|
-
count
|
|
2383
|
+
count,
|
|
2087
2384
|
search: true,
|
|
2088
|
-
isLoading: isPending,
|
|
2089
|
-
pageSize: PAGE_SIZE
|
|
2090
|
-
orderBy: ["
|
|
2385
|
+
isLoading: result.isPending,
|
|
2386
|
+
pageSize: PAGE_SIZE,
|
|
2387
|
+
orderBy: ["created_at"],
|
|
2388
|
+
prefix: PREFIX,
|
|
2091
2389
|
queryObject: raw,
|
|
2092
2390
|
noRecords: {
|
|
2093
|
-
title: t("
|
|
2094
|
-
message: t("
|
|
2391
|
+
title: t("quotes.table.noRecordsTitle"),
|
|
2392
|
+
message: t("quotes.table.noRecordsMessage")
|
|
2095
2393
|
}
|
|
2096
2394
|
})]
|
|
2097
2395
|
});
|
|
2098
2396
|
};
|
|
2099
|
-
// src/admin/routes/b2b/
|
|
2100
|
-
|
|
2101
|
-
defineCellRenderer("b2b-approval-status", { render: (value) => /* @__PURE__ */ jsx(ApprovalStatusBadge, { status: value }) });
|
|
2102
|
-
defineCellRenderer("b2b-items", { render: (value, row) => /* @__PURE__ */ jsx(ItemsPopover, {
|
|
2103
|
-
items: value,
|
|
2104
|
-
currencyCode: row.currency_code
|
|
2105
|
-
}) });
|
|
2106
|
-
defineCellRenderer("b2b-approval-type", { render: (value) => {
|
|
2107
|
-
const approvals = Array.isArray(value) ? value : [];
|
|
2108
|
-
if (!approvals.length) return "-";
|
|
2109
|
-
const t = getI18n().t;
|
|
2110
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2111
|
-
className: "flex flex-wrap gap-1",
|
|
2112
|
-
children: approvals.map((a) => /* @__PURE__ */ jsx(Badge, {
|
|
2113
|
-
size: "2xsmall",
|
|
2114
|
-
rounded: "full",
|
|
2115
|
-
color: a.type === "admin" ? "blue" : "purple",
|
|
2116
|
-
children: a.type === "admin" ? t("approvals.types.admin") : t("approvals.types.salesManager")
|
|
2117
|
-
}, a.id))
|
|
2118
|
-
});
|
|
2119
|
-
} });
|
|
2120
|
-
defineCellRenderer("b2b-approval-handled-by", { render: (value) => {
|
|
2121
|
-
const names = (Array.isArray(value) ? value : []).filter((a) => a.handled_by).map((a) => a.handled_by);
|
|
2122
|
-
return names.length ? names.join(", ") : "-";
|
|
2123
|
-
} });
|
|
2124
|
-
defineCellRenderer("b2b-approval-handled-at", { render: (value) => {
|
|
2125
|
-
const dates = (Array.isArray(value) ? value : []).filter((a) => a.handled_at).map((a) => a.handled_at).toSorted().toReversed();
|
|
2126
|
-
if (!dates.length) return "-";
|
|
2127
|
-
return new Date(dates[0]).toLocaleDateString();
|
|
2128
|
-
} });
|
|
2129
|
-
defineCellRenderer("b2b-approval-reason", { render: (value) => {
|
|
2130
|
-
return (Array.isArray(value) ? value : []).find((a) => a.reason)?.reason ?? "-";
|
|
2131
|
-
} });
|
|
2132
|
-
// src/admin/routes/b2b/approvals/components/approvals-table-adapter.tsx
|
|
2133
|
-
function useApprovalsTableAdapter() {
|
|
2397
|
+
// src/admin/routes/b2b/quotes/components/send-quote-drawer.tsx
|
|
2398
|
+
function SendQuoteDrawer({ open, onClose, onConfirm, isPending }) {
|
|
2134
2399
|
const { t } = useTranslation();
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
});
|
|
2144
|
-
return {
|
|
2145
|
-
data: data?.carts_with_approvals,
|
|
2146
|
-
count: data?.count,
|
|
2147
|
-
isLoading: isPending,
|
|
2148
|
-
isError,
|
|
2149
|
-
error
|
|
2150
|
-
};
|
|
2151
|
-
},
|
|
2152
|
-
renderRowActions: (row) => /* @__PURE__ */ jsx(ApprovalActions, { cart: row }),
|
|
2153
|
-
emptyState: {
|
|
2154
|
-
empty: {
|
|
2155
|
-
heading: t("approvals.table.noRecordsTitle"),
|
|
2156
|
-
description: t("approvals.table.noRecordsMessage")
|
|
2157
|
-
},
|
|
2158
|
-
filtered: {
|
|
2159
|
-
heading: t("approvals.table.noRecordsTitle"),
|
|
2160
|
-
description: t("approvals.table.noRecordsMessage")
|
|
2161
|
-
}
|
|
2400
|
+
const [expiresAt, setExpiresAt] = useState("");
|
|
2401
|
+
const handleConfirm = () => {
|
|
2402
|
+
onConfirm(expiresAt || null);
|
|
2403
|
+
};
|
|
2404
|
+
const handleOpenChange = (isOpen) => {
|
|
2405
|
+
if (!isOpen) {
|
|
2406
|
+
setExpiresAt("");
|
|
2407
|
+
onClose();
|
|
2162
2408
|
}
|
|
2163
|
-
}
|
|
2409
|
+
};
|
|
2410
|
+
return /* @__PURE__ */ jsx(Drawer, {
|
|
2411
|
+
open,
|
|
2412
|
+
onOpenChange: handleOpenChange,
|
|
2413
|
+
children: /* @__PURE__ */ jsxs(Drawer.Content, { children: [
|
|
2414
|
+
/* @__PURE__ */ jsx(Drawer.Header, { children: /* @__PURE__ */ jsx(Drawer.Title, { children: t("quotes.detail.sendQuote") }) }),
|
|
2415
|
+
/* @__PURE__ */ jsxs(Drawer.Body, {
|
|
2416
|
+
className: "flex flex-col gap-y-4 p-6",
|
|
2417
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
2418
|
+
className: "text-ui-fg-subtle",
|
|
2419
|
+
children: t("quotes.prompts.send.description")
|
|
2420
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2421
|
+
className: "flex flex-col gap-y-2",
|
|
2422
|
+
children: [
|
|
2423
|
+
/* @__PURE__ */ jsx(Label, {
|
|
2424
|
+
htmlFor: "expires-at",
|
|
2425
|
+
size: "small",
|
|
2426
|
+
weight: "plus",
|
|
2427
|
+
children: t("quotes.send.expiresAt")
|
|
2428
|
+
}),
|
|
2429
|
+
/* @__PURE__ */ jsx(Input, {
|
|
2430
|
+
id: "expires-at",
|
|
2431
|
+
type: "datetime-local",
|
|
2432
|
+
value: expiresAt,
|
|
2433
|
+
onChange: (e) => setExpiresAt(e.target.value)
|
|
2434
|
+
}),
|
|
2435
|
+
/* @__PURE__ */ jsx(Hint, { children: t("quotes.send.expiresAtHint") })
|
|
2436
|
+
]
|
|
2437
|
+
})]
|
|
2438
|
+
}),
|
|
2439
|
+
/* @__PURE__ */ jsxs(Drawer.Footer, { children: [/* @__PURE__ */ jsx(Button, {
|
|
2440
|
+
variant: "secondary",
|
|
2441
|
+
onClick: onClose,
|
|
2442
|
+
disabled: isPending,
|
|
2443
|
+
children: t("actions.cancel")
|
|
2444
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
2445
|
+
onClick: handleConfirm,
|
|
2446
|
+
isLoading: isPending,
|
|
2447
|
+
children: t("actions.send")
|
|
2448
|
+
})] })
|
|
2449
|
+
] })
|
|
2450
|
+
});
|
|
2164
2451
|
}
|
|
2165
|
-
// src/admin/routes/b2b/
|
|
2166
|
-
var
|
|
2452
|
+
// src/admin/routes/b2b/quotes/components/quote-actions-menu.tsx
|
|
2453
|
+
var MANAGEABLE_STATUSES = [
|
|
2454
|
+
EQuoteStatus.PendingMerchant,
|
|
2455
|
+
EQuoteStatus.CustomerRejected,
|
|
2456
|
+
EQuoteStatus.MerchantRejected
|
|
2457
|
+
];
|
|
2458
|
+
var QuoteActionsMenu = ({ quote }) => {
|
|
2167
2459
|
const { t } = useTranslation();
|
|
2168
|
-
const
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
|
|
2460
|
+
const prompt = usePrompt();
|
|
2461
|
+
const navigate = useNavigate();
|
|
2462
|
+
const [sendDrawerOpen, setSendDrawerOpen] = useState(false);
|
|
2463
|
+
const { mutateAsync: sendQuote, isPending: isSending } = useSendQuote(quote.id);
|
|
2464
|
+
const { mutateAsync: rejectQuote, isPending: isRejecting } = useRejectQuote(quote.id);
|
|
2465
|
+
const canSend = [EQuoteStatus.PendingMerchant, EQuoteStatus.CustomerRejected].includes(quote.status);
|
|
2466
|
+
const canReject = [EQuoteStatus.PendingMerchant, EQuoteStatus.PendingCustomer].includes(quote.status);
|
|
2467
|
+
const canManage = MANAGEABLE_STATUSES.includes(quote.status);
|
|
2468
|
+
const handleSendConfirm = async (expiresAt) => {
|
|
2469
|
+
try {
|
|
2470
|
+
await sendQuote({ expires_at: expiresAt }, {
|
|
2471
|
+
onSuccess: () => {
|
|
2472
|
+
setSendDrawerOpen(false);
|
|
2473
|
+
toast.success(t("quotes.toasts.sent"));
|
|
2474
|
+
},
|
|
2475
|
+
onError: (err) => toast.error(err.message)
|
|
2476
|
+
});
|
|
2477
|
+
} catch {}
|
|
2478
|
+
};
|
|
2479
|
+
const handleReject = async () => {
|
|
2480
|
+
if (!await prompt({
|
|
2481
|
+
title: t("quotes.prompts.reject.title"),
|
|
2482
|
+
description: t("quotes.prompts.reject.description"),
|
|
2483
|
+
confirmText: t("actions.reject"),
|
|
2484
|
+
cancelText: t("actions.cancel")
|
|
2485
|
+
})) return;
|
|
2486
|
+
try {
|
|
2487
|
+
await rejectQuote(void 0, {
|
|
2488
|
+
onSuccess: () => toast.success(t("quotes.toasts.rejected")),
|
|
2489
|
+
onError: (err) => toast.error(err.message)
|
|
2490
|
+
});
|
|
2491
|
+
} catch {}
|
|
2492
|
+
};
|
|
2493
|
+
const primaryActions = [];
|
|
2494
|
+
if (canManage) primaryActions.push({
|
|
2495
|
+
label: t("quotes.summary.manage", "Manage"),
|
|
2496
|
+
onClick: () => navigate(`/b2b/quotes/${quote.id}/manage`),
|
|
2497
|
+
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
2498
|
+
});
|
|
2499
|
+
if (canSend) primaryActions.push({
|
|
2500
|
+
label: t("quotes.detail.sendQuote"),
|
|
2501
|
+
onClick: () => setSendDrawerOpen(true),
|
|
2502
|
+
disabled: isSending,
|
|
2503
|
+
icon: /* @__PURE__ */ jsx(EllipsisHorizontal, {})
|
|
2504
|
+
});
|
|
2505
|
+
const dangerActions = [];
|
|
2506
|
+
if (canReject) dangerActions.push({
|
|
2507
|
+
label: t("quotes.detail.rejectQuote"),
|
|
2508
|
+
onClick: handleReject,
|
|
2509
|
+
disabled: isRejecting,
|
|
2510
|
+
icon: /* @__PURE__ */ jsx(XCircle, {})
|
|
2511
|
+
});
|
|
2512
|
+
const groups = [];
|
|
2513
|
+
if (primaryActions.length) groups.push({ actions: primaryActions });
|
|
2514
|
+
if (dangerActions.length) groups.push({ actions: dangerActions });
|
|
2515
|
+
if (!groups.length) return null;
|
|
2516
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ActionMenu, { groups }), /* @__PURE__ */ jsx(SendQuoteDrawer, {
|
|
2517
|
+
open: sendDrawerOpen,
|
|
2518
|
+
onClose: () => setSendDrawerOpen(false),
|
|
2519
|
+
onConfirm: handleSendConfirm,
|
|
2520
|
+
isPending: isSending
|
|
2521
|
+
})] });
|
|
2522
|
+
};
|
|
2523
|
+
// src/admin/routes/b2b/quotes/components/quotes-table-renderers.tsx
|
|
2524
|
+
defineCellRenderer("b2b-display-id-prefix", { render: (value) => value != null ? `#${value}` : "-" });
|
|
2525
|
+
defineCellRenderer("b2b-quote-status", { render: (value) => /* @__PURE__ */ jsx(QuoteStatusBadge, { status: value }) });
|
|
2526
|
+
defineCellRenderer("b2b-quote-total", { render: (value, row) => {
|
|
2527
|
+
const amount = value;
|
|
2528
|
+
if (amount == null) return "-";
|
|
2529
|
+
const currencyCode = (row?.draft_order?.currency_code ?? "USD").toUpperCase();
|
|
2530
|
+
return formatCurrency(amount / 100, currencyCode);
|
|
2531
|
+
} });
|
|
2532
|
+
defineCellRenderer("b2b-quote-customer-link", { render: (value) => {
|
|
2533
|
+
if (!value.id) return "-";
|
|
2534
|
+
return /* @__PURE__ */ jsx(Link$1, {
|
|
2535
|
+
to: `/customers/${value.id}`,
|
|
2536
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2537
|
+
children: value.full_name || value.id
|
|
2538
|
+
});
|
|
2539
|
+
} });
|
|
2540
|
+
defineCellRenderer("b2b-quote-draft-order-link", { render: (value, row) => {
|
|
2541
|
+
if (!value) return "-";
|
|
2542
|
+
const displayId = row?.draft_order?.display_id;
|
|
2543
|
+
return /* @__PURE__ */ jsx(Link$1, {
|
|
2544
|
+
to: `/orders/${value}`,
|
|
2545
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2546
|
+
children: displayId != null ? `#${displayId}` : value
|
|
2547
|
+
});
|
|
2548
|
+
} });
|
|
2549
|
+
defineCellRenderer("b2b-quote-order-change-link", { render: (value, row) => {
|
|
2550
|
+
if (!value) return "-";
|
|
2551
|
+
const draftOrderId = row?.draft_order?.id ?? row?.draft_order_id;
|
|
2552
|
+
if (draftOrderId) return /* @__PURE__ */ jsx(Link$1, {
|
|
2553
|
+
to: `/orders/${draftOrderId}`,
|
|
2554
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2555
|
+
children: value
|
|
2556
|
+
});
|
|
2557
|
+
return /* @__PURE__ */ jsx("span", {
|
|
2558
|
+
className: "txt-compact-small text-ui-fg-subtle",
|
|
2559
|
+
children: value
|
|
2560
|
+
});
|
|
2561
|
+
} });
|
|
2562
|
+
defineCellRenderer("b2b-quote-cart-link", { render: (value) => {
|
|
2563
|
+
if (!value) return "-";
|
|
2564
|
+
return /* @__PURE__ */ jsx("span", {
|
|
2565
|
+
className: "txt-compact-small text-ui-fg-subtle",
|
|
2566
|
+
children: value
|
|
2567
|
+
});
|
|
2568
|
+
} });
|
|
2569
|
+
defineCellRenderer("b2b-quote-messages-count", { render: (value) => {
|
|
2570
|
+
const count = Array.isArray(value) ? value.length : 0;
|
|
2571
|
+
return /* @__PURE__ */ jsx("span", {
|
|
2572
|
+
className: "txt-compact-small",
|
|
2573
|
+
children: count
|
|
2574
|
+
});
|
|
2575
|
+
} });
|
|
2576
|
+
// src/admin/routes/b2b/quotes/components/quotes-table-adapter.tsx
|
|
2577
|
+
function useQuotesTableAdapter() {
|
|
2578
|
+
const { t } = useTranslation();
|
|
2579
|
+
return useMemo(() => createTableAdapter({
|
|
2580
|
+
entity: "b2b-quotes",
|
|
2581
|
+
queryPrefix: "quot",
|
|
2582
|
+
pageSize: 50,
|
|
2583
|
+
useData: (_fields, params) => {
|
|
2584
|
+
const result = useQuotes({
|
|
2585
|
+
...params,
|
|
2586
|
+
order: "-created_at"
|
|
2587
|
+
});
|
|
2588
|
+
return {
|
|
2589
|
+
data: result.quotes,
|
|
2590
|
+
count: result.count,
|
|
2591
|
+
isLoading: result.isPending,
|
|
2592
|
+
isError: result.isError,
|
|
2593
|
+
error: result.error
|
|
2594
|
+
};
|
|
2595
|
+
},
|
|
2596
|
+
getRowHref: (row) => `/b2b/quotes/${row.id}`,
|
|
2597
|
+
renderRowActions: (row) => /* @__PURE__ */ jsx(QuoteActionsMenu, { quote: row }),
|
|
2598
|
+
emptyState: {
|
|
2599
|
+
empty: {
|
|
2600
|
+
heading: t("quotes.table.noRecordsTitle"),
|
|
2601
|
+
description: t("quotes.table.noRecordsMessage")
|
|
2602
|
+
},
|
|
2603
|
+
filtered: {
|
|
2604
|
+
heading: t("quotes.table.noRecordsTitle"),
|
|
2605
|
+
description: t("quotes.table.noRecordsMessage")
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
}), [t]);
|
|
2609
|
+
}
|
|
2610
|
+
// src/admin/routes/b2b/quotes/page.tsx
|
|
2611
|
+
var Quotes = () => {
|
|
2612
|
+
const { t } = useTranslation();
|
|
2613
|
+
const isViewConfigEnabled = useFeatureFlag("view_configurations");
|
|
2614
|
+
const adapter = useQuotesTableAdapter();
|
|
2615
|
+
return /* @__PURE__ */ jsx(LayoutComposer, {
|
|
2616
|
+
widgetsZonePrefix: "quotes_list.list",
|
|
2172
2617
|
preferredLayoutId: CORE_LAYOUT_IDS.SINGLE_COLUMN,
|
|
2173
2618
|
sections: { main: /* @__PURE__ */ jsxs(LayoutComposer.Entry, {
|
|
2174
|
-
id: "
|
|
2619
|
+
id: "QuotesListTable",
|
|
2175
2620
|
children: [isViewConfigEnabled ? /* @__PURE__ */ jsx(ConfigurableDataTable, {
|
|
2176
2621
|
adapter,
|
|
2177
|
-
heading: t("
|
|
2178
|
-
subHeading: t("overview.nav.
|
|
2179
|
-
}) : /* @__PURE__ */ jsx(
|
|
2622
|
+
heading: t("quotes.title"),
|
|
2623
|
+
subHeading: t("overview.nav.quotes.description")
|
|
2624
|
+
}) : /* @__PURE__ */ jsx(QuotesTable, {}), /* @__PURE__ */ jsx(Toaster, {})]
|
|
2180
2625
|
}) }
|
|
2181
2626
|
});
|
|
2182
2627
|
};
|
|
2183
|
-
var Breadcrumb$
|
|
2628
|
+
var Breadcrumb$2 = () => {
|
|
2184
2629
|
const { t } = useTranslation();
|
|
2185
|
-
return t("
|
|
2630
|
+
return t("quotes.title");
|
|
2186
2631
|
};
|
|
2187
|
-
var config
|
|
2188
|
-
label: "
|
|
2189
|
-
|
|
2632
|
+
var config = defineRouteConfig({
|
|
2633
|
+
label: "quotes.title",
|
|
2634
|
+
translationNs: "b2b",
|
|
2635
|
+
icon: DocumentText
|
|
2190
2636
|
});
|
|
2191
|
-
var handle$
|
|
2192
|
-
var
|
|
2637
|
+
var handle$2 = { breadcrumb: () => /* @__PURE__ */ jsx(Breadcrumb$2, {}) };
|
|
2638
|
+
var GuardedQuotes = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
2193
2639
|
permission: "b2b.read",
|
|
2194
|
-
children: /* @__PURE__ */ jsx(
|
|
2640
|
+
children: /* @__PURE__ */ jsx(Quotes, {})
|
|
2195
2641
|
});
|
|
2196
|
-
// src/admin/routes/b2b/
|
|
2197
|
-
var
|
|
2198
|
-
pending_merchant: "purple",
|
|
2199
|
-
pending_customer: "purple",
|
|
2200
|
-
accepted: "green",
|
|
2201
|
-
customer_rejected: "red",
|
|
2202
|
-
merchant_rejected: "red",
|
|
2203
|
-
expired: "grey"
|
|
2204
|
-
};
|
|
2205
|
-
function QuoteStatusBadge({ status }) {
|
|
2642
|
+
// src/admin/routes/b2b/companies/[id]/components/company-general-section.tsx
|
|
2643
|
+
var CompanyGeneralSection = ({ company }) => {
|
|
2206
2644
|
const { t } = useTranslation();
|
|
2207
|
-
const
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2645
|
+
const c = company;
|
|
2646
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
2647
|
+
className: "divide-y p-0",
|
|
2648
|
+
children: [
|
|
2649
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2650
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
2651
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2652
|
+
className: "flex items-center gap-x-3",
|
|
2653
|
+
children: [/* @__PURE__ */ jsx(Thumbnail, { src: c.logo_url }), /* @__PURE__ */ jsx(Heading, { children: c.name })]
|
|
2654
|
+
}), /* @__PURE__ */ jsx(CompanyActionsMenu, { company })]
|
|
2655
|
+
}),
|
|
2656
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
2657
|
+
title: t("companies.detail.email"),
|
|
2658
|
+
value: c.email || "—"
|
|
2659
|
+
}),
|
|
2660
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
2661
|
+
title: t("companies.detail.phone"),
|
|
2662
|
+
value: c.phone || "—"
|
|
2663
|
+
}),
|
|
2664
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
2665
|
+
title: t("companies.detail.address"),
|
|
2666
|
+
value: c.address || "—"
|
|
2667
|
+
}),
|
|
2668
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
2669
|
+
title: t("companies.detail.city"),
|
|
2670
|
+
value: c.city || "—"
|
|
2671
|
+
}),
|
|
2672
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
2673
|
+
title: t("companies.detail.state"),
|
|
2674
|
+
value: c.state || "—"
|
|
2675
|
+
}),
|
|
2676
|
+
c.currency_code && /* @__PURE__ */ jsx(SectionRow, {
|
|
2677
|
+
title: t("companies.detail.currency"),
|
|
2678
|
+
value: /* @__PURE__ */ jsx(Badge, {
|
|
2679
|
+
size: "xsmall",
|
|
2680
|
+
color: "grey",
|
|
2681
|
+
children: c.currency_code.toUpperCase()
|
|
2682
|
+
})
|
|
2683
|
+
}),
|
|
2684
|
+
c.spending_limit_reset_frequency && /* @__PURE__ */ jsx(SectionRow, {
|
|
2685
|
+
title: t("companies.detail.spendingLimitResetFrequency"),
|
|
2686
|
+
value: c.spending_limit_reset_frequency
|
|
2687
|
+
}),
|
|
2688
|
+
c.spending_limit_reset_at && /* @__PURE__ */ jsx(SectionRow, {
|
|
2689
|
+
title: t("companies.detail.spendingLimitResetAt"),
|
|
2690
|
+
value: new Date(c.spending_limit_reset_at).toLocaleDateString()
|
|
2691
|
+
})
|
|
2692
|
+
]
|
|
2218
2693
|
});
|
|
2219
|
-
}
|
|
2220
|
-
// src/admin/routes/b2b/quotes/components/table/columns.tsx
|
|
2221
|
-
var columnHelper$2 = legacyCreateColumnHelper();
|
|
2222
|
-
var useQuotesTableColumns = () => {
|
|
2223
|
-
const { t } = useTranslation();
|
|
2224
|
-
return useMemo(() => [
|
|
2225
|
-
columnHelper$2.accessor("status", {
|
|
2226
|
-
header: t("fields.status"),
|
|
2227
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(QuoteStatusBadge, { status: getValue() })
|
|
2228
|
-
}),
|
|
2229
|
-
columnHelper$2.accessor("customer", {
|
|
2230
|
-
header: t("quotes.table.customer"),
|
|
2231
|
-
cell: ({ row }) => {
|
|
2232
|
-
const customer = row.original.customer;
|
|
2233
|
-
if (!customer) return /* @__PURE__ */ jsx("span", {
|
|
2234
|
-
className: "txt-compact-small text-ui-fg-subtle",
|
|
2235
|
-
children: "—"
|
|
2236
|
-
});
|
|
2237
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ") || customer.email || customer.id;
|
|
2238
|
-
return /* @__PURE__ */ jsx(Link$1, {
|
|
2239
|
-
to: `/customers/${customer.id}`,
|
|
2240
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2241
|
-
children: name
|
|
2242
|
-
});
|
|
2243
|
-
}
|
|
2244
|
-
}),
|
|
2245
|
-
columnHelper$2.accessor("draft_order", {
|
|
2246
|
-
header: t("quotes.table.draftOrder"),
|
|
2247
|
-
cell: ({ row }) => {
|
|
2248
|
-
const draftOrder = row.original.draft_order;
|
|
2249
|
-
if (!draftOrder) return /* @__PURE__ */ jsx("span", {
|
|
2250
|
-
className: "txt-compact-small text-ui-fg-subtle",
|
|
2251
|
-
children: "—"
|
|
2252
|
-
});
|
|
2253
|
-
return /* @__PURE__ */ jsxs(Link$1, {
|
|
2254
|
-
to: `/orders/${draftOrder.id}`,
|
|
2255
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2256
|
-
children: ["#", draftOrder.display_id]
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
}),
|
|
2260
|
-
columnHelper$2.accessor("messages_count", {
|
|
2261
|
-
header: t("quotes.table.messages"),
|
|
2262
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx("span", {
|
|
2263
|
-
className: "txt-compact-small",
|
|
2264
|
-
children: getValue() ?? 0
|
|
2265
|
-
})
|
|
2266
|
-
}),
|
|
2267
|
-
columnHelper$2.accessor("created_at", {
|
|
2268
|
-
header: t("fields.createdAt"),
|
|
2269
|
-
cell: ({ getValue }) => /* @__PURE__ */ jsx(DateCell, { date: getValue() })
|
|
2270
|
-
})
|
|
2271
|
-
], [t]);
|
|
2272
2694
|
};
|
|
2273
|
-
// src/admin/routes/b2b/
|
|
2274
|
-
var
|
|
2695
|
+
// src/admin/routes/b2b/companies/[id]/@employee/components/employees-actions-menu.tsx
|
|
2696
|
+
var EmployeesActionsMenu = ({ employee }) => {
|
|
2275
2697
|
const { t } = useTranslation();
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
label: t("quotes.status.accepted"),
|
|
2292
|
-
value: EQuoteStatus.Accepted
|
|
2293
|
-
},
|
|
2294
|
-
{
|
|
2295
|
-
label: t("quotes.status.customer_rejected"),
|
|
2296
|
-
value: EQuoteStatus.CustomerRejected
|
|
2297
|
-
},
|
|
2298
|
-
{
|
|
2299
|
-
label: t("quotes.status.merchant_rejected"),
|
|
2300
|
-
value: EQuoteStatus.MerchantRejected
|
|
2301
|
-
},
|
|
2302
|
-
{
|
|
2303
|
-
label: t("quotes.status.expired"),
|
|
2304
|
-
value: EQuoteStatus.Expired
|
|
2305
|
-
}
|
|
2306
|
-
]
|
|
2307
|
-
},
|
|
2308
|
-
{
|
|
2309
|
-
label: t("quotes.filters.customerId"),
|
|
2310
|
-
key: "customer_id",
|
|
2311
|
-
type: "string"
|
|
2312
|
-
},
|
|
2313
|
-
{
|
|
2314
|
-
label: t("quotes.filters.draftOrderId"),
|
|
2315
|
-
key: "draft_order_id",
|
|
2316
|
-
type: "string"
|
|
2317
|
-
}
|
|
2318
|
-
];
|
|
2319
|
-
};
|
|
2320
|
-
// src/admin/routes/b2b/quotes/components/table/query.tsx
|
|
2321
|
-
var useQuotesTableQuery = ({ pageSize = 50, prefix }) => {
|
|
2322
|
-
const raw = useQueryParams([
|
|
2323
|
-
"q",
|
|
2324
|
-
"offset",
|
|
2325
|
-
"order",
|
|
2326
|
-
"created_at",
|
|
2327
|
-
"updated_at",
|
|
2328
|
-
"status"
|
|
2329
|
-
], prefix);
|
|
2330
|
-
const { offset, created_at, updated_at, ...rest } = raw;
|
|
2331
|
-
return {
|
|
2332
|
-
searchParams: {
|
|
2333
|
-
...rest,
|
|
2334
|
-
limit: pageSize,
|
|
2335
|
-
offset: offset ? Number(offset) : 0,
|
|
2336
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
2337
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0
|
|
2338
|
-
},
|
|
2339
|
-
raw
|
|
2698
|
+
const prompt = usePrompt();
|
|
2699
|
+
const { mutateAsync: deleteEmployee, isPending: isDeleting } = useDeleteEmployee(employee.company_id);
|
|
2700
|
+
const handleDelete = async () => {
|
|
2701
|
+
if (!await prompt({
|
|
2702
|
+
title: t("employees.prompts.delete.title"),
|
|
2703
|
+
description: t("employees.prompts.delete.description"),
|
|
2704
|
+
confirmText: t("actions.delete"),
|
|
2705
|
+
cancelText: t("actions.cancel")
|
|
2706
|
+
})) return;
|
|
2707
|
+
try {
|
|
2708
|
+
await deleteEmployee(employee.id, {
|
|
2709
|
+
onSuccess: () => toast.success(t("employees.toasts.deleted")),
|
|
2710
|
+
onError: (err) => toast.error(err.message)
|
|
2711
|
+
});
|
|
2712
|
+
} catch {}
|
|
2340
2713
|
};
|
|
2714
|
+
return /* @__PURE__ */ jsx(ActionMenu, { groups: [{ actions: [{
|
|
2715
|
+
label: t("actions.edit"),
|
|
2716
|
+
to: `/b2b/companies/${employee.company_id}/employee/${employee.id}`,
|
|
2717
|
+
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
2718
|
+
}] }, { actions: [{
|
|
2719
|
+
label: t("actions.delete"),
|
|
2720
|
+
onClick: handleDelete,
|
|
2721
|
+
disabled: isDeleting,
|
|
2722
|
+
icon: /* @__PURE__ */ jsx(Trash, {})
|
|
2723
|
+
}] }] });
|
|
2341
2724
|
};
|
|
2342
|
-
// src/admin/routes/b2b/
|
|
2343
|
-
var
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
const columns = useQuotesTableColumns();
|
|
2358
|
-
const filters = useQuotesTableFilters();
|
|
2359
|
-
const { table } = useDataTable$1({
|
|
2360
|
-
data: quotes,
|
|
2361
|
-
columns,
|
|
2362
|
-
count,
|
|
2363
|
-
enablePagination: true,
|
|
2364
|
-
pageSize: PAGE_SIZE,
|
|
2365
|
-
prefix: PREFIX,
|
|
2366
|
-
getRowId: (row) => row.id
|
|
2367
|
-
});
|
|
2368
|
-
return /* @__PURE__ */ jsxs(Container, {
|
|
2369
|
-
className: "divide-y p-0",
|
|
2370
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2371
|
-
className: "flex items-center justify-between px-6 py-4",
|
|
2372
|
-
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Heading, { children: t("quotes.title") }), /* @__PURE__ */ jsx(Text, {
|
|
2373
|
-
className: "text-ui-fg-subtle",
|
|
2374
|
-
size: "small",
|
|
2375
|
-
children: t("overview.nav.quotes.description")
|
|
2376
|
-
})] })
|
|
2377
|
-
}), /* @__PURE__ */ jsx(DataTable$1, {
|
|
2378
|
-
columns,
|
|
2379
|
-
table,
|
|
2380
|
-
navigateTo: (row) => `/b2b/quotes/${row.original.id}`,
|
|
2381
|
-
pagination: true,
|
|
2382
|
-
filters,
|
|
2383
|
-
count,
|
|
2384
|
-
search: true,
|
|
2385
|
-
isLoading: result.isPending,
|
|
2386
|
-
pageSize: PAGE_SIZE,
|
|
2387
|
-
orderBy: ["created_at"],
|
|
2388
|
-
prefix: PREFIX,
|
|
2389
|
-
queryObject: raw,
|
|
2390
|
-
noRecords: {
|
|
2391
|
-
title: t("quotes.table.noRecordsTitle"),
|
|
2392
|
-
message: t("quotes.table.noRecordsMessage")
|
|
2393
|
-
}
|
|
2394
|
-
})]
|
|
2395
|
-
});
|
|
2396
|
-
};
|
|
2397
|
-
// src/admin/routes/b2b/quotes/components/send-quote-drawer.tsx
|
|
2398
|
-
function SendQuoteDrawer({ open, onClose, onConfirm, isPending }) {
|
|
2725
|
+
// src/admin/routes/b2b/companies/[id]/@employee/components/validators.ts
|
|
2726
|
+
var makeEmployeeCreateFormSchema = () => z.object({
|
|
2727
|
+
first_name: z.string().optional().or(z.literal("")),
|
|
2728
|
+
last_name: z.string().optional().or(z.literal("")),
|
|
2729
|
+
email: z.email(),
|
|
2730
|
+
phone: z.string().optional().or(z.literal("")),
|
|
2731
|
+
spending_limit: z.string().optional(),
|
|
2732
|
+
is_admin: z.boolean()
|
|
2733
|
+
});
|
|
2734
|
+
var makeEmployeeUpdateFormSchema = () => z.object({
|
|
2735
|
+
spending_limit: z.string().optional(),
|
|
2736
|
+
is_admin: z.boolean()
|
|
2737
|
+
});
|
|
2738
|
+
// src/admin/routes/b2b/companies/[id]/@employee/components/employees-create-form.tsx
|
|
2739
|
+
function EmployeesCreateForm({ handleSubmit, loading, error, company }) {
|
|
2399
2740
|
const { t } = useTranslation();
|
|
2400
|
-
const
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2741
|
+
const form = useForm({
|
|
2742
|
+
resolver: zodResolver(makeEmployeeCreateFormSchema()),
|
|
2743
|
+
defaultValues: {
|
|
2744
|
+
first_name: "",
|
|
2745
|
+
last_name: "",
|
|
2746
|
+
email: "",
|
|
2747
|
+
phone: "",
|
|
2748
|
+
spending_limit: "0",
|
|
2749
|
+
is_admin: false
|
|
2408
2750
|
}
|
|
2409
|
-
};
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
children: /* @__PURE__ */ jsxs(
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
/* @__PURE__ */ jsx(Input, {
|
|
2430
|
-
id: "expires-at",
|
|
2431
|
-
type: "datetime-local",
|
|
2432
|
-
value: expiresAt,
|
|
2433
|
-
onChange: (e) => setExpiresAt(e.target.value)
|
|
2751
|
+
});
|
|
2752
|
+
const currencyKey = company.currency_code || "USD";
|
|
2753
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, {
|
|
2754
|
+
form,
|
|
2755
|
+
children: /* @__PURE__ */ jsxs(KeyboundForm, {
|
|
2756
|
+
onSubmit: form.handleSubmit((data) => handleSubmit({
|
|
2757
|
+
...data,
|
|
2758
|
+
company_id: company.id,
|
|
2759
|
+
customer_id: "",
|
|
2760
|
+
spending_limit: data.spending_limit ? parseInt(data.spending_limit, 10) : 0
|
|
2761
|
+
})),
|
|
2762
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
2763
|
+
children: [/* @__PURE__ */ jsxs(RouteDrawer.Body, {
|
|
2764
|
+
className: "flex flex-1 flex-col gap-y-6 overflow-auto p-4",
|
|
2765
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2766
|
+
className: "flex flex-col gap-y-4",
|
|
2767
|
+
children: [
|
|
2768
|
+
/* @__PURE__ */ jsx("h2", {
|
|
2769
|
+
className: "h2-core",
|
|
2770
|
+
children: t("employees.form.details")
|
|
2434
2771
|
}),
|
|
2435
|
-
/* @__PURE__ */ jsx(
|
|
2772
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2773
|
+
control: form.control,
|
|
2774
|
+
name: "first_name",
|
|
2775
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
2776
|
+
/* @__PURE__ */ jsx(Form.Label, {
|
|
2777
|
+
optional: true,
|
|
2778
|
+
children: t("employees.form.firstName")
|
|
2779
|
+
}),
|
|
2780
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
2781
|
+
placeholder: "John",
|
|
2782
|
+
...field
|
|
2783
|
+
}) }),
|
|
2784
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
2785
|
+
] })
|
|
2786
|
+
}),
|
|
2787
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2788
|
+
control: form.control,
|
|
2789
|
+
name: "last_name",
|
|
2790
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
2791
|
+
/* @__PURE__ */ jsx(Form.Label, {
|
|
2792
|
+
optional: true,
|
|
2793
|
+
children: t("employees.form.lastName")
|
|
2794
|
+
}),
|
|
2795
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
2796
|
+
placeholder: "Doe",
|
|
2797
|
+
...field
|
|
2798
|
+
}) }),
|
|
2799
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
2800
|
+
] })
|
|
2801
|
+
}),
|
|
2802
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2803
|
+
control: form.control,
|
|
2804
|
+
name: "email",
|
|
2805
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
2806
|
+
/* @__PURE__ */ jsx(Form.Label, { children: t("employees.form.email") }),
|
|
2807
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
2808
|
+
type: "email",
|
|
2809
|
+
placeholder: "john.doe@example.com",
|
|
2810
|
+
...field
|
|
2811
|
+
}) }),
|
|
2812
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
2813
|
+
] })
|
|
2814
|
+
}),
|
|
2815
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2816
|
+
control: form.control,
|
|
2817
|
+
name: "phone",
|
|
2818
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
2819
|
+
/* @__PURE__ */ jsx(Form.Label, {
|
|
2820
|
+
optional: true,
|
|
2821
|
+
children: t("employees.form.phone")
|
|
2822
|
+
}),
|
|
2823
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
2824
|
+
placeholder: "0612345678",
|
|
2825
|
+
...field
|
|
2826
|
+
}) }),
|
|
2827
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
2828
|
+
] })
|
|
2829
|
+
})
|
|
2830
|
+
]
|
|
2831
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2832
|
+
className: "flex flex-col gap-y-4",
|
|
2833
|
+
children: [
|
|
2834
|
+
/* @__PURE__ */ jsx("h2", {
|
|
2835
|
+
className: "h2-core",
|
|
2836
|
+
children: t("employees.form.permissions")
|
|
2837
|
+
}),
|
|
2838
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2839
|
+
control: form.control,
|
|
2840
|
+
name: "spending_limit",
|
|
2841
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
2842
|
+
/* @__PURE__ */ jsx(Form.Label, {
|
|
2843
|
+
optional: true,
|
|
2844
|
+
children: t("employees.form.spendingLimit", { currency: company.currency_code?.toUpperCase() || "USD" })
|
|
2845
|
+
}),
|
|
2846
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CurrencyInput, {
|
|
2847
|
+
symbol: getCurrencySymbol(currencyKey),
|
|
2848
|
+
code: company.currency_code || "USD",
|
|
2849
|
+
placeholder: "1000",
|
|
2850
|
+
value: field.value ?? "",
|
|
2851
|
+
onChange: (e) => field.onChange(e.target.value.replace(/[^0-9]/g, ""))
|
|
2852
|
+
}) }),
|
|
2853
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
2854
|
+
] })
|
|
2855
|
+
}),
|
|
2856
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2857
|
+
control: form.control,
|
|
2858
|
+
name: "is_admin",
|
|
2859
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [/* @__PURE__ */ jsx(Form.Label, {
|
|
2860
|
+
optional: true,
|
|
2861
|
+
children: t("employees.form.adminAccess")
|
|
2862
|
+
}), /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CoolSwitch, {
|
|
2863
|
+
fieldName: "is_admin",
|
|
2864
|
+
label: t("employees.form.isAdmin"),
|
|
2865
|
+
description: t("employees.form.isAdminDescription"),
|
|
2866
|
+
checked: field.value,
|
|
2867
|
+
onChange: field.onChange,
|
|
2868
|
+
tooltip: t("employees.form.isAdminTooltip")
|
|
2869
|
+
}) })] })
|
|
2870
|
+
})
|
|
2436
2871
|
]
|
|
2437
2872
|
})]
|
|
2438
|
-
}),
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2873
|
+
}), /* @__PURE__ */ jsxs(RouteDrawer.Footer, { children: [
|
|
2874
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, {
|
|
2875
|
+
asChild: true,
|
|
2876
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2877
|
+
variant: "secondary",
|
|
2878
|
+
children: t("actions.cancel")
|
|
2879
|
+
})
|
|
2880
|
+
}),
|
|
2881
|
+
/* @__PURE__ */ jsx(Button, {
|
|
2882
|
+
type: "submit",
|
|
2883
|
+
isLoading: loading,
|
|
2884
|
+
children: t("actions.save")
|
|
2885
|
+
}),
|
|
2886
|
+
error && /* @__PURE__ */ jsx(Text, {
|
|
2887
|
+
className: "text-ui-fg-error",
|
|
2888
|
+
children: error.message
|
|
2889
|
+
})
|
|
2890
|
+
] })]
|
|
2891
|
+
})
|
|
2450
2892
|
});
|
|
2451
2893
|
}
|
|
2452
|
-
// src/admin/routes/b2b/
|
|
2453
|
-
|
|
2454
|
-
EQuoteStatus.PendingMerchant,
|
|
2455
|
-
EQuoteStatus.CustomerRejected,
|
|
2456
|
-
EQuoteStatus.MerchantRejected
|
|
2457
|
-
];
|
|
2458
|
-
var QuoteActionsMenu = ({ quote }) => {
|
|
2894
|
+
// src/admin/routes/b2b/companies/[id]/@employee/components/employees-update-form.tsx
|
|
2895
|
+
function EmployeesUpdateForm({ company, employee, handleSubmit, loading, error }) {
|
|
2459
2896
|
const { t } = useTranslation();
|
|
2460
|
-
const
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
const canReject = [EQuoteStatus.PendingMerchant, EQuoteStatus.PendingCustomer].includes(quote.status);
|
|
2467
|
-
const canManage = MANAGEABLE_STATUSES.includes(quote.status);
|
|
2468
|
-
const handleSendConfirm = async (expiresAt) => {
|
|
2469
|
-
try {
|
|
2470
|
-
await sendQuote({ expires_at: expiresAt }, {
|
|
2471
|
-
onSuccess: () => {
|
|
2472
|
-
setSendDrawerOpen(false);
|
|
2473
|
-
toast.success(t("quotes.toasts.sent"));
|
|
2474
|
-
},
|
|
2475
|
-
onError: (err) => toast.error(err.message)
|
|
2476
|
-
});
|
|
2477
|
-
} catch {}
|
|
2478
|
-
};
|
|
2479
|
-
const handleReject = async () => {
|
|
2480
|
-
if (!await prompt({
|
|
2481
|
-
title: t("quotes.prompts.reject.title"),
|
|
2482
|
-
description: t("quotes.prompts.reject.description"),
|
|
2483
|
-
confirmText: t("actions.reject"),
|
|
2484
|
-
cancelText: t("actions.cancel")
|
|
2485
|
-
})) return;
|
|
2486
|
-
try {
|
|
2487
|
-
await rejectQuote(void 0, {
|
|
2488
|
-
onSuccess: () => toast.success(t("quotes.toasts.rejected")),
|
|
2489
|
-
onError: (err) => toast.error(err.message)
|
|
2490
|
-
});
|
|
2491
|
-
} catch {}
|
|
2492
|
-
};
|
|
2493
|
-
const primaryActions = [];
|
|
2494
|
-
if (canManage) primaryActions.push({
|
|
2495
|
-
label: t("quotes.summary.manage", "Manage"),
|
|
2496
|
-
onClick: () => navigate(`/b2b/quotes/${quote.id}/manage`),
|
|
2497
|
-
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
2498
|
-
});
|
|
2499
|
-
if (canSend) primaryActions.push({
|
|
2500
|
-
label: t("quotes.detail.sendQuote"),
|
|
2501
|
-
onClick: () => setSendDrawerOpen(true),
|
|
2502
|
-
disabled: isSending,
|
|
2503
|
-
icon: /* @__PURE__ */ jsx(EllipsisHorizontal, {})
|
|
2504
|
-
});
|
|
2505
|
-
const dangerActions = [];
|
|
2506
|
-
if (canReject) dangerActions.push({
|
|
2507
|
-
label: t("quotes.detail.rejectQuote"),
|
|
2508
|
-
onClick: handleReject,
|
|
2509
|
-
disabled: isRejecting,
|
|
2510
|
-
icon: /* @__PURE__ */ jsx(XCircle, {})
|
|
2511
|
-
});
|
|
2512
|
-
const groups = [];
|
|
2513
|
-
if (primaryActions.length) groups.push({ actions: primaryActions });
|
|
2514
|
-
if (dangerActions.length) groups.push({ actions: dangerActions });
|
|
2515
|
-
if (!groups.length) return null;
|
|
2516
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ActionMenu, { groups }), /* @__PURE__ */ jsx(SendQuoteDrawer, {
|
|
2517
|
-
open: sendDrawerOpen,
|
|
2518
|
-
onClose: () => setSendDrawerOpen(false),
|
|
2519
|
-
onConfirm: handleSendConfirm,
|
|
2520
|
-
isPending: isSending
|
|
2521
|
-
})] });
|
|
2522
|
-
};
|
|
2523
|
-
// src/admin/routes/b2b/quotes/components/quotes-table-renderers.tsx
|
|
2524
|
-
defineCellRenderer("b2b-display-id-prefix", { render: (value) => value != null ? `#${value}` : "-" });
|
|
2525
|
-
defineCellRenderer("b2b-quote-status", { render: (value) => /* @__PURE__ */ jsx(QuoteStatusBadge, { status: value }) });
|
|
2526
|
-
defineCellRenderer("b2b-quote-total", { render: (value, row) => {
|
|
2527
|
-
const amount = value;
|
|
2528
|
-
if (amount == null) return "-";
|
|
2529
|
-
const currencyCode = (row?.draft_order?.currency_code ?? "USD").toUpperCase();
|
|
2530
|
-
return formatCurrency(amount / 100, currencyCode);
|
|
2531
|
-
} });
|
|
2532
|
-
defineCellRenderer("b2b-quote-customer-link", { render: (value) => {
|
|
2533
|
-
if (!value.id) return "-";
|
|
2534
|
-
return /* @__PURE__ */ jsx(Link$1, {
|
|
2535
|
-
to: `/customers/${value.id}`,
|
|
2536
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2537
|
-
children: value.full_name || value.id
|
|
2538
|
-
});
|
|
2539
|
-
} });
|
|
2540
|
-
defineCellRenderer("b2b-quote-draft-order-link", { render: (value, row) => {
|
|
2541
|
-
if (!value) return "-";
|
|
2542
|
-
const displayId = row?.draft_order?.display_id;
|
|
2543
|
-
return /* @__PURE__ */ jsx(Link$1, {
|
|
2544
|
-
to: `/orders/${value}`,
|
|
2545
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2546
|
-
children: displayId != null ? `#${displayId}` : value
|
|
2897
|
+
const form = useForm({
|
|
2898
|
+
resolver: zodResolver(makeEmployeeUpdateFormSchema()),
|
|
2899
|
+
defaultValues: {
|
|
2900
|
+
spending_limit: employee?.spending_limit?.toString() ?? "0",
|
|
2901
|
+
is_admin: employee?.is_admin ?? false
|
|
2902
|
+
}
|
|
2547
2903
|
});
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2904
|
+
const currencyKey = company.currency_code || "USD";
|
|
2905
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, {
|
|
2906
|
+
form,
|
|
2907
|
+
children: /* @__PURE__ */ jsxs(KeyboundForm, {
|
|
2908
|
+
onSubmit: form.handleSubmit((data) => handleSubmit({
|
|
2909
|
+
spending_limit: data.spending_limit ? Number(data.spending_limit) : void 0,
|
|
2910
|
+
is_admin: data.is_admin
|
|
2911
|
+
})),
|
|
2912
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
2913
|
+
children: [/* @__PURE__ */ jsxs(RouteDrawer.Body, {
|
|
2914
|
+
className: "flex flex-1 flex-col gap-y-6 overflow-auto p-4",
|
|
2915
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2916
|
+
className: "flex flex-col gap-y-4",
|
|
2917
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2918
|
+
className: "flex items-center justify-between",
|
|
2919
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
2920
|
+
className: "h2-core",
|
|
2921
|
+
children: t("employees.form.details")
|
|
2922
|
+
}), /* @__PURE__ */ jsx("a", {
|
|
2923
|
+
href: `/app/customers/${employee?.customer?.id}/edit`,
|
|
2924
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover",
|
|
2925
|
+
children: t("employees.form.editCustomerDetails")
|
|
2926
|
+
})]
|
|
2927
|
+
}), /* @__PURE__ */ jsx(Container, {
|
|
2928
|
+
className: "p-0 overflow-hidden",
|
|
2929
|
+
children: /* @__PURE__ */ jsx(Table, { children: /* @__PURE__ */ jsxs(Table.Body, { children: [
|
|
2930
|
+
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
2931
|
+
className: "font-medium font-sans txt-compact-small",
|
|
2932
|
+
children: t("employees.form.name")
|
|
2933
|
+
}), /* @__PURE__ */ jsxs(Table.Cell, { children: [
|
|
2934
|
+
employee?.customer?.first_name,
|
|
2935
|
+
" ",
|
|
2936
|
+
employee?.customer?.last_name
|
|
2937
|
+
] })] }),
|
|
2938
|
+
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
2939
|
+
className: "font-medium font-sans txt-compact-small",
|
|
2940
|
+
children: t("employees.form.email")
|
|
2941
|
+
}), /* @__PURE__ */ jsx(Table.Cell, { children: employee?.customer?.email })] }),
|
|
2942
|
+
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
2943
|
+
className: "font-medium font-sans txt-compact-small",
|
|
2944
|
+
children: t("employees.form.phone")
|
|
2945
|
+
}), /* @__PURE__ */ jsx(Table.Cell, { children: employee?.customer?.phone ?? "—" })] }),
|
|
2946
|
+
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
2947
|
+
className: "font-medium font-sans txt-compact-small",
|
|
2948
|
+
children: t("employees.form.company")
|
|
2949
|
+
}), /* @__PURE__ */ jsx(Table.Cell, { children: company.name })] })
|
|
2950
|
+
] }) })
|
|
2951
|
+
})]
|
|
2952
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2953
|
+
className: "flex flex-col gap-y-4",
|
|
2954
|
+
children: [
|
|
2955
|
+
/* @__PURE__ */ jsx("h2", {
|
|
2956
|
+
className: "h2-core",
|
|
2957
|
+
children: t("employees.form.permissions")
|
|
2958
|
+
}),
|
|
2959
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2960
|
+
control: form.control,
|
|
2961
|
+
name: "spending_limit",
|
|
2962
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
2963
|
+
/* @__PURE__ */ jsx(Form.Label, {
|
|
2964
|
+
optional: true,
|
|
2965
|
+
children: t("fields.spendingLimit")
|
|
2966
|
+
}),
|
|
2967
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CurrencyInput, {
|
|
2968
|
+
symbol: getCurrencySymbol(currencyKey),
|
|
2969
|
+
code: company.currency_code || "USD",
|
|
2970
|
+
placeholder: "1000",
|
|
2971
|
+
value: field.value ?? "",
|
|
2972
|
+
onChange: (e) => field.onChange(e.target.value.replace(/[^0-9]/g, ""))
|
|
2973
|
+
}) }),
|
|
2974
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
2975
|
+
] })
|
|
2976
|
+
}),
|
|
2977
|
+
/* @__PURE__ */ jsx(Form.Field, {
|
|
2978
|
+
control: form.control,
|
|
2979
|
+
name: "is_admin",
|
|
2980
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [/* @__PURE__ */ jsx(Form.Label, {
|
|
2981
|
+
optional: true,
|
|
2982
|
+
children: t("employees.form.adminAccess")
|
|
2983
|
+
}), /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CoolSwitch, {
|
|
2984
|
+
fieldName: "is_admin",
|
|
2985
|
+
label: t("employees.form.isAdmin"),
|
|
2986
|
+
description: t("employees.form.isAdminDescription"),
|
|
2987
|
+
checked: field.value,
|
|
2988
|
+
onChange: field.onChange,
|
|
2989
|
+
tooltip: t("employees.form.isAdminTooltip")
|
|
2990
|
+
}) })] })
|
|
2991
|
+
})
|
|
2992
|
+
]
|
|
2993
|
+
})]
|
|
2994
|
+
}), /* @__PURE__ */ jsxs(RouteDrawer.Footer, { children: [
|
|
2995
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, {
|
|
2996
|
+
asChild: true,
|
|
2997
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2998
|
+
variant: "secondary",
|
|
2999
|
+
children: t("actions.cancel")
|
|
3000
|
+
})
|
|
3001
|
+
}),
|
|
3002
|
+
/* @__PURE__ */ jsx(Button, {
|
|
3003
|
+
type: "submit",
|
|
3004
|
+
isLoading: loading,
|
|
3005
|
+
children: t("actions.save")
|
|
3006
|
+
}),
|
|
3007
|
+
error && /* @__PURE__ */ jsx(Text, {
|
|
3008
|
+
className: "text-ui-fg-error",
|
|
3009
|
+
children: error.message
|
|
3010
|
+
})
|
|
3011
|
+
] })]
|
|
3012
|
+
})
|
|
2560
3013
|
});
|
|
3014
|
+
}
|
|
3015
|
+
// src/admin/routes/b2b/companies/[id]/components/company-employees-table-renderers.tsx
|
|
3016
|
+
defineCellRenderer("b2b-employee-name", { render: (value) => {
|
|
3017
|
+
const customer = value;
|
|
3018
|
+
return [customer?.first_name, customer?.last_name].filter(Boolean).join(" ") || "—";
|
|
2561
3019
|
} });
|
|
2562
|
-
defineCellRenderer("b2b-
|
|
2563
|
-
|
|
2564
|
-
return /* @__PURE__ */ jsx("span", {
|
|
2565
|
-
className: "txt-compact-small text-ui-fg-subtle",
|
|
2566
|
-
children: value
|
|
2567
|
-
});
|
|
3020
|
+
defineCellRenderer("b2b-employee-email", { render: (_value, row) => {
|
|
3021
|
+
return row?.customer?.email || "—";
|
|
2568
3022
|
} });
|
|
2569
|
-
defineCellRenderer("b2b-
|
|
2570
|
-
const
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
3023
|
+
defineCellRenderer("b2b-employee-spending-limit", { render: (value, row, _column, t) => {
|
|
3024
|
+
const currency = row?.company?.currency_code;
|
|
3025
|
+
if (!value || value === 0) return t("quotes.detail.unlimited");
|
|
3026
|
+
return currency ? getLocaleAmount(Number(value), currency) : String(value);
|
|
3027
|
+
} });
|
|
3028
|
+
defineCellRenderer("b2b-employee-is-admin", { render: (value, _row, _column, t) => {
|
|
3029
|
+
return value ? /* @__PURE__ */ jsx(Badge, {
|
|
3030
|
+
size: "2xsmall",
|
|
3031
|
+
color: "green",
|
|
3032
|
+
children: t("employees.admin")
|
|
3033
|
+
}) : null;
|
|
3034
|
+
} });
|
|
3035
|
+
defineCellRenderer("b2b-employee-is-active", { render: (value, _row, _column, t) => {
|
|
3036
|
+
return value ? /* @__PURE__ */ jsx(Badge, {
|
|
3037
|
+
size: "2xsmall",
|
|
3038
|
+
color: "green",
|
|
3039
|
+
children: t("employees.active")
|
|
3040
|
+
}) : /* @__PURE__ */ jsx(Badge, {
|
|
3041
|
+
size: "2xsmall",
|
|
3042
|
+
color: "grey",
|
|
3043
|
+
children: t("employees.inactive")
|
|
2574
3044
|
});
|
|
2575
3045
|
} });
|
|
2576
|
-
// src/admin/routes/b2b/
|
|
2577
|
-
function
|
|
3046
|
+
// src/admin/routes/b2b/companies/[id]/components/company-employees-section.tsx
|
|
3047
|
+
function useCompanyEmployeesAdapter(companyId) {
|
|
2578
3048
|
const { t } = useTranslation();
|
|
2579
3049
|
return useMemo(() => createTableAdapter({
|
|
2580
|
-
entity: "b2b-
|
|
2581
|
-
queryPrefix: "
|
|
2582
|
-
pageSize:
|
|
3050
|
+
entity: "b2b-company-employees",
|
|
3051
|
+
queryPrefix: "cemp",
|
|
3052
|
+
pageSize: 20,
|
|
2583
3053
|
useData: (_fields, params) => {
|
|
2584
|
-
const
|
|
2585
|
-
...params,
|
|
2586
|
-
order: "-created_at"
|
|
2587
|
-
});
|
|
3054
|
+
const { data, isPending, isError, error } = useEmployees(companyId, params);
|
|
2588
3055
|
return {
|
|
2589
|
-
data:
|
|
2590
|
-
count:
|
|
2591
|
-
isLoading:
|
|
2592
|
-
isError
|
|
2593
|
-
error
|
|
3056
|
+
data: data?.employees,
|
|
3057
|
+
count: data?.count,
|
|
3058
|
+
isLoading: isPending,
|
|
3059
|
+
isError,
|
|
3060
|
+
error
|
|
2594
3061
|
};
|
|
2595
3062
|
},
|
|
2596
|
-
getRowHref: (row) =>
|
|
2597
|
-
|
|
3063
|
+
getRowHref: (row) => {
|
|
3064
|
+
const customerId = row.original?.customer?.id;
|
|
3065
|
+
return customerId ? `/customers/${customerId}` : void 0;
|
|
3066
|
+
},
|
|
3067
|
+
renderRowActions: (row) => /* @__PURE__ */ jsx(EmployeesActionsMenu, { employee: row }),
|
|
2598
3068
|
emptyState: {
|
|
2599
3069
|
empty: {
|
|
2600
|
-
heading: t("
|
|
2601
|
-
description:
|
|
3070
|
+
heading: t("employees.noRecords"),
|
|
3071
|
+
description: ""
|
|
2602
3072
|
},
|
|
2603
3073
|
filtered: {
|
|
2604
|
-
heading: t("
|
|
2605
|
-
description:
|
|
3074
|
+
heading: t("employees.noRecords"),
|
|
3075
|
+
description: ""
|
|
2606
3076
|
}
|
|
2607
3077
|
}
|
|
2608
|
-
}), [t]);
|
|
3078
|
+
}), [companyId, t]);
|
|
2609
3079
|
}
|
|
2610
|
-
|
|
2611
|
-
var Quotes = () => {
|
|
3080
|
+
var CompanyEmployeesSection = ({ companyId }) => {
|
|
2612
3081
|
const { t } = useTranslation();
|
|
2613
|
-
const
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
adapter,
|
|
2622
|
-
heading: t("quotes.title"),
|
|
2623
|
-
subHeading: t("overview.nav.quotes.description")
|
|
2624
|
-
}) : /* @__PURE__ */ jsx(QuotesTable, {}), /* @__PURE__ */ jsx(Toaster, {})]
|
|
2625
|
-
}) }
|
|
3082
|
+
const adapter = useCompanyEmployeesAdapter(companyId);
|
|
3083
|
+
return /* @__PURE__ */ jsx(ConfigurableDataTable, {
|
|
3084
|
+
adapter,
|
|
3085
|
+
heading: t("employees.title"),
|
|
3086
|
+
actions: [{
|
|
3087
|
+
label: t("actions.add"),
|
|
3088
|
+
to: `/b2b/companies/${companyId}/employee/create`
|
|
3089
|
+
}]
|
|
2626
3090
|
});
|
|
2627
3091
|
};
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
var handle$2 = { breadcrumb: () => /* @__PURE__ */ jsx(Breadcrumb$2, {}) };
|
|
2638
|
-
var GuardedQuotes = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
2639
|
-
permission: "b2b.read",
|
|
2640
|
-
children: /* @__PURE__ */ jsx(Quotes, {})
|
|
3092
|
+
// src/admin/routes/b2b/companies/[id]/components/company-approval-settings-section.tsx
|
|
3093
|
+
var BoolBadge = ({ value, t }) => value ? /* @__PURE__ */ jsx(Badge, {
|
|
3094
|
+
size: "xsmall",
|
|
3095
|
+
color: "green",
|
|
3096
|
+
children: t("general.yes")
|
|
3097
|
+
}) : /* @__PURE__ */ jsx(Badge, {
|
|
3098
|
+
size: "xsmall",
|
|
3099
|
+
color: "grey",
|
|
3100
|
+
children: t("general.no")
|
|
2641
3101
|
});
|
|
2642
|
-
|
|
2643
|
-
var QuoteCompanySection = ({ quote }) => {
|
|
3102
|
+
var CompanyApprovalSettingsSection = ({ company }) => {
|
|
2644
3103
|
const { t } = useTranslation();
|
|
2645
|
-
const
|
|
2646
|
-
if (!company) return null;
|
|
3104
|
+
const settings = company.approval_settings;
|
|
2647
3105
|
return /* @__PURE__ */ jsxs(Container, {
|
|
2648
3106
|
className: "divide-y p-0",
|
|
2649
3107
|
children: [
|
|
@@ -2651,1050 +3109,405 @@ var QuoteCompanySection = ({ quote }) => {
|
|
|
2651
3109
|
className: "flex items-center justify-between px-6 py-4",
|
|
2652
3110
|
children: [/* @__PURE__ */ jsx(Heading, {
|
|
2653
3111
|
level: "h2",
|
|
2654
|
-
children: t("
|
|
2655
|
-
}), /* @__PURE__ */ jsx(
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
})]
|
|
3112
|
+
children: t("companies.detail.approvalSettings")
|
|
3113
|
+
}), /* @__PURE__ */ jsx(ActionMenu, { groups: [{ actions: [{
|
|
3114
|
+
label: t("companies.actions.approvalSettings"),
|
|
3115
|
+
to: `/b2b/companies/${company.id}/approval-settings`,
|
|
3116
|
+
icon: /* @__PURE__ */ jsx(LockClosedSolid, {})
|
|
3117
|
+
}] }] })]
|
|
2661
3118
|
}),
|
|
2662
3119
|
/* @__PURE__ */ jsx(SectionRow, {
|
|
2663
|
-
title: t("
|
|
2664
|
-
value: /* @__PURE__ */
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
to: `/b2b/companies/${company.id}`,
|
|
2668
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2669
|
-
children: company.name
|
|
2670
|
-
})]
|
|
3120
|
+
title: t("companies.approvalSettings.requiresAdmin"),
|
|
3121
|
+
value: /* @__PURE__ */ jsx(BoolBadge, {
|
|
3122
|
+
value: !!settings?.requires_admin_approval,
|
|
3123
|
+
t
|
|
2671
3124
|
})
|
|
2672
3125
|
}),
|
|
2673
|
-
|
|
2674
|
-
title: t("
|
|
2675
|
-
value:
|
|
3126
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3127
|
+
title: t("companies.approvalSettings.requiresSalesManager"),
|
|
3128
|
+
value: /* @__PURE__ */ jsx(BoolBadge, {
|
|
3129
|
+
value: !!settings?.requires_sales_manager_approval,
|
|
3130
|
+
t
|
|
3131
|
+
})
|
|
2676
3132
|
})
|
|
2677
3133
|
]
|
|
2678
3134
|
});
|
|
2679
3135
|
};
|
|
2680
|
-
// src/admin/routes/b2b/
|
|
2681
|
-
var
|
|
3136
|
+
// src/admin/routes/b2b/companies/[id]/components/company-customer-group-section.tsx
|
|
3137
|
+
var CompanyCustomerGroupSection = ({ company }) => {
|
|
2682
3138
|
const { t } = useTranslation();
|
|
2683
|
-
const
|
|
2684
|
-
const
|
|
3139
|
+
const c = company;
|
|
3140
|
+
const group = Array.isArray(c.customer_group) ? c.customer_group[0] : c.customer_group;
|
|
2685
3141
|
return /* @__PURE__ */ jsxs(Container, {
|
|
2686
3142
|
className: "divide-y p-0",
|
|
2687
3143
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2688
3144
|
className: "flex items-center justify-between px-6 py-4",
|
|
2689
3145
|
children: [/* @__PURE__ */ jsx(Heading, {
|
|
2690
3146
|
level: "h2",
|
|
2691
|
-
children: t("
|
|
2692
|
-
}),
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
/* @__PURE__ */ jsx(
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
children: [customer.first_name, customer.last_name].filter(Boolean).join(" ") || customer.email || customer.id
|
|
2705
|
-
})
|
|
2706
|
-
}),
|
|
2707
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
2708
|
-
title: t("fields.email"),
|
|
2709
|
-
value: customer.email || "—"
|
|
2710
|
-
}),
|
|
2711
|
-
customer.phone && /* @__PURE__ */ jsx(SectionRow, {
|
|
2712
|
-
title: t("fields.phone"),
|
|
2713
|
-
value: customer.phone
|
|
2714
|
-
}),
|
|
2715
|
-
q.customer?.employee?.spending_limit != null && /* @__PURE__ */ jsx(SectionRow, {
|
|
2716
|
-
title: t("fields.spendingLimit"),
|
|
2717
|
-
value: q.customer.employee.spending_limit === 0 ? t("quotes.detail.unlimited") : formatCurrency(q.customer.employee.spending_limit / 100, q.customer.employee.company?.currency_code ?? "USD")
|
|
2718
|
-
})
|
|
2719
|
-
] }) : /* @__PURE__ */ jsx("div", {
|
|
2720
|
-
className: "px-6 py-4 txt-compact-small text-ui-fg-subtle",
|
|
2721
|
-
children: t("quotes.detail.noCustomer")
|
|
3147
|
+
children: t("companies.detail.customerGroup")
|
|
3148
|
+
}), /* @__PURE__ */ jsx(ActionMenu, { groups: [{ actions: [{
|
|
3149
|
+
label: t("companies.actions.manageCustomerGroup"),
|
|
3150
|
+
to: `/b2b/companies/${company.id}/customer-group`,
|
|
3151
|
+
icon: /* @__PURE__ */ jsx(Link, {})
|
|
3152
|
+
}] }] })]
|
|
3153
|
+
}), /* @__PURE__ */ jsx(SectionRow, {
|
|
3154
|
+
title: t("companies.detail.customerGroup"),
|
|
3155
|
+
value: group?.id ? /* @__PURE__ */ jsx(Link$1, {
|
|
3156
|
+
to: `/customer-groups/${group.id}`,
|
|
3157
|
+
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover",
|
|
3158
|
+
children: group.name || group.id
|
|
3159
|
+
}) : "—"
|
|
2722
3160
|
})]
|
|
2723
3161
|
});
|
|
2724
3162
|
};
|
|
2725
|
-
// src/admin/routes/b2b/
|
|
2726
|
-
var
|
|
2727
|
-
const {
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
onClick: onViewOrder,
|
|
2736
|
-
children: t("quotes.detail.viewOrder")
|
|
2737
|
-
}),
|
|
2738
|
-
canReject && /* @__PURE__ */ jsx(Button, {
|
|
2739
|
-
size: "small",
|
|
2740
|
-
variant: "secondary",
|
|
2741
|
-
isLoading: isRejecting,
|
|
2742
|
-
onClick: onReject,
|
|
2743
|
-
children: t("quotes.detail.rejectQuote")
|
|
2744
|
-
}),
|
|
2745
|
-
canSend && /* @__PURE__ */ jsx(Button, {
|
|
2746
|
-
size: "small",
|
|
2747
|
-
isLoading: isSending,
|
|
2748
|
-
onClick: onOpenSendDrawer,
|
|
2749
|
-
children: t("quotes.detail.sendQuote")
|
|
2750
|
-
})
|
|
2751
|
-
]
|
|
2752
|
-
});
|
|
2753
|
-
};
|
|
2754
|
-
// src/admin/routes/b2b/quotes/[id]/components/quote-general-section.tsx
|
|
2755
|
-
var QuoteGeneralSection = ({ quote }) => {
|
|
2756
|
-
const { t } = useTranslation();
|
|
2757
|
-
const q = quote;
|
|
2758
|
-
const orderLinkId = q.draft_order?.id ?? q.draft_order_id;
|
|
2759
|
-
const displayId = q.draft_order?.display_id;
|
|
2760
|
-
return /* @__PURE__ */ jsxs(Container, {
|
|
2761
|
-
className: "divide-y p-0",
|
|
2762
|
-
children: [
|
|
2763
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2764
|
-
className: "flex items-center justify-between px-6 py-4",
|
|
2765
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2766
|
-
className: "flex items-center gap-3",
|
|
2767
|
-
children: [/* @__PURE__ */ jsx(Heading, { children: displayId != null ? `#${displayId}` : quote.id }), /* @__PURE__ */ jsx(QuoteStatusBadge, { status: quote.status })]
|
|
2768
|
-
}), /* @__PURE__ */ jsx(QuoteActionsMenu, { quote })]
|
|
2769
|
-
}),
|
|
2770
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
2771
|
-
title: t("quotes.detail.orderChange"),
|
|
2772
|
-
value: q.order_change_id ? orderLinkId ? /* @__PURE__ */ jsx(Link$1, {
|
|
2773
|
-
to: `/orders/${orderLinkId}`,
|
|
2774
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2775
|
-
children: String(q.order_change_id)
|
|
2776
|
-
}) : String(q.order_change_id) : "—"
|
|
2777
|
-
}),
|
|
2778
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
2779
|
-
title: t("quotes.detail.cart"),
|
|
2780
|
-
value: q.cart_id ? String(q.cart_id) : "—"
|
|
2781
|
-
}),
|
|
2782
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
2783
|
-
title: t("quotes.table.messages"),
|
|
2784
|
-
value: String(Array.isArray(q.messages) ? q.messages.length : 0)
|
|
2785
|
-
}),
|
|
2786
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
2787
|
-
title: t("fields.createdAt"),
|
|
2788
|
-
value: q.created_at ? new Date(q.created_at).toLocaleDateString() : "—"
|
|
2789
|
-
}),
|
|
2790
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
2791
|
-
title: t("fields.updatedAt"),
|
|
2792
|
-
value: q.updated_at ? new Date(q.updated_at).toLocaleDateString() : "—"
|
|
2793
|
-
})
|
|
2794
|
-
]
|
|
2795
|
-
});
|
|
2796
|
-
};
|
|
2797
|
-
// src/admin/routes/b2b/quotes/[id]/components/quote-message-bubble.tsx
|
|
2798
|
-
var ItemChip = ({ item, draftOrderId }) => {
|
|
2799
|
-
const title = item?.variant?.product?.title ?? item?.title ?? `...${item?.id?.slice(-8)}`;
|
|
2800
|
-
const subtitle = item?.variant?.title && item.variant.title !== "Default Title" ? item.variant.title : null;
|
|
2801
|
-
const inner = /* @__PURE__ */ jsxs("span", {
|
|
2802
|
-
className: "flex items-center gap-1.5 px-2 py-1 rounded-md bg-ui-bg-subtle border border-ui-border-base txt-compact-xsmall text-ui-fg-subtle",
|
|
2803
|
-
children: [
|
|
2804
|
-
/* @__PURE__ */ jsx(Tag, { className: "h-3 w-3 shrink-0" }),
|
|
2805
|
-
/* @__PURE__ */ jsx("span", {
|
|
2806
|
-
className: "truncate max-w-[160px]",
|
|
2807
|
-
children: title
|
|
2808
|
-
}),
|
|
2809
|
-
subtitle && /* @__PURE__ */ jsxs("span", {
|
|
2810
|
-
className: "text-ui-fg-muted",
|
|
2811
|
-
children: ["· ", subtitle]
|
|
2812
|
-
})
|
|
2813
|
-
]
|
|
2814
|
-
});
|
|
2815
|
-
if (draftOrderId) return /* @__PURE__ */ jsx(Link$1, {
|
|
2816
|
-
to: `/orders/${draftOrderId}`,
|
|
2817
|
-
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2818
|
-
children: inner
|
|
3163
|
+
// src/admin/routes/b2b/companies/[id]/page.tsx
|
|
3164
|
+
var CompanyDetail = () => {
|
|
3165
|
+
const { id } = useParams();
|
|
3166
|
+
const { data, isLoading, isError, error } = useCompany(id);
|
|
3167
|
+
const company = data?.company;
|
|
3168
|
+
if (isLoading || !company) return /* @__PURE__ */ jsx(TwoColumnPageSkeleton, {
|
|
3169
|
+
mainSections: 2,
|
|
3170
|
+
sidebarSections: 2,
|
|
3171
|
+
showJSON: true,
|
|
3172
|
+
showMetadata: true
|
|
2819
3173
|
});
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
month: "short",
|
|
2831
|
-
day: "numeric",
|
|
2832
|
-
hour: "2-digit",
|
|
2833
|
-
minute: "2-digit"
|
|
2834
|
-
}) : null;
|
|
2835
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2836
|
-
className: `flex gap-2.5 px-4 py-2 ${isAdmin ? "flex-row-reverse" : "flex-row"}`,
|
|
2837
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2838
|
-
className: `shrink-0 h-7 w-7 rounded-full flex items-center justify-center ${isAdmin ? "bg-ui-tag-purple-bg" : "bg-ui-tag-blue-bg"}`,
|
|
2839
|
-
children: isAdmin ? /* @__PURE__ */ jsx(Buildings, { className: "h-3.5 w-3.5 text-ui-tag-purple-icon" }) : /* @__PURE__ */ jsx(User, { className: "h-3.5 w-3.5 text-ui-tag-blue-icon" })
|
|
2840
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
2841
|
-
className: `flex flex-col gap-0.5 max-w-[70%] ${isAdmin ? "items-end" : "items-start"}`,
|
|
2842
|
-
children: [
|
|
2843
|
-
/* @__PURE__ */ jsx(Link$1, {
|
|
2844
|
-
to: senderHref,
|
|
2845
|
-
className: "txt-compact-xsmall-plus text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
2846
|
-
children: senderName
|
|
2847
|
-
}),
|
|
2848
|
-
item && /* @__PURE__ */ jsx(ItemChip, {
|
|
2849
|
-
item,
|
|
2850
|
-
draftOrderId
|
|
3174
|
+
if (isError) throw error;
|
|
3175
|
+
return /* @__PURE__ */ jsx(LayoutComposer, {
|
|
3176
|
+
widgetsZonePrefix: "b2b.company.details",
|
|
3177
|
+
preferredLayoutId: CORE_LAYOUT_IDS.TWO_COLUMN,
|
|
3178
|
+
data: company,
|
|
3179
|
+
sections: {
|
|
3180
|
+
main: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3181
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3182
|
+
id: "CompanyGeneralSection",
|
|
3183
|
+
children: /* @__PURE__ */ jsx(CompanyGeneralSection, { company })
|
|
2851
3184
|
}),
|
|
2852
|
-
/* @__PURE__ */ jsx(
|
|
2853
|
-
|
|
2854
|
-
children:
|
|
3185
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3186
|
+
id: "CompanyEmployeesSection",
|
|
3187
|
+
children: /* @__PURE__ */ jsx(CompanyEmployeesSection, { companyId: company.id })
|
|
2855
3188
|
}),
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3189
|
+
detailPageDefaultEntries(company)
|
|
3190
|
+
] }),
|
|
3191
|
+
side: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3192
|
+
id: "CompanyCustomerGroupSection",
|
|
3193
|
+
children: /* @__PURE__ */ jsx(CompanyCustomerGroupSection, { company })
|
|
3194
|
+
}), /* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3195
|
+
id: "CompanyApprovalSettingsSection",
|
|
3196
|
+
children: /* @__PURE__ */ jsx(CompanyApprovalSettingsSection, { company })
|
|
3197
|
+
})] })
|
|
3198
|
+
}
|
|
2862
3199
|
});
|
|
2863
3200
|
};
|
|
2864
|
-
|
|
2865
|
-
var MessageSchema = z.object({
|
|
2866
|
-
text: z.string().min(1),
|
|
2867
|
-
item_id: z.string().nullish()
|
|
2868
|
-
});
|
|
2869
|
-
// src/admin/routes/b2b/quotes/[id]/components/quote-message-composer.tsx
|
|
2870
|
-
var QuoteMessageComposer = ({ quoteId, selectItems }) => {
|
|
3201
|
+
var Breadcrumb$1 = ({ id }) => {
|
|
2871
3202
|
const { t } = useTranslation();
|
|
2872
|
-
const
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
})
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
3203
|
+
const { data } = useCompany(id ?? "", void 0, { enabled: !!id });
|
|
3204
|
+
return data?.company?.name ?? id ?? t("companies.label");
|
|
3205
|
+
};
|
|
3206
|
+
var handle$1 = { breadcrumb: (match) => /* @__PURE__ */ jsx(Breadcrumb$1, { id: match?.params?.id }) };
|
|
3207
|
+
var GuardedCompanyDetail = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3208
|
+
permission: "b2b.read",
|
|
3209
|
+
children: /* @__PURE__ */ jsx(CompanyDetail, {})
|
|
3210
|
+
});
|
|
3211
|
+
// src/admin/routes/b2b/companies/[id]/@approval-settings/page.tsx
|
|
3212
|
+
var ApprovalSettingsContent = ({ id }) => {
|
|
3213
|
+
const { t } = useTranslation();
|
|
3214
|
+
const { handleSuccess } = useRouteModal();
|
|
3215
|
+
const { data, isLoading } = useCompany(id);
|
|
3216
|
+
const company = data?.company;
|
|
3217
|
+
const approvalSettings = company?.approval_settings;
|
|
3218
|
+
const [requiresAdminApproval, setRequiresAdminApproval] = useState(null);
|
|
3219
|
+
const [requiresSalesManagerApproval, setRequiresSalesManagerApproval] = useState(null);
|
|
3220
|
+
const { mutateAsync, isPending } = useUpdateApprovalSettings(id);
|
|
3221
|
+
if (isLoading || !company) return null;
|
|
3222
|
+
const adminValue = requiresAdminApproval ?? (approvalSettings?.requires_admin_approval || false);
|
|
3223
|
+
const salesValue = requiresSalesManagerApproval ?? (approvalSettings?.requires_sales_manager_approval || false);
|
|
3224
|
+
const handleSubmit = async () => {
|
|
3225
|
+
try {
|
|
3226
|
+
await mutateAsync({
|
|
3227
|
+
id: approvalSettings?.id,
|
|
3228
|
+
requires_admin_approval: adminValue,
|
|
3229
|
+
requires_sales_manager_approval: salesValue
|
|
3230
|
+
});
|
|
3231
|
+
toast.success(t("companies.toasts.approvalSettingsUpdated"));
|
|
3232
|
+
handleSuccess();
|
|
3233
|
+
} catch {
|
|
3234
|
+
toast.error(t("companies.toasts.approvalSettingsError"));
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(RouteDrawer.Body, {
|
|
3238
|
+
className: "flex flex-col gap-2",
|
|
3239
|
+
children: [/* @__PURE__ */ jsx(CoolSwitch, {
|
|
3240
|
+
checked: adminValue,
|
|
3241
|
+
onChange: () => setRequiresAdminApproval(!adminValue),
|
|
3242
|
+
fieldName: "requires_admin_approval",
|
|
3243
|
+
label: t("companies.approvalSettings.requiresAdmin"),
|
|
3244
|
+
description: t("companies.approvalSettings.requiresAdminDescription")
|
|
3245
|
+
}), /* @__PURE__ */ jsx(CoolSwitch, {
|
|
3246
|
+
checked: salesValue,
|
|
3247
|
+
onChange: () => setRequiresSalesManagerApproval(!salesValue),
|
|
3248
|
+
fieldName: "requires_sales_manager_approval",
|
|
3249
|
+
label: t("companies.approvalSettings.requiresSalesManager"),
|
|
3250
|
+
description: t("companies.approvalSettings.requiresSalesManagerDescription")
|
|
3251
|
+
})]
|
|
3252
|
+
}), /* @__PURE__ */ jsxs(RouteDrawer.Footer, { children: [/* @__PURE__ */ jsx(Button, {
|
|
3253
|
+
variant: "secondary",
|
|
3254
|
+
onClick: () => handleSuccess(),
|
|
3255
|
+
children: t("actions.cancel")
|
|
3256
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
3257
|
+
onClick: handleSubmit,
|
|
3258
|
+
isLoading: isPending,
|
|
3259
|
+
children: t("actions.save")
|
|
3260
|
+
})] })] });
|
|
3261
|
+
};
|
|
3262
|
+
var CompanyApprovalSettings = () => {
|
|
3263
|
+
const { t } = useTranslation();
|
|
3264
|
+
const { id } = useParams();
|
|
3265
|
+
if (!id) return null;
|
|
3266
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { children: t("companies.approvalSettings.title") }) }), /* @__PURE__ */ jsx(ApprovalSettingsContent, { id })] });
|
|
3267
|
+
};
|
|
3268
|
+
var GuardedCompanyApprovalSettings = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3269
|
+
permission: "b2b.write",
|
|
3270
|
+
children: /* @__PURE__ */ jsx(CompanyApprovalSettings, {})
|
|
3271
|
+
});
|
|
3272
|
+
// src/admin/routes/b2b/companies/[id]/@customer-group/page.tsx
|
|
3273
|
+
var CustomerGroupContent = ({ id }) => {
|
|
3274
|
+
const { t } = useTranslation();
|
|
3275
|
+
const { handleSuccess } = useRouteModal();
|
|
3276
|
+
const { data: companyData, isLoading: companyLoading } = useCompany(id);
|
|
3277
|
+
const { data: groupsData, isLoading: groupsLoading } = useQuery({
|
|
3278
|
+
queryKey: ["customer-groups"],
|
|
3279
|
+
queryFn: () => sdk.client.fetch("/admin/customer-groups")
|
|
2891
3280
|
});
|
|
2892
|
-
const
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
3281
|
+
const { mutateAsync: addMutate, isPending: addLoading } = useAddCompanyToCustomerGroup(id);
|
|
3282
|
+
const { mutateAsync: removeMutate, isPending: removeLoading } = useRemoveCompanyFromCustomerGroup(id);
|
|
3283
|
+
const company = companyData?.company;
|
|
3284
|
+
const customerGroups = groupsData?.customer_groups ?? [];
|
|
3285
|
+
const currentGroupId = company?.customer_group?.id;
|
|
3286
|
+
const employeeCount = company?.employees_count ?? 0;
|
|
3287
|
+
const handleAdd = async (groupId) => {
|
|
3288
|
+
try {
|
|
3289
|
+
await addMutate(groupId);
|
|
3290
|
+
toast.success(t("companies.customerGroup.addedSuccess"));
|
|
3291
|
+
handleSuccess();
|
|
3292
|
+
} catch {
|
|
3293
|
+
toast.error(t("companies.customerGroup.addError"));
|
|
2896
3294
|
}
|
|
2897
3295
|
};
|
|
2898
|
-
const
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
ref,
|
|
2916
|
-
children: /* @__PURE__ */ jsx(Select.Value, { placeholder: t("quotes.messages.selectItem", "Attach an item (optional)") })
|
|
2917
|
-
}), /* @__PURE__ */ jsx(Select.Content, { children: selectItems.map((item) => /* @__PURE__ */ jsx(Select.Item, {
|
|
2918
|
-
value: item.id,
|
|
2919
|
-
children: item.variant_sku ?? item.title ?? item.id
|
|
2920
|
-
}, item.id)) })]
|
|
2921
|
-
}) }) })
|
|
2922
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
2923
|
-
className: "flex items-end gap-2 rounded-2xl border border-ui-border-base bg-ui-bg-base px-3 py-2 focus-within:border-ui-border-interactive transition-colors",
|
|
2924
|
-
children: [/* @__PURE__ */ jsx(Form.Field, {
|
|
2925
|
-
control: form.control,
|
|
2926
|
-
name: "text",
|
|
2927
|
-
render: ({ field: { ref, ...field } }) => /* @__PURE__ */ jsx(Form.Item, {
|
|
2928
|
-
className: "flex-1 m-0",
|
|
2929
|
-
children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx("textarea", {
|
|
2930
|
-
...field,
|
|
2931
|
-
ref,
|
|
2932
|
-
rows: 1,
|
|
2933
|
-
placeholder: t("quotes.messages.placeholder", "Write a message…"),
|
|
2934
|
-
onKeyDown: handleKeyDown,
|
|
2935
|
-
className: "w-full resize-none bg-transparent txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted outline-hidden leading-5 max-h-32 overflow-y-auto",
|
|
2936
|
-
style: { fieldSizing: "content" }
|
|
2937
|
-
}) })
|
|
2938
|
-
})
|
|
2939
|
-
}), /* @__PURE__ */ jsx(IconButton, {
|
|
2940
|
-
type: "submit",
|
|
2941
|
-
size: "small",
|
|
2942
|
-
variant: "transparent",
|
|
2943
|
-
disabled: !textValue?.trim() || isSending,
|
|
2944
|
-
className: `shrink-0 transition-colors ${textValue?.trim() ? "text-ui-fg-interactive hover:text-ui-fg-interactive-hover" : "text-ui-fg-disabled"}`,
|
|
2945
|
-
children: /* @__PURE__ */ jsx(PaperPlane, {})
|
|
2946
|
-
})]
|
|
2947
|
-
})]
|
|
3296
|
+
const handleRemove = async (groupId) => {
|
|
3297
|
+
try {
|
|
3298
|
+
await removeMutate(groupId);
|
|
3299
|
+
toast.success(t("companies.customerGroup.removedSuccess"));
|
|
3300
|
+
} catch {
|
|
3301
|
+
toast.error(t("companies.customerGroup.removeError"));
|
|
3302
|
+
}
|
|
3303
|
+
};
|
|
3304
|
+
if (companyLoading || groupsLoading || !company) return null;
|
|
3305
|
+
return /* @__PURE__ */ jsxs(RouteDrawer.Body, {
|
|
3306
|
+
className: "space-y-4 h-full overflow-y-hidden",
|
|
3307
|
+
children: [/* @__PURE__ */ jsx(Hint, {
|
|
3308
|
+
variant: "info",
|
|
3309
|
+
children: t("companies.customerGroup.hint", {
|
|
3310
|
+
name: company.name,
|
|
3311
|
+
count: employeeCount,
|
|
3312
|
+
plural: employeeCount === 1 ? "" : "s"
|
|
2948
3313
|
})
|
|
2949
|
-
})
|
|
3314
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3315
|
+
className: "h-full overflow-y-auto",
|
|
3316
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(Table.Header, { children: /* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.HeaderCell, { children: t("companies.customerGroup.header") }), /* @__PURE__ */ jsx(Table.HeaderCell, {
|
|
3317
|
+
className: "text-right",
|
|
3318
|
+
children: t("companies.customerGroup.actionsHeader")
|
|
3319
|
+
})] }) }), /* @__PURE__ */ jsx(Table.Body, { children: customerGroups.length ? customerGroups.map((group) => {
|
|
3320
|
+
const isLinked = currentGroupId === group.id;
|
|
3321
|
+
const isOtherLinked = !!currentGroupId && !isLinked;
|
|
3322
|
+
return /* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, { children: group.name }), /* @__PURE__ */ jsx(Table.Cell, {
|
|
3323
|
+
className: "text-right",
|
|
3324
|
+
children: isLinked ? /* @__PURE__ */ jsx(Button, {
|
|
3325
|
+
size: "small",
|
|
3326
|
+
variant: "danger",
|
|
3327
|
+
isLoading: removeLoading,
|
|
3328
|
+
onClick: () => handleRemove(group.id),
|
|
3329
|
+
children: t("companies.customerGroup.remove")
|
|
3330
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
3331
|
+
size: "small",
|
|
3332
|
+
disabled: isOtherLinked || addLoading,
|
|
3333
|
+
isLoading: addLoading,
|
|
3334
|
+
onClick: () => handleAdd(group.id),
|
|
3335
|
+
children: t("companies.customerGroup.add")
|
|
3336
|
+
})
|
|
3337
|
+
})] }, group.id);
|
|
3338
|
+
}) : /* @__PURE__ */ jsx(Table.Row, { children: /* @__PURE__ */ jsx(Table.Cell, { children: t("companies.customerGroup.noGroups") }) }) })] })
|
|
3339
|
+
})]
|
|
2950
3340
|
});
|
|
2951
3341
|
};
|
|
2952
|
-
|
|
2953
|
-
|
|
3342
|
+
var CompanyCustomerGroup = () => {
|
|
3343
|
+
const { t } = useTranslation();
|
|
2954
3344
|
const { id } = useParams();
|
|
3345
|
+
const { data } = useCompany(id ?? "", void 0, { enabled: !!id });
|
|
3346
|
+
if (!id) return null;
|
|
3347
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { children: t("companies.customerGroup.drawerTitle", { name: data?.company?.name ?? "" }) }) }), /* @__PURE__ */ jsx(CustomerGroupContent, { id })] });
|
|
3348
|
+
};
|
|
3349
|
+
var GuardedCompanyCustomerGroup = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3350
|
+
permission: "b2b.write",
|
|
3351
|
+
children: /* @__PURE__ */ jsx(CompanyCustomerGroup, {})
|
|
3352
|
+
});
|
|
3353
|
+
// src/admin/routes/b2b/companies/[id]/@edit/page.tsx
|
|
3354
|
+
var EditContent = ({ id }) => {
|
|
2955
3355
|
const { t } = useTranslation();
|
|
2956
|
-
const
|
|
2957
|
-
const
|
|
2958
|
-
const
|
|
2959
|
-
const
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
children: [
|
|
2978
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2979
|
-
className: "flex items-center justify-between px-6 py-4",
|
|
2980
|
-
children: [/* @__PURE__ */ jsx(Heading, {
|
|
2981
|
-
level: "h2",
|
|
2982
|
-
children: t("quotes.messages.title", "Messages")
|
|
2983
|
-
}), /* @__PURE__ */ jsx(Badge, {
|
|
2984
|
-
size: "xsmall",
|
|
2985
|
-
color: "grey",
|
|
2986
|
-
children: messages.length
|
|
2987
|
-
})]
|
|
2988
|
-
}),
|
|
2989
|
-
/* @__PURE__ */ jsx("div", {
|
|
2990
|
-
ref: scrollRef,
|
|
2991
|
-
className: "flex flex-col py-2 overflow-y-auto",
|
|
2992
|
-
style: {
|
|
2993
|
-
maxHeight: "400px",
|
|
2994
|
-
minHeight: sorted.length === 0 ? "80px" : void 0
|
|
3356
|
+
const { handleSuccess } = useRouteModal();
|
|
3357
|
+
const { data, isLoading } = useCompany(id);
|
|
3358
|
+
const { mutateAsync, isPending } = useUpdateCompany(id);
|
|
3359
|
+
const handleSubmit = async (formData) => {
|
|
3360
|
+
const payload = {
|
|
3361
|
+
...formData,
|
|
3362
|
+
phone: formData.phone || null,
|
|
3363
|
+
address: formData.address || null,
|
|
3364
|
+
city: formData.city || null,
|
|
3365
|
+
state: formData.state || null,
|
|
3366
|
+
zip: formData.zip || null,
|
|
3367
|
+
country: formData.country || null,
|
|
3368
|
+
logo_url: formData.logo_url || null,
|
|
3369
|
+
spending_limit_reset_at: formData.spending_limit_reset_at ? new Date(formData.spending_limit_reset_at).toISOString() : null
|
|
3370
|
+
};
|
|
3371
|
+
try {
|
|
3372
|
+
await mutateAsync(payload, {
|
|
3373
|
+
onSuccess: (result) => {
|
|
3374
|
+
const name = result.company?.name ?? "";
|
|
3375
|
+
toast.success(t("companies.toasts.updated", { name }));
|
|
3376
|
+
handleSuccess();
|
|
2995
3377
|
},
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
}) : sorted.map((msg) => /* @__PURE__ */ jsx(MessageBubble, {
|
|
3000
|
-
message: msg,
|
|
3001
|
-
item: msg.item_id ? itemsById.get(msg.item_id) : void 0,
|
|
3002
|
-
draftOrderId,
|
|
3003
|
-
customerFallback: customerById.get(msg.customer_id)
|
|
3004
|
-
}, msg.id))
|
|
3005
|
-
}),
|
|
3006
|
-
/* @__PURE__ */ jsx(QuoteMessageComposer, {
|
|
3007
|
-
quoteId: id,
|
|
3008
|
-
selectItems
|
|
3009
|
-
})
|
|
3010
|
-
]
|
|
3011
|
-
});
|
|
3012
|
-
};
|
|
3013
|
-
// src/admin/routes/b2b/quotes/[id]/components/quote-order-section.tsx
|
|
3014
|
-
var ORDER_STATUS_COLOR = {
|
|
3015
|
-
completed: "green",
|
|
3016
|
-
pending: "orange",
|
|
3017
|
-
requires_action: "orange",
|
|
3018
|
-
draft: "grey",
|
|
3019
|
-
archived: "grey",
|
|
3020
|
-
cancelled: "red"
|
|
3021
|
-
};
|
|
3022
|
-
var QuoteOrderSection = ({ quote }) => {
|
|
3023
|
-
const { t } = useTranslation();
|
|
3024
|
-
const q = quote;
|
|
3025
|
-
const draftOrder = q.draft_order;
|
|
3026
|
-
const draftOrderId = q.draft_order_id;
|
|
3027
|
-
const OrderStatusBadge = ({ status }) => {
|
|
3028
|
-
if (!status) return /* @__PURE__ */ jsx("span", {
|
|
3029
|
-
className: "txt-compact-small text-ui-fg-subtle",
|
|
3030
|
-
children: "—"
|
|
3031
|
-
});
|
|
3032
|
-
const color = ORDER_STATUS_COLOR[status] ?? "grey";
|
|
3033
|
-
return /* @__PURE__ */ jsx(Badge, {
|
|
3034
|
-
size: "2xsmall",
|
|
3035
|
-
color,
|
|
3036
|
-
children: t(`quotes.orderStatus.${status}`, { defaultValue: status.replace(/_/g, " ") })
|
|
3037
|
-
});
|
|
3378
|
+
onError: (err) => toast.error(err.message)
|
|
3379
|
+
});
|
|
3380
|
+
} catch {}
|
|
3038
3381
|
};
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
})
|
|
3060
|
-
}),
|
|
3061
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3062
|
-
title: t("fields.status"),
|
|
3063
|
-
value: /* @__PURE__ */ jsx(OrderStatusBadge, { status: draftOrder.status })
|
|
3064
|
-
}),
|
|
3065
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3066
|
-
title: t("fields.total"),
|
|
3067
|
-
value: draftOrder.total != null && draftOrder.currency_code ? formatCurrency(draftOrder.total / 100, draftOrder.currency_code) : "—"
|
|
3068
|
-
}),
|
|
3069
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3070
|
-
title: t("fields.createdAt"),
|
|
3071
|
-
value: draftOrder.created_at ? new Date(draftOrder.created_at).toLocaleDateString() : "—"
|
|
3072
|
-
})
|
|
3073
|
-
] }) : draftOrderId ? /* @__PURE__ */ jsx(SectionRow, {
|
|
3074
|
-
title: t("fields.id"),
|
|
3075
|
-
value: /* @__PURE__ */ jsx(Link$1, {
|
|
3076
|
-
to: `/orders/${draftOrderId}`,
|
|
3077
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3078
|
-
children: draftOrderId
|
|
3079
|
-
})
|
|
3080
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
3081
|
-
className: "px-6 py-4 txt-compact-small text-ui-fg-subtle",
|
|
3082
|
-
children: t("quotes.detail.noDraftOrder")
|
|
3083
|
-
})]
|
|
3382
|
+
const company = data?.company;
|
|
3383
|
+
if (isLoading || !company) return null;
|
|
3384
|
+
return /* @__PURE__ */ jsx(CompanyForm, {
|
|
3385
|
+
mode: "update",
|
|
3386
|
+
company: {
|
|
3387
|
+
name: company.name,
|
|
3388
|
+
email: company.email,
|
|
3389
|
+
currency_code: company.currency_code,
|
|
3390
|
+
phone: company.phone,
|
|
3391
|
+
address: company.address,
|
|
3392
|
+
city: company.city,
|
|
3393
|
+
state: company.state,
|
|
3394
|
+
zip: company.zip,
|
|
3395
|
+
country: company.country,
|
|
3396
|
+
logo_url: company.logo_url,
|
|
3397
|
+
spending_limit_reset_frequency: company.spending_limit_reset_frequency ?? null,
|
|
3398
|
+
spending_limit_reset_at: company.spending_limit_reset_at ?? null
|
|
3399
|
+
},
|
|
3400
|
+
onSubmit: handleSubmit,
|
|
3401
|
+
loading: isPending
|
|
3084
3402
|
});
|
|
3085
3403
|
};
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
var QuoteDetail = () => {
|
|
3404
|
+
var CompanyEdit = () => {
|
|
3405
|
+
const { t } = useTranslation();
|
|
3089
3406
|
const { id } = useParams();
|
|
3407
|
+
if (!id) return null;
|
|
3408
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(Heading, { children: t("companies.form.editTitle") }) }), /* @__PURE__ */ jsx(EditContent, { id })] });
|
|
3409
|
+
};
|
|
3410
|
+
var GuardedCompanyEdit = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3411
|
+
permission: "b2b.write",
|
|
3412
|
+
children: /* @__PURE__ */ jsx(CompanyEdit, {})
|
|
3413
|
+
});
|
|
3414
|
+
// src/admin/routes/b2b/companies/[id]/@employee/[employeeId]/page.tsx
|
|
3415
|
+
var UpdateContent = () => {
|
|
3090
3416
|
const { t } = useTranslation();
|
|
3091
|
-
const
|
|
3092
|
-
const
|
|
3093
|
-
const
|
|
3094
|
-
const {
|
|
3095
|
-
const { mutateAsync
|
|
3096
|
-
|
|
3097
|
-
const
|
|
3098
|
-
const
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
"total",
|
|
3102
|
-
"discount_total",
|
|
3103
|
-
"summary",
|
|
3104
|
-
"*shipping_methods",
|
|
3105
|
-
"*items",
|
|
3106
|
-
"*items.variant",
|
|
3107
|
-
"*items.variant.product",
|
|
3108
|
-
"*items.actions",
|
|
3109
|
-
"*items.detail"
|
|
3110
|
-
].join(",") }, { enabled: !!draftOrderId });
|
|
3111
|
-
const order = orderPreview ? {
|
|
3112
|
-
...orderPreview,
|
|
3113
|
-
currency_code: orderPreview.currency_code ?? draftOrderCurrencyCode
|
|
3114
|
-
} : orderPreview;
|
|
3115
|
-
if (isPending || !quote) return /* @__PURE__ */ jsx(TwoColumnPageSkeleton, {
|
|
3116
|
-
mainSections: 3,
|
|
3117
|
-
sidebarSections: 2
|
|
3118
|
-
});
|
|
3119
|
-
if (isError) throw error;
|
|
3120
|
-
const canSend = [EQuoteStatus.PendingMerchant, EQuoteStatus.CustomerRejected].includes(quote.status);
|
|
3121
|
-
const canReject = [EQuoteStatus.PendingMerchant, EQuoteStatus.PendingCustomer].includes(quote.status);
|
|
3122
|
-
const isAccepted = quote.status === EQuoteStatus.Accepted;
|
|
3123
|
-
const handleSendConfirm = async (expiresAt) => {
|
|
3417
|
+
const { id, employeeId } = useParams();
|
|
3418
|
+
const { handleSuccess } = useRouteModal();
|
|
3419
|
+
const { data: companyData, isLoading: companyLoading } = useCompany(id);
|
|
3420
|
+
const { data: employeeData, isLoading: employeeLoading } = useEmployee(id, employeeId);
|
|
3421
|
+
const { mutateAsync, isPending, error } = useUpdateEmployee(id, employeeId);
|
|
3422
|
+
if (companyLoading || employeeLoading) return null;
|
|
3423
|
+
const company = companyData?.company;
|
|
3424
|
+
const employee = employeeData?.employee;
|
|
3425
|
+
if (!company || !employee) return null;
|
|
3426
|
+
const handleSubmit = async (formData) => {
|
|
3124
3427
|
try {
|
|
3125
|
-
await
|
|
3428
|
+
await mutateAsync({
|
|
3429
|
+
...formData,
|
|
3430
|
+
id: employeeId
|
|
3431
|
+
}, {
|
|
3126
3432
|
onSuccess: () => {
|
|
3127
|
-
|
|
3128
|
-
|
|
3433
|
+
toast.success(t("employees.toasts.updated", { email: employee?.customer?.email }));
|
|
3434
|
+
handleSuccess();
|
|
3129
3435
|
},
|
|
3130
3436
|
onError: (err) => toast.error(err.message)
|
|
3131
3437
|
});
|
|
3132
3438
|
} catch {}
|
|
3133
3439
|
};
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
onSuccess: () => toast.success(t("quotes.toasts.rejected")),
|
|
3144
|
-
onError: (err) => toast.error(err.message)
|
|
3145
|
-
});
|
|
3146
|
-
} catch {}
|
|
3147
|
-
};
|
|
3148
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3149
|
-
className: "flex flex-col gap-4",
|
|
3150
|
-
children: [
|
|
3151
|
-
/* @__PURE__ */ jsx(QuoteDetailActions, {
|
|
3152
|
-
canSend,
|
|
3153
|
-
canReject,
|
|
3154
|
-
isAccepted,
|
|
3155
|
-
draftOrderId,
|
|
3156
|
-
isSending,
|
|
3157
|
-
isRejecting,
|
|
3158
|
-
onViewOrder: () => navigate(`/orders/${draftOrderId}`),
|
|
3159
|
-
onReject: handleReject,
|
|
3160
|
-
onOpenSendDrawer: () => setSendDrawerOpen(true)
|
|
3161
|
-
}),
|
|
3162
|
-
/* @__PURE__ */ jsx(LayoutComposer, {
|
|
3163
|
-
widgetsZonePrefix: "b2b.quote.details",
|
|
3164
|
-
preferredLayoutId: CORE_LAYOUT_IDS.TWO_COLUMN,
|
|
3165
|
-
data: quote,
|
|
3166
|
-
sections: {
|
|
3167
|
-
main: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3168
|
-
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3169
|
-
id: "QuoteGeneralSection",
|
|
3170
|
-
children: /* @__PURE__ */ jsx(QuoteGeneralSection, { quote })
|
|
3171
|
-
}),
|
|
3172
|
-
order && !isPreviewPending && /* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3173
|
-
id: "QuoteOrderSummarySection",
|
|
3174
|
-
children: /* @__PURE__ */ jsx(OrderSummarySection, {
|
|
3175
|
-
order,
|
|
3176
|
-
plugins: [],
|
|
3177
|
-
readOnly: true
|
|
3178
|
-
})
|
|
3179
|
-
}),
|
|
3180
|
-
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3181
|
-
id: "QuoteMessagesSection",
|
|
3182
|
-
children: /* @__PURE__ */ jsx(QuoteMessagesSection, {
|
|
3183
|
-
quote,
|
|
3184
|
-
preview: order
|
|
3185
|
-
})
|
|
3186
|
-
}),
|
|
3187
|
-
isAccepted && /* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3188
|
-
id: "QuoteAcceptedMessage",
|
|
3189
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
3190
|
-
className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle px-6 py-4",
|
|
3191
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
3192
|
-
size: "small",
|
|
3193
|
-
children: t("quotes.detail.acceptedMessage")
|
|
3194
|
-
})
|
|
3195
|
-
})
|
|
3196
|
-
}),
|
|
3197
|
-
detailPageDefaultEntries(quote)
|
|
3198
|
-
] }),
|
|
3199
|
-
side: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3200
|
-
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3201
|
-
id: "QuoteCustomerSection",
|
|
3202
|
-
children: /* @__PURE__ */ jsx(QuoteCustomerSection, { quote })
|
|
3203
|
-
}),
|
|
3204
|
-
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3205
|
-
id: "QuoteCompanySection",
|
|
3206
|
-
children: /* @__PURE__ */ jsx(QuoteCompanySection, { quote })
|
|
3207
|
-
}),
|
|
3208
|
-
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
3209
|
-
id: "QuoteOrderSection",
|
|
3210
|
-
children: /* @__PURE__ */ jsx(QuoteOrderSection, { quote })
|
|
3211
|
-
})
|
|
3212
|
-
] })
|
|
3213
|
-
}
|
|
3214
|
-
}),
|
|
3215
|
-
/* @__PURE__ */ jsx(SendQuoteDrawer, {
|
|
3216
|
-
open: sendDrawerOpen,
|
|
3217
|
-
onClose: () => setSendDrawerOpen(false),
|
|
3218
|
-
onConfirm: handleSendConfirm,
|
|
3219
|
-
isPending: isSending
|
|
3220
|
-
})
|
|
3221
|
-
]
|
|
3222
|
-
});
|
|
3223
|
-
};
|
|
3224
|
-
var Breadcrumb$1 = ({ id }) => {
|
|
3225
|
-
const { t } = useTranslation();
|
|
3226
|
-
const { quote } = useQuote(id ?? "", void 0, { enabled: !!id });
|
|
3227
|
-
const displayId = quote?.draft_order?.display_id;
|
|
3228
|
-
return displayId != null ? `#${displayId}` : id ?? t("quote.title");
|
|
3229
|
-
};
|
|
3230
|
-
var handle$1 = { breadcrumb: (match) => /* @__PURE__ */ jsx(Breadcrumb$1, { id: match?.params?.id }) };
|
|
3231
|
-
var GuardedQuoteDetail = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3232
|
-
permission: "b2b.read",
|
|
3233
|
-
children: /* @__PURE__ */ jsx(QuoteDetail, {})
|
|
3234
|
-
});
|
|
3235
|
-
// src/admin/routes/b2b/companies/[id]/components/company-general-section.tsx
|
|
3236
|
-
var CompanyGeneralSection = ({ company }) => {
|
|
3237
|
-
const { t } = useTranslation();
|
|
3238
|
-
const c = company;
|
|
3239
|
-
return /* @__PURE__ */ jsxs(Container, {
|
|
3240
|
-
className: "divide-y p-0",
|
|
3241
|
-
children: [
|
|
3242
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3243
|
-
className: "flex items-center justify-between px-6 py-4",
|
|
3244
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3245
|
-
className: "flex items-center gap-x-3",
|
|
3246
|
-
children: [/* @__PURE__ */ jsx(Thumbnail, { src: c.logo_url }), /* @__PURE__ */ jsx(Heading, { children: c.name })]
|
|
3247
|
-
}), /* @__PURE__ */ jsx(CompanyActionsMenu, { company })]
|
|
3248
|
-
}),
|
|
3249
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3250
|
-
title: t("companies.detail.email"),
|
|
3251
|
-
value: c.email || "—"
|
|
3252
|
-
}),
|
|
3253
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3254
|
-
title: t("companies.detail.phone"),
|
|
3255
|
-
value: c.phone || "—"
|
|
3256
|
-
}),
|
|
3257
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3258
|
-
title: t("companies.detail.address"),
|
|
3259
|
-
value: c.address || "—"
|
|
3260
|
-
}),
|
|
3261
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3262
|
-
title: t("companies.detail.city"),
|
|
3263
|
-
value: c.city || "—"
|
|
3264
|
-
}),
|
|
3265
|
-
/* @__PURE__ */ jsx(SectionRow, {
|
|
3266
|
-
title: t("companies.detail.state"),
|
|
3267
|
-
value: c.state || "—"
|
|
3268
|
-
}),
|
|
3269
|
-
c.currency_code && /* @__PURE__ */ jsx(SectionRow, {
|
|
3270
|
-
title: t("companies.detail.currency"),
|
|
3271
|
-
value: /* @__PURE__ */ jsx(Badge, {
|
|
3272
|
-
size: "xsmall",
|
|
3273
|
-
color: "grey",
|
|
3274
|
-
children: c.currency_code.toUpperCase()
|
|
3275
|
-
})
|
|
3276
|
-
}),
|
|
3277
|
-
c.spending_limit_reset_frequency && /* @__PURE__ */ jsx(SectionRow, {
|
|
3278
|
-
title: t("companies.detail.spendingLimitResetFrequency"),
|
|
3279
|
-
value: c.spending_limit_reset_frequency
|
|
3280
|
-
}),
|
|
3281
|
-
c.spending_limit_reset_at && /* @__PURE__ */ jsx(SectionRow, {
|
|
3282
|
-
title: t("companies.detail.spendingLimitResetAt"),
|
|
3283
|
-
value: new Date(c.spending_limit_reset_at).toLocaleDateString()
|
|
3284
|
-
})
|
|
3285
|
-
]
|
|
3286
|
-
});
|
|
3287
|
-
};
|
|
3288
|
-
// src/admin/routes/b2b/companies/[id]/@employee/components/employees-actions-menu.tsx
|
|
3289
|
-
var EmployeesActionsMenu = ({ employee }) => {
|
|
3290
|
-
const { t } = useTranslation();
|
|
3291
|
-
const prompt = usePrompt();
|
|
3292
|
-
const { mutateAsync: deleteEmployee, isPending: isDeleting } = useDeleteEmployee(employee.company_id);
|
|
3293
|
-
const handleDelete = async () => {
|
|
3294
|
-
if (!await prompt({
|
|
3295
|
-
title: t("employees.prompts.delete.title"),
|
|
3296
|
-
description: t("employees.prompts.delete.description"),
|
|
3297
|
-
confirmText: t("actions.delete"),
|
|
3298
|
-
cancelText: t("actions.cancel")
|
|
3299
|
-
})) return;
|
|
3300
|
-
try {
|
|
3301
|
-
await deleteEmployee(employee.id, {
|
|
3302
|
-
onSuccess: () => toast.success(t("employees.toasts.deleted")),
|
|
3303
|
-
onError: (err) => toast.error(err.message)
|
|
3304
|
-
});
|
|
3305
|
-
} catch {}
|
|
3306
|
-
};
|
|
3307
|
-
return /* @__PURE__ */ jsx(ActionMenu, { groups: [{ actions: [{
|
|
3308
|
-
label: t("actions.edit"),
|
|
3309
|
-
to: `/b2b/companies/${employee.company_id}/employee/${employee.id}`,
|
|
3310
|
-
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
3311
|
-
}] }, { actions: [{
|
|
3312
|
-
label: t("actions.delete"),
|
|
3313
|
-
onClick: handleDelete,
|
|
3314
|
-
disabled: isDeleting,
|
|
3315
|
-
icon: /* @__PURE__ */ jsx(Trash, {})
|
|
3316
|
-
}] }] });
|
|
3317
|
-
};
|
|
3318
|
-
// src/admin/routes/b2b/companies/[id]/@employee/components/validators.ts
|
|
3319
|
-
var makeEmployeeCreateFormSchema = () => z.object({
|
|
3320
|
-
first_name: z.string().optional().or(z.literal("")),
|
|
3321
|
-
last_name: z.string().optional().or(z.literal("")),
|
|
3322
|
-
email: z.email(),
|
|
3323
|
-
phone: z.string().optional().or(z.literal("")),
|
|
3324
|
-
spending_limit: z.string().optional(),
|
|
3325
|
-
is_admin: z.boolean()
|
|
3326
|
-
});
|
|
3327
|
-
var makeEmployeeUpdateFormSchema = () => z.object({
|
|
3328
|
-
spending_limit: z.string().optional(),
|
|
3329
|
-
is_admin: z.boolean()
|
|
3330
|
-
});
|
|
3331
|
-
// src/admin/routes/b2b/companies/[id]/@employee/components/employees-create-form.tsx
|
|
3332
|
-
function EmployeesCreateForm({ handleSubmit, loading, error, company }) {
|
|
3333
|
-
const { t } = useTranslation();
|
|
3334
|
-
const form = useForm({
|
|
3335
|
-
resolver: zodResolver(makeEmployeeCreateFormSchema()),
|
|
3336
|
-
defaultValues: {
|
|
3337
|
-
first_name: "",
|
|
3338
|
-
last_name: "",
|
|
3339
|
-
email: "",
|
|
3340
|
-
phone: "",
|
|
3341
|
-
spending_limit: "0",
|
|
3342
|
-
is_admin: false
|
|
3343
|
-
}
|
|
3344
|
-
});
|
|
3345
|
-
const currencyKey = company.currency_code || "USD";
|
|
3346
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, {
|
|
3347
|
-
form,
|
|
3348
|
-
children: /* @__PURE__ */ jsxs(KeyboundForm, {
|
|
3349
|
-
onSubmit: form.handleSubmit((data) => handleSubmit({
|
|
3350
|
-
...data,
|
|
3351
|
-
company_id: company.id,
|
|
3352
|
-
customer_id: "",
|
|
3353
|
-
spending_limit: data.spending_limit ? parseInt(data.spending_limit, 10) : 0
|
|
3354
|
-
})),
|
|
3355
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
3356
|
-
children: [/* @__PURE__ */ jsxs(RouteDrawer.Body, {
|
|
3357
|
-
className: "flex flex-1 flex-col gap-y-6 overflow-auto p-4",
|
|
3358
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3359
|
-
className: "flex flex-col gap-y-4",
|
|
3360
|
-
children: [
|
|
3361
|
-
/* @__PURE__ */ jsx("h2", {
|
|
3362
|
-
className: "h2-core",
|
|
3363
|
-
children: t("employees.form.details")
|
|
3364
|
-
}),
|
|
3365
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3366
|
-
control: form.control,
|
|
3367
|
-
name: "first_name",
|
|
3368
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
3369
|
-
/* @__PURE__ */ jsx(Form.Label, {
|
|
3370
|
-
optional: true,
|
|
3371
|
-
children: t("employees.form.firstName")
|
|
3372
|
-
}),
|
|
3373
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
3374
|
-
placeholder: "John",
|
|
3375
|
-
...field
|
|
3376
|
-
}) }),
|
|
3377
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
3378
|
-
] })
|
|
3379
|
-
}),
|
|
3380
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3381
|
-
control: form.control,
|
|
3382
|
-
name: "last_name",
|
|
3383
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
3384
|
-
/* @__PURE__ */ jsx(Form.Label, {
|
|
3385
|
-
optional: true,
|
|
3386
|
-
children: t("employees.form.lastName")
|
|
3387
|
-
}),
|
|
3388
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
3389
|
-
placeholder: "Doe",
|
|
3390
|
-
...field
|
|
3391
|
-
}) }),
|
|
3392
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
3393
|
-
] })
|
|
3394
|
-
}),
|
|
3395
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3396
|
-
control: form.control,
|
|
3397
|
-
name: "email",
|
|
3398
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
3399
|
-
/* @__PURE__ */ jsx(Form.Label, { children: t("employees.form.email") }),
|
|
3400
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
3401
|
-
type: "email",
|
|
3402
|
-
placeholder: "john.doe@example.com",
|
|
3403
|
-
...field
|
|
3404
|
-
}) }),
|
|
3405
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
3406
|
-
] })
|
|
3407
|
-
}),
|
|
3408
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3409
|
-
control: form.control,
|
|
3410
|
-
name: "phone",
|
|
3411
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
3412
|
-
/* @__PURE__ */ jsx(Form.Label, {
|
|
3413
|
-
optional: true,
|
|
3414
|
-
children: t("employees.form.phone")
|
|
3415
|
-
}),
|
|
3416
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, {
|
|
3417
|
-
placeholder: "0612345678",
|
|
3418
|
-
...field
|
|
3419
|
-
}) }),
|
|
3420
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
3421
|
-
] })
|
|
3422
|
-
})
|
|
3423
|
-
]
|
|
3424
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3425
|
-
className: "flex flex-col gap-y-4",
|
|
3426
|
-
children: [
|
|
3427
|
-
/* @__PURE__ */ jsx("h2", {
|
|
3428
|
-
className: "h2-core",
|
|
3429
|
-
children: t("employees.form.permissions")
|
|
3430
|
-
}),
|
|
3431
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3432
|
-
control: form.control,
|
|
3433
|
-
name: "spending_limit",
|
|
3434
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
3435
|
-
/* @__PURE__ */ jsx(Form.Label, {
|
|
3436
|
-
optional: true,
|
|
3437
|
-
children: t("employees.form.spendingLimit", { currency: company.currency_code?.toUpperCase() || "USD" })
|
|
3438
|
-
}),
|
|
3439
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CurrencyInput, {
|
|
3440
|
-
symbol: getCurrencySymbol(currencyKey),
|
|
3441
|
-
code: company.currency_code || "USD",
|
|
3442
|
-
placeholder: "1000",
|
|
3443
|
-
value: field.value ?? "",
|
|
3444
|
-
onChange: (e) => field.onChange(e.target.value.replace(/[^0-9]/g, ""))
|
|
3445
|
-
}) }),
|
|
3446
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
3447
|
-
] })
|
|
3448
|
-
}),
|
|
3449
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3450
|
-
control: form.control,
|
|
3451
|
-
name: "is_admin",
|
|
3452
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [/* @__PURE__ */ jsx(Form.Label, {
|
|
3453
|
-
optional: true,
|
|
3454
|
-
children: t("employees.form.adminAccess")
|
|
3455
|
-
}), /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CoolSwitch, {
|
|
3456
|
-
fieldName: "is_admin",
|
|
3457
|
-
label: t("employees.form.isAdmin"),
|
|
3458
|
-
description: t("employees.form.isAdminDescription"),
|
|
3459
|
-
checked: field.value,
|
|
3460
|
-
onChange: field.onChange,
|
|
3461
|
-
tooltip: t("employees.form.isAdminTooltip")
|
|
3462
|
-
}) })] })
|
|
3463
|
-
})
|
|
3464
|
-
]
|
|
3465
|
-
})]
|
|
3466
|
-
}), /* @__PURE__ */ jsxs(RouteDrawer.Footer, { children: [
|
|
3467
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, {
|
|
3468
|
-
asChild: true,
|
|
3469
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
3470
|
-
variant: "secondary",
|
|
3471
|
-
children: t("actions.cancel")
|
|
3472
|
-
})
|
|
3473
|
-
}),
|
|
3474
|
-
/* @__PURE__ */ jsx(Button, {
|
|
3475
|
-
type: "submit",
|
|
3476
|
-
isLoading: loading,
|
|
3477
|
-
children: t("actions.save")
|
|
3478
|
-
}),
|
|
3479
|
-
error && /* @__PURE__ */ jsx(Text, {
|
|
3480
|
-
className: "text-ui-fg-error",
|
|
3481
|
-
children: error.message
|
|
3482
|
-
})
|
|
3483
|
-
] })]
|
|
3484
|
-
})
|
|
3485
|
-
});
|
|
3486
|
-
}
|
|
3487
|
-
// src/admin/routes/b2b/companies/[id]/@employee/components/employees-update-form.tsx
|
|
3488
|
-
function EmployeesUpdateForm({ company, employee, handleSubmit, loading, error }) {
|
|
3489
|
-
const { t } = useTranslation();
|
|
3490
|
-
const form = useForm({
|
|
3491
|
-
resolver: zodResolver(makeEmployeeUpdateFormSchema()),
|
|
3492
|
-
defaultValues: {
|
|
3493
|
-
spending_limit: employee?.spending_limit?.toString() ?? "0",
|
|
3494
|
-
is_admin: employee?.is_admin ?? false
|
|
3495
|
-
}
|
|
3496
|
-
});
|
|
3497
|
-
const currencyKey = company.currency_code || "USD";
|
|
3498
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, {
|
|
3499
|
-
form,
|
|
3500
|
-
children: /* @__PURE__ */ jsxs(KeyboundForm, {
|
|
3501
|
-
onSubmit: form.handleSubmit((data) => handleSubmit({
|
|
3502
|
-
spending_limit: data.spending_limit ? Number(data.spending_limit) : void 0,
|
|
3503
|
-
is_admin: data.is_admin
|
|
3504
|
-
})),
|
|
3505
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
3506
|
-
children: [/* @__PURE__ */ jsxs(RouteDrawer.Body, {
|
|
3507
|
-
className: "flex flex-1 flex-col gap-y-6 overflow-auto p-4",
|
|
3508
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3509
|
-
className: "flex flex-col gap-y-4",
|
|
3510
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3511
|
-
className: "flex items-center justify-between",
|
|
3512
|
-
children: [/* @__PURE__ */ jsx("h2", {
|
|
3513
|
-
className: "h2-core",
|
|
3514
|
-
children: t("employees.form.details")
|
|
3515
|
-
}), /* @__PURE__ */ jsx("a", {
|
|
3516
|
-
href: `/app/customers/${employee?.customer?.id}/edit`,
|
|
3517
|
-
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover",
|
|
3518
|
-
children: t("employees.form.editCustomerDetails")
|
|
3519
|
-
})]
|
|
3520
|
-
}), /* @__PURE__ */ jsx(Container, {
|
|
3521
|
-
className: "p-0 overflow-hidden",
|
|
3522
|
-
children: /* @__PURE__ */ jsx(Table, { children: /* @__PURE__ */ jsxs(Table.Body, { children: [
|
|
3523
|
-
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
3524
|
-
className: "font-medium font-sans txt-compact-small",
|
|
3525
|
-
children: t("employees.form.name")
|
|
3526
|
-
}), /* @__PURE__ */ jsxs(Table.Cell, { children: [
|
|
3527
|
-
employee?.customer?.first_name,
|
|
3528
|
-
" ",
|
|
3529
|
-
employee?.customer?.last_name
|
|
3530
|
-
] })] }),
|
|
3531
|
-
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
3532
|
-
className: "font-medium font-sans txt-compact-small",
|
|
3533
|
-
children: t("employees.form.email")
|
|
3534
|
-
}), /* @__PURE__ */ jsx(Table.Cell, { children: employee?.customer?.email })] }),
|
|
3535
|
-
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
3536
|
-
className: "font-medium font-sans txt-compact-small",
|
|
3537
|
-
children: t("employees.form.phone")
|
|
3538
|
-
}), /* @__PURE__ */ jsx(Table.Cell, { children: employee?.customer?.phone ?? "—" })] }),
|
|
3539
|
-
/* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, {
|
|
3540
|
-
className: "font-medium font-sans txt-compact-small",
|
|
3541
|
-
children: t("employees.form.company")
|
|
3542
|
-
}), /* @__PURE__ */ jsx(Table.Cell, { children: company.name })] })
|
|
3543
|
-
] }) })
|
|
3544
|
-
})]
|
|
3545
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3546
|
-
className: "flex flex-col gap-y-4",
|
|
3547
|
-
children: [
|
|
3548
|
-
/* @__PURE__ */ jsx("h2", {
|
|
3549
|
-
className: "h2-core",
|
|
3550
|
-
children: t("employees.form.permissions")
|
|
3551
|
-
}),
|
|
3552
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3553
|
-
control: form.control,
|
|
3554
|
-
name: "spending_limit",
|
|
3555
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
3556
|
-
/* @__PURE__ */ jsx(Form.Label, {
|
|
3557
|
-
optional: true,
|
|
3558
|
-
children: t("fields.spendingLimit")
|
|
3559
|
-
}),
|
|
3560
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CurrencyInput, {
|
|
3561
|
-
symbol: getCurrencySymbol(currencyKey),
|
|
3562
|
-
code: company.currency_code || "USD",
|
|
3563
|
-
placeholder: "1000",
|
|
3564
|
-
value: field.value ?? "",
|
|
3565
|
-
onChange: (e) => field.onChange(e.target.value.replace(/[^0-9]/g, ""))
|
|
3566
|
-
}) }),
|
|
3567
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
3568
|
-
] })
|
|
3569
|
-
}),
|
|
3570
|
-
/* @__PURE__ */ jsx(Form.Field, {
|
|
3571
|
-
control: form.control,
|
|
3572
|
-
name: "is_admin",
|
|
3573
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [/* @__PURE__ */ jsx(Form.Label, {
|
|
3574
|
-
optional: true,
|
|
3575
|
-
children: t("employees.form.adminAccess")
|
|
3576
|
-
}), /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(CoolSwitch, {
|
|
3577
|
-
fieldName: "is_admin",
|
|
3578
|
-
label: t("employees.form.isAdmin"),
|
|
3579
|
-
description: t("employees.form.isAdminDescription"),
|
|
3580
|
-
checked: field.value,
|
|
3581
|
-
onChange: field.onChange,
|
|
3582
|
-
tooltip: t("employees.form.isAdminTooltip")
|
|
3583
|
-
}) })] })
|
|
3584
|
-
})
|
|
3585
|
-
]
|
|
3586
|
-
})]
|
|
3587
|
-
}), /* @__PURE__ */ jsxs(RouteDrawer.Footer, { children: [
|
|
3588
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, {
|
|
3589
|
-
asChild: true,
|
|
3590
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
3591
|
-
variant: "secondary",
|
|
3592
|
-
children: t("actions.cancel")
|
|
3593
|
-
})
|
|
3594
|
-
}),
|
|
3595
|
-
/* @__PURE__ */ jsx(Button, {
|
|
3596
|
-
type: "submit",
|
|
3597
|
-
isLoading: loading,
|
|
3598
|
-
children: t("actions.save")
|
|
3599
|
-
}),
|
|
3600
|
-
error && /* @__PURE__ */ jsx(Text, {
|
|
3601
|
-
className: "text-ui-fg-error",
|
|
3602
|
-
children: error.message
|
|
3603
|
-
})
|
|
3604
|
-
] })]
|
|
3605
|
-
})
|
|
3606
|
-
});
|
|
3607
|
-
}
|
|
3608
|
-
// src/admin/routes/b2b/companies/[id]/components/company-employees-table-renderers.tsx
|
|
3609
|
-
defineCellRenderer("b2b-employee-name", { render: (value) => {
|
|
3610
|
-
const customer = value;
|
|
3611
|
-
return [customer?.first_name, customer?.last_name].filter(Boolean).join(" ") || "—";
|
|
3612
|
-
} });
|
|
3613
|
-
defineCellRenderer("b2b-employee-email", { render: (_value, row) => {
|
|
3614
|
-
return row?.customer?.email || "—";
|
|
3615
|
-
} });
|
|
3616
|
-
defineCellRenderer("b2b-employee-spending-limit", { render: (value, row, _column, t) => {
|
|
3617
|
-
const currency = row?.company?.currency_code;
|
|
3618
|
-
if (!value || value === 0) return t("quotes.detail.unlimited");
|
|
3619
|
-
return currency ? getLocaleAmount(Number(value), currency) : String(value);
|
|
3620
|
-
} });
|
|
3621
|
-
defineCellRenderer("b2b-employee-is-admin", { render: (value, _row, _column, t) => {
|
|
3622
|
-
return value ? /* @__PURE__ */ jsx(Badge, {
|
|
3623
|
-
size: "2xsmall",
|
|
3624
|
-
color: "green",
|
|
3625
|
-
children: t("employees.admin")
|
|
3626
|
-
}) : null;
|
|
3627
|
-
} });
|
|
3628
|
-
defineCellRenderer("b2b-employee-is-active", { render: (value, _row, _column, t) => {
|
|
3629
|
-
return value ? /* @__PURE__ */ jsx(Badge, {
|
|
3630
|
-
size: "2xsmall",
|
|
3631
|
-
color: "green",
|
|
3632
|
-
children: t("employees.active")
|
|
3633
|
-
}) : /* @__PURE__ */ jsx(Badge, {
|
|
3634
|
-
size: "2xsmall",
|
|
3635
|
-
color: "grey",
|
|
3636
|
-
children: t("employees.inactive")
|
|
3637
|
-
});
|
|
3638
|
-
} });
|
|
3639
|
-
// src/admin/routes/b2b/companies/[id]/components/company-employees-section.tsx
|
|
3640
|
-
function useCompanyEmployeesAdapter(companyId) {
|
|
3440
|
+
return /* @__PURE__ */ jsx(EmployeesUpdateForm, {
|
|
3441
|
+
handleSubmit,
|
|
3442
|
+
loading: isPending,
|
|
3443
|
+
error,
|
|
3444
|
+
employee,
|
|
3445
|
+
company
|
|
3446
|
+
});
|
|
3447
|
+
};
|
|
3448
|
+
var EmployeeUpdate = () => {
|
|
3641
3449
|
const { t } = useTranslation();
|
|
3642
|
-
return
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
count: data?.count,
|
|
3651
|
-
isLoading: isPending,
|
|
3652
|
-
isError,
|
|
3653
|
-
error
|
|
3654
|
-
};
|
|
3655
|
-
},
|
|
3656
|
-
getRowHref: (row) => {
|
|
3657
|
-
const customerId = row.original?.customer?.id;
|
|
3658
|
-
return customerId ? `/customers/${customerId}` : void 0;
|
|
3659
|
-
},
|
|
3660
|
-
renderRowActions: (row) => /* @__PURE__ */ jsx(EmployeesActionsMenu, { employee: row }),
|
|
3661
|
-
emptyState: {
|
|
3662
|
-
empty: {
|
|
3663
|
-
heading: t("employees.noRecords"),
|
|
3664
|
-
description: ""
|
|
3665
|
-
},
|
|
3666
|
-
filtered: {
|
|
3667
|
-
heading: t("employees.noRecords"),
|
|
3668
|
-
description: ""
|
|
3669
|
-
}
|
|
3670
|
-
}
|
|
3671
|
-
}), [companyId, t]);
|
|
3672
|
-
}
|
|
3673
|
-
var CompanyEmployeesSection = ({ companyId }) => {
|
|
3450
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(Heading, { children: t("employees.drawers.editTitle") }) }), /* @__PURE__ */ jsx(UpdateContent, {})] });
|
|
3451
|
+
};
|
|
3452
|
+
var GuardedEmployeeUpdate = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3453
|
+
permission: "b2b.read",
|
|
3454
|
+
children: /* @__PURE__ */ jsx(EmployeeUpdate, {})
|
|
3455
|
+
});
|
|
3456
|
+
// src/admin/routes/b2b/companies/[id]/@employee/create/page.tsx
|
|
3457
|
+
var CreateContent = () => {
|
|
3674
3458
|
const { t } = useTranslation();
|
|
3675
|
-
const
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3459
|
+
const { id } = useParams();
|
|
3460
|
+
const { handleSuccess } = useRouteModal();
|
|
3461
|
+
const { data, isLoading } = useCompany(id);
|
|
3462
|
+
const company = data?.company;
|
|
3463
|
+
const { mutateAsync: createCustomer, isPending: creatingCustomer, error: customerError } = useCreateCustomer();
|
|
3464
|
+
const { mutateAsync: createEmployee, isPending: creatingEmployee, error: employeeError } = useCreateEmployee(id);
|
|
3465
|
+
if (isLoading || !company) return null;
|
|
3466
|
+
const handleSubmit = async (formData) => {
|
|
3467
|
+
try {
|
|
3468
|
+
const { customer } = await createCustomer({
|
|
3469
|
+
email: formData.email,
|
|
3470
|
+
first_name: formData.first_name || void 0,
|
|
3471
|
+
last_name: formData.last_name || void 0,
|
|
3472
|
+
phone: formData.phone || void 0,
|
|
3473
|
+
company_name: company.name
|
|
3474
|
+
});
|
|
3475
|
+
if (!customer?.id) {
|
|
3476
|
+
toast.error(t("employees.toasts.createCustomerError"));
|
|
3477
|
+
return;
|
|
3478
|
+
}
|
|
3479
|
+
await createEmployee({
|
|
3480
|
+
spending_limit: formData.spending_limit,
|
|
3481
|
+
is_admin: formData.is_admin,
|
|
3482
|
+
customer_id: customer.id
|
|
3483
|
+
});
|
|
3484
|
+
toast.success(t("employees.toasts.created", {
|
|
3485
|
+
firstName: customer.first_name,
|
|
3486
|
+
lastName: customer.last_name
|
|
3487
|
+
}));
|
|
3488
|
+
handleSuccess();
|
|
3489
|
+
} catch {}
|
|
3490
|
+
};
|
|
3491
|
+
return /* @__PURE__ */ jsx(EmployeesCreateForm, {
|
|
3492
|
+
handleSubmit,
|
|
3493
|
+
loading: creatingCustomer || creatingEmployee,
|
|
3494
|
+
error: customerError || employeeError,
|
|
3495
|
+
company
|
|
3683
3496
|
});
|
|
3684
3497
|
};
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
color: "grey",
|
|
3693
|
-
children: t("general.no")
|
|
3498
|
+
var EmployeeCreate = () => {
|
|
3499
|
+
const { t } = useTranslation();
|
|
3500
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(Heading, { children: t("employees.drawers.addTitle") }) }), /* @__PURE__ */ jsx(CreateContent, {})] });
|
|
3501
|
+
};
|
|
3502
|
+
var GuardedEmployeeCreate = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3503
|
+
permission: "b2b.write",
|
|
3504
|
+
children: /* @__PURE__ */ jsx(EmployeeCreate, {})
|
|
3694
3505
|
});
|
|
3695
|
-
|
|
3506
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-company-section.tsx
|
|
3507
|
+
var QuoteCompanySection = ({ quote }) => {
|
|
3696
3508
|
const { t } = useTranslation();
|
|
3697
|
-
const
|
|
3509
|
+
const company = quote.customer?.employee?.company;
|
|
3510
|
+
if (!company) return null;
|
|
3698
3511
|
return /* @__PURE__ */ jsxs(Container, {
|
|
3699
3512
|
className: "divide-y p-0",
|
|
3700
3513
|
children: [
|
|
@@ -3702,399 +3515,586 @@ var CompanyApprovalSettingsSection = ({ company }) => {
|
|
|
3702
3515
|
className: "flex items-center justify-between px-6 py-4",
|
|
3703
3516
|
children: [/* @__PURE__ */ jsx(Heading, {
|
|
3704
3517
|
level: "h2",
|
|
3705
|
-
children: t("
|
|
3706
|
-
}), /* @__PURE__ */ jsx(
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3518
|
+
children: t("quotes.detail.company")
|
|
3519
|
+
}), /* @__PURE__ */ jsx(Link$1, {
|
|
3520
|
+
to: `/b2b/companies/${company.id}`,
|
|
3521
|
+
className: "flex shrink-0 items-center text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3522
|
+
tabIndex: -1,
|
|
3523
|
+
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, { className: "h-5 w-5" })
|
|
3524
|
+
})]
|
|
3711
3525
|
}),
|
|
3712
3526
|
/* @__PURE__ */ jsx(SectionRow, {
|
|
3713
|
-
title: t("
|
|
3714
|
-
value: /* @__PURE__ */
|
|
3715
|
-
|
|
3716
|
-
|
|
3527
|
+
title: t("fields.name"),
|
|
3528
|
+
value: /* @__PURE__ */ jsxs("div", {
|
|
3529
|
+
className: "flex items-center gap-3",
|
|
3530
|
+
children: [/* @__PURE__ */ jsx(Thumbnail, { src: company.logo_url }), /* @__PURE__ */ jsx(Link$1, {
|
|
3531
|
+
to: `/b2b/companies/${company.id}`,
|
|
3532
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3533
|
+
children: company.name
|
|
3534
|
+
})]
|
|
3717
3535
|
})
|
|
3718
3536
|
}),
|
|
3537
|
+
company.currency_code && /* @__PURE__ */ jsx(SectionRow, {
|
|
3538
|
+
title: t("fields.currency"),
|
|
3539
|
+
value: company.currency_code.toUpperCase()
|
|
3540
|
+
})
|
|
3541
|
+
]
|
|
3542
|
+
});
|
|
3543
|
+
};
|
|
3544
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-customer-section.tsx
|
|
3545
|
+
var QuoteCustomerSection = ({ quote }) => {
|
|
3546
|
+
const { t } = useTranslation();
|
|
3547
|
+
const q = quote;
|
|
3548
|
+
const customer = q.customer;
|
|
3549
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
3550
|
+
className: "divide-y p-0",
|
|
3551
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3552
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
3553
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
3554
|
+
level: "h2",
|
|
3555
|
+
children: t("quotes.detail.customer")
|
|
3556
|
+
}), customer && /* @__PURE__ */ jsx(Link$1, {
|
|
3557
|
+
to: `/customers/${customer.id}`,
|
|
3558
|
+
className: "flex shrink-0 items-center text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3559
|
+
tabIndex: -1,
|
|
3560
|
+
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, { className: "h-5 w-5" })
|
|
3561
|
+
})]
|
|
3562
|
+
}), customer ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3719
3563
|
/* @__PURE__ */ jsx(SectionRow, {
|
|
3720
|
-
title: t("
|
|
3721
|
-
value: /* @__PURE__ */ jsx(
|
|
3722
|
-
|
|
3723
|
-
|
|
3564
|
+
title: t("fields.name"),
|
|
3565
|
+
value: /* @__PURE__ */ jsx(Link$1, {
|
|
3566
|
+
to: `/customers/${customer.id}`,
|
|
3567
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3568
|
+
children: [customer.first_name, customer.last_name].filter(Boolean).join(" ") || customer.email || customer.id
|
|
3724
3569
|
})
|
|
3570
|
+
}),
|
|
3571
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3572
|
+
title: t("fields.email"),
|
|
3573
|
+
value: customer.email || "—"
|
|
3574
|
+
}),
|
|
3575
|
+
customer.phone && /* @__PURE__ */ jsx(SectionRow, {
|
|
3576
|
+
title: t("fields.phone"),
|
|
3577
|
+
value: customer.phone
|
|
3578
|
+
}),
|
|
3579
|
+
q.customer?.employee?.spending_limit != null && /* @__PURE__ */ jsx(SectionRow, {
|
|
3580
|
+
title: t("fields.spendingLimit"),
|
|
3581
|
+
value: q.customer.employee.spending_limit === 0 ? t("quotes.detail.unlimited") : formatCurrency(q.customer.employee.spending_limit / 100, q.customer.employee.company?.currency_code ?? "USD")
|
|
3582
|
+
})
|
|
3583
|
+
] }) : /* @__PURE__ */ jsx("div", {
|
|
3584
|
+
className: "px-6 py-4 txt-compact-small text-ui-fg-subtle",
|
|
3585
|
+
children: t("quotes.detail.noCustomer")
|
|
3586
|
+
})]
|
|
3587
|
+
});
|
|
3588
|
+
};
|
|
3589
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-detail-actions.tsx
|
|
3590
|
+
var QuoteDetailActions = ({ canSend, canReject, isAccepted, draftOrderId, isSending, isRejecting, onViewOrder, onReject, onOpenSendDrawer }) => {
|
|
3591
|
+
const { t } = useTranslation();
|
|
3592
|
+
if (!canSend && !canReject && !isAccepted) return null;
|
|
3593
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3594
|
+
className: "flex items-center justify-end gap-2",
|
|
3595
|
+
children: [
|
|
3596
|
+
isAccepted && draftOrderId && /* @__PURE__ */ jsx(Button, {
|
|
3597
|
+
size: "small",
|
|
3598
|
+
variant: "secondary",
|
|
3599
|
+
onClick: onViewOrder,
|
|
3600
|
+
children: t("quotes.detail.viewOrder")
|
|
3601
|
+
}),
|
|
3602
|
+
canReject && /* @__PURE__ */ jsx(Button, {
|
|
3603
|
+
size: "small",
|
|
3604
|
+
variant: "secondary",
|
|
3605
|
+
isLoading: isRejecting,
|
|
3606
|
+
onClick: onReject,
|
|
3607
|
+
children: t("quotes.detail.rejectQuote")
|
|
3608
|
+
}),
|
|
3609
|
+
canSend && /* @__PURE__ */ jsx(Button, {
|
|
3610
|
+
size: "small",
|
|
3611
|
+
isLoading: isSending,
|
|
3612
|
+
onClick: onOpenSendDrawer,
|
|
3613
|
+
children: t("quotes.detail.sendQuote")
|
|
3614
|
+
})
|
|
3615
|
+
]
|
|
3616
|
+
});
|
|
3617
|
+
};
|
|
3618
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-general-section.tsx
|
|
3619
|
+
var QuoteGeneralSection = ({ quote }) => {
|
|
3620
|
+
const { t } = useTranslation();
|
|
3621
|
+
const q = quote;
|
|
3622
|
+
const orderLinkId = q.draft_order?.id ?? q.draft_order_id;
|
|
3623
|
+
const displayId = q.draft_order?.display_id;
|
|
3624
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
3625
|
+
className: "divide-y p-0",
|
|
3626
|
+
children: [
|
|
3627
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3628
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
3629
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3630
|
+
className: "flex items-center gap-3",
|
|
3631
|
+
children: [/* @__PURE__ */ jsx(Heading, { children: displayId != null ? `#${displayId}` : quote.id }), /* @__PURE__ */ jsx(QuoteStatusBadge, { status: quote.status })]
|
|
3632
|
+
}), /* @__PURE__ */ jsx(QuoteActionsMenu, { quote })]
|
|
3633
|
+
}),
|
|
3634
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3635
|
+
title: t("quotes.detail.orderChange"),
|
|
3636
|
+
value: q.order_change_id ? orderLinkId ? /* @__PURE__ */ jsx(Link$1, {
|
|
3637
|
+
to: `/orders/${orderLinkId}`,
|
|
3638
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3639
|
+
children: String(q.order_change_id)
|
|
3640
|
+
}) : String(q.order_change_id) : "—"
|
|
3641
|
+
}),
|
|
3642
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3643
|
+
title: t("quotes.detail.cart"),
|
|
3644
|
+
value: q.cart_id ? String(q.cart_id) : "—"
|
|
3645
|
+
}),
|
|
3646
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3647
|
+
title: t("quotes.table.messages"),
|
|
3648
|
+
value: String(Array.isArray(q.messages) ? q.messages.length : 0)
|
|
3649
|
+
}),
|
|
3650
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3651
|
+
title: t("fields.createdAt"),
|
|
3652
|
+
value: q.created_at ? new Date(q.created_at).toLocaleDateString() : "—"
|
|
3653
|
+
}),
|
|
3654
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3655
|
+
title: t("fields.updatedAt"),
|
|
3656
|
+
value: q.updated_at ? new Date(q.updated_at).toLocaleDateString() : "—"
|
|
3725
3657
|
})
|
|
3726
3658
|
]
|
|
3727
3659
|
});
|
|
3728
3660
|
};
|
|
3729
|
-
// src/admin/routes/b2b/
|
|
3730
|
-
var
|
|
3731
|
-
const
|
|
3732
|
-
const
|
|
3733
|
-
const
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
}), /* @__PURE__ */ jsx(SectionRow, {
|
|
3747
|
-
title: t("companies.detail.customerGroup"),
|
|
3748
|
-
value: group?.id ? /* @__PURE__ */ jsx(Link$1, {
|
|
3749
|
-
to: `/customer-groups/${group.id}`,
|
|
3750
|
-
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover",
|
|
3751
|
-
children: group.name || group.id
|
|
3752
|
-
}) : "—"
|
|
3753
|
-
})]
|
|
3661
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-message-bubble.tsx
|
|
3662
|
+
var ItemChip = ({ item, draftOrderId }) => {
|
|
3663
|
+
const title = item?.variant?.product?.title ?? item?.title ?? `...${item?.id?.slice(-8)}`;
|
|
3664
|
+
const subtitle = item?.variant?.title && item.variant.title !== "Default Title" ? item.variant.title : null;
|
|
3665
|
+
const inner = /* @__PURE__ */ jsxs("span", {
|
|
3666
|
+
className: "flex items-center gap-1.5 px-2 py-1 rounded-md bg-ui-bg-subtle border border-ui-border-base txt-compact-xsmall text-ui-fg-subtle",
|
|
3667
|
+
children: [
|
|
3668
|
+
/* @__PURE__ */ jsx(Tag, { className: "h-3 w-3 shrink-0" }),
|
|
3669
|
+
/* @__PURE__ */ jsx("span", {
|
|
3670
|
+
className: "truncate max-w-[160px]",
|
|
3671
|
+
children: title
|
|
3672
|
+
}),
|
|
3673
|
+
subtitle && /* @__PURE__ */ jsxs("span", {
|
|
3674
|
+
className: "text-ui-fg-muted",
|
|
3675
|
+
children: ["· ", subtitle]
|
|
3676
|
+
})
|
|
3677
|
+
]
|
|
3754
3678
|
});
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
const { data, isLoading, isError, error } = useCompany(id);
|
|
3760
|
-
const company = data?.company;
|
|
3761
|
-
if (isLoading || !company) return /* @__PURE__ */ jsx(TwoColumnPageSkeleton, {
|
|
3762
|
-
mainSections: 2,
|
|
3763
|
-
sidebarSections: 2,
|
|
3764
|
-
showJSON: true,
|
|
3765
|
-
showMetadata: true
|
|
3679
|
+
if (draftOrderId) return /* @__PURE__ */ jsx(Link$1, {
|
|
3680
|
+
to: `/orders/${draftOrderId}`,
|
|
3681
|
+
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3682
|
+
children: inner
|
|
3766
3683
|
});
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3684
|
+
return inner;
|
|
3685
|
+
};
|
|
3686
|
+
var MessageBubble = ({ message, item, draftOrderId, customerFallback }) => {
|
|
3687
|
+
const { t } = useTranslation();
|
|
3688
|
+
const isAdmin = !!message.admin_id;
|
|
3689
|
+
const m = message;
|
|
3690
|
+
const resolvedCustomer = m.customer ?? customerFallback;
|
|
3691
|
+
const senderName = isAdmin ? m.admin_name || t("quotes.messages.adminSender") : [resolvedCustomer?.first_name, resolvedCustomer?.last_name].filter(Boolean).join(" ") || resolvedCustomer?.email || t("quotes.messages.customerSender");
|
|
3692
|
+
const senderHref = isAdmin ? `/settings/users/${message.admin_id}` : `/customers/${message.customer_id}`;
|
|
3693
|
+
const timestamp = m.created_at ? new Date(m.created_at).toLocaleString(void 0, {
|
|
3694
|
+
month: "short",
|
|
3695
|
+
day: "numeric",
|
|
3696
|
+
hour: "2-digit",
|
|
3697
|
+
minute: "2-digit"
|
|
3698
|
+
}) : null;
|
|
3699
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3700
|
+
className: `flex gap-2.5 px-4 py-2 ${isAdmin ? "flex-row-reverse" : "flex-row"}`,
|
|
3701
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3702
|
+
className: `shrink-0 h-7 w-7 rounded-full flex items-center justify-center ${isAdmin ? "bg-ui-tag-purple-bg" : "bg-ui-tag-blue-bg"}`,
|
|
3703
|
+
children: isAdmin ? /* @__PURE__ */ jsx(Buildings, { className: "h-3.5 w-3.5 text-ui-tag-purple-icon" }) : /* @__PURE__ */ jsx(User, { className: "h-3.5 w-3.5 text-ui-tag-blue-icon" })
|
|
3704
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3705
|
+
className: `flex flex-col gap-0.5 max-w-[70%] ${isAdmin ? "items-end" : "items-start"}`,
|
|
3706
|
+
children: [
|
|
3707
|
+
/* @__PURE__ */ jsx(Link$1, {
|
|
3708
|
+
to: senderHref,
|
|
3709
|
+
className: "txt-compact-xsmall-plus text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3710
|
+
children: senderName
|
|
3777
3711
|
}),
|
|
3778
|
-
/* @__PURE__ */ jsx(
|
|
3779
|
-
|
|
3780
|
-
|
|
3712
|
+
item && /* @__PURE__ */ jsx(ItemChip, {
|
|
3713
|
+
item,
|
|
3714
|
+
draftOrderId
|
|
3781
3715
|
}),
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
}
|
|
3716
|
+
/* @__PURE__ */ jsx("div", {
|
|
3717
|
+
className: `px-3 py-2 rounded-2xl txt-compact-small whitespace-pre-wrap break-words ${isAdmin ? "bg-ui-tag-purple-bg text-ui-fg-base rounded-tr-sm" : "bg-ui-bg-component text-ui-fg-base rounded-tl-sm"}`,
|
|
3718
|
+
children: message.text
|
|
3719
|
+
}),
|
|
3720
|
+
timestamp && /* @__PURE__ */ jsx("span", {
|
|
3721
|
+
className: "txt-compact-xsmall text-ui-fg-muted",
|
|
3722
|
+
children: timestamp
|
|
3723
|
+
})
|
|
3724
|
+
]
|
|
3725
|
+
})]
|
|
3792
3726
|
});
|
|
3793
3727
|
};
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
};
|
|
3799
|
-
var handle = { breadcrumb: (match) => /* @__PURE__ */ jsx(Breadcrumb, { id: match?.params?.id }) };
|
|
3800
|
-
var GuardedCompanyDetail = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3801
|
-
permission: "b2b.read",
|
|
3802
|
-
children: /* @__PURE__ */ jsx(CompanyDetail, {})
|
|
3728
|
+
// src/admin/routes/b2b/quotes/[id]/components/validators.ts
|
|
3729
|
+
var MessageSchema = z.object({
|
|
3730
|
+
text: z.string().min(1),
|
|
3731
|
+
item_id: z.string().nullish()
|
|
3803
3732
|
});
|
|
3804
|
-
// src/admin/routes/b2b/
|
|
3805
|
-
var
|
|
3733
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-message-composer.tsx
|
|
3734
|
+
var QuoteMessageComposer = ({ quoteId, selectItems }) => {
|
|
3806
3735
|
const { t } = useTranslation();
|
|
3807
|
-
const
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
const
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
}
|
|
3824
|
-
toast.
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3736
|
+
const form = useForm({
|
|
3737
|
+
defaultValues: {
|
|
3738
|
+
text: "",
|
|
3739
|
+
item_id: null
|
|
3740
|
+
},
|
|
3741
|
+
resolver: zodResolver(MessageSchema)
|
|
3742
|
+
});
|
|
3743
|
+
const { mutateAsync: createMessage, isPending: isSending } = useCreateQuoteMessage(quoteId);
|
|
3744
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
3745
|
+
await createMessage({
|
|
3746
|
+
text: data.text,
|
|
3747
|
+
item_id: data.item_id ?? void 0
|
|
3748
|
+
}, {
|
|
3749
|
+
onSuccess: () => {
|
|
3750
|
+
form.reset();
|
|
3751
|
+
toast.success(t("quotes.messages.sentSuccess"));
|
|
3752
|
+
},
|
|
3753
|
+
onError: (e) => toast.error(e.message)
|
|
3754
|
+
});
|
|
3755
|
+
});
|
|
3756
|
+
const handleKeyDown = (e) => {
|
|
3757
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
3758
|
+
e.preventDefault();
|
|
3759
|
+
handleSubmit();
|
|
3828
3760
|
}
|
|
3829
3761
|
};
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3762
|
+
const textValue = form.watch("text");
|
|
3763
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3764
|
+
className: "px-4 py-3 bg-ui-bg-subtle",
|
|
3765
|
+
children: /* @__PURE__ */ jsx(Form, {
|
|
3766
|
+
...form,
|
|
3767
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
3768
|
+
onSubmit: handleSubmit,
|
|
3769
|
+
className: "flex flex-col gap-2",
|
|
3770
|
+
children: [selectItems.length > 0 && /* @__PURE__ */ jsx(Form.Field, {
|
|
3771
|
+
control: form.control,
|
|
3772
|
+
name: "item_id",
|
|
3773
|
+
render: ({ field: { onChange, ref, ...field } }) => /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, {
|
|
3774
|
+
onValueChange: onChange,
|
|
3775
|
+
...field,
|
|
3776
|
+
value: field.value ?? void 0,
|
|
3777
|
+
children: [/* @__PURE__ */ jsx(Select.Trigger, {
|
|
3778
|
+
className: "bg-ui-bg-base h-8 text-xs",
|
|
3779
|
+
ref,
|
|
3780
|
+
children: /* @__PURE__ */ jsx(Select.Value, { placeholder: t("quotes.messages.selectItem", "Attach an item (optional)") })
|
|
3781
|
+
}), /* @__PURE__ */ jsx(Select.Content, { children: selectItems.map((item) => /* @__PURE__ */ jsx(Select.Item, {
|
|
3782
|
+
value: item.id,
|
|
3783
|
+
children: item.variant_sku ?? item.title ?? item.id
|
|
3784
|
+
}, item.id)) })]
|
|
3785
|
+
}) }) })
|
|
3786
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3787
|
+
className: "flex items-end gap-2 rounded-2xl border border-ui-border-base bg-ui-bg-base px-3 py-2 focus-within:border-ui-border-interactive transition-colors",
|
|
3788
|
+
children: [/* @__PURE__ */ jsx(Form.Field, {
|
|
3789
|
+
control: form.control,
|
|
3790
|
+
name: "text",
|
|
3791
|
+
render: ({ field: { ref, ...field } }) => /* @__PURE__ */ jsx(Form.Item, {
|
|
3792
|
+
className: "flex-1 m-0",
|
|
3793
|
+
children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx("textarea", {
|
|
3794
|
+
...field,
|
|
3795
|
+
ref,
|
|
3796
|
+
rows: 1,
|
|
3797
|
+
placeholder: t("quotes.messages.placeholder", "Write a message…"),
|
|
3798
|
+
onKeyDown: handleKeyDown,
|
|
3799
|
+
className: "w-full resize-none bg-transparent txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted outline-hidden leading-5 max-h-32 overflow-y-auto",
|
|
3800
|
+
style: { fieldSizing: "content" }
|
|
3801
|
+
}) })
|
|
3802
|
+
})
|
|
3803
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
3804
|
+
type: "submit",
|
|
3805
|
+
size: "small",
|
|
3806
|
+
variant: "transparent",
|
|
3807
|
+
disabled: !textValue?.trim() || isSending,
|
|
3808
|
+
className: `shrink-0 transition-colors ${textValue?.trim() ? "text-ui-fg-interactive hover:text-ui-fg-interactive-hover" : "text-ui-fg-disabled"}`,
|
|
3809
|
+
children: /* @__PURE__ */ jsx(PaperPlane, {})
|
|
3810
|
+
})]
|
|
3811
|
+
})]
|
|
3812
|
+
})
|
|
3813
|
+
})
|
|
3814
|
+
});
|
|
3854
3815
|
};
|
|
3855
|
-
|
|
3856
|
-
|
|
3816
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-messages-section.tsx
|
|
3817
|
+
var QuoteMessagesSection = ({ quote, preview }) => {
|
|
3857
3818
|
const { id } = useParams();
|
|
3858
|
-
if (!id) return null;
|
|
3859
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { children: t("companies.approvalSettings.title") }) }), /* @__PURE__ */ jsx(ApprovalSettingsContent, { id })] });
|
|
3860
|
-
};
|
|
3861
|
-
var GuardedCompanyApprovalSettings = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
3862
|
-
permission: "b2b.write",
|
|
3863
|
-
children: /* @__PURE__ */ jsx(CompanyApprovalSettings, {})
|
|
3864
|
-
});
|
|
3865
|
-
// src/admin/routes/b2b/companies/[id]/@customer-group/page.tsx
|
|
3866
|
-
var CustomerGroupContent = ({ id }) => {
|
|
3867
3819
|
const { t } = useTranslation();
|
|
3868
|
-
const
|
|
3869
|
-
const
|
|
3870
|
-
const
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3820
|
+
const q = quote;
|
|
3821
|
+
const scrollRef = useRef(null);
|
|
3822
|
+
const messages = Array.isArray(q.messages) ? q.messages : [];
|
|
3823
|
+
const draftOrderId = q.draft_order_id ?? q.draft_order?.id;
|
|
3824
|
+
const draftOrderItems = q.draft_order?.items ?? [];
|
|
3825
|
+
const customerById = useMemo(() => {
|
|
3826
|
+
const map = /* @__PURE__ */ new Map();
|
|
3827
|
+
if (q.customer) map.set(q.customer.id, q.customer);
|
|
3828
|
+
messages.forEach((m) => {
|
|
3829
|
+
if (m.customer) map.set(m.customer.id ?? m.customer_id, m.customer);
|
|
3830
|
+
});
|
|
3831
|
+
return map;
|
|
3832
|
+
}, [q.customer, messages]);
|
|
3833
|
+
const selectItems = preview?.items ?? draftOrderItems;
|
|
3834
|
+
const sorted = useMemo(() => [...messages].toSorted((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()), [messages]);
|
|
3835
|
+
const itemsById = useMemo(() => new Map(draftOrderItems.map((i) => [i.id, i])), [draftOrderItems]);
|
|
3836
|
+
useEffect(() => {
|
|
3837
|
+
if (scrollRef.current) scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
3838
|
+
}, [sorted.length]);
|
|
3839
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
3840
|
+
className: "divide-y p-0 overflow-hidden",
|
|
3841
|
+
children: [
|
|
3842
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3843
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
3844
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
3845
|
+
level: "h2",
|
|
3846
|
+
children: t("quotes.messages.title", "Messages")
|
|
3847
|
+
}), /* @__PURE__ */ jsx(Badge, {
|
|
3848
|
+
size: "xsmall",
|
|
3849
|
+
color: "grey",
|
|
3850
|
+
children: messages.length
|
|
3851
|
+
})]
|
|
3852
|
+
}),
|
|
3853
|
+
/* @__PURE__ */ jsx("div", {
|
|
3854
|
+
ref: scrollRef,
|
|
3855
|
+
className: "flex flex-col py-2 overflow-y-auto",
|
|
3856
|
+
style: {
|
|
3857
|
+
maxHeight: "400px",
|
|
3858
|
+
minHeight: sorted.length === 0 ? "80px" : void 0
|
|
3859
|
+
},
|
|
3860
|
+
children: sorted.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
3861
|
+
className: "px-6 py-4 txt-compact-small text-ui-fg-subtle",
|
|
3862
|
+
children: t("quotes.messages.empty", "No messages yet")
|
|
3863
|
+
}) : sorted.map((msg) => /* @__PURE__ */ jsx(MessageBubble, {
|
|
3864
|
+
message: msg,
|
|
3865
|
+
item: msg.item_id ? itemsById.get(msg.item_id) : void 0,
|
|
3866
|
+
draftOrderId,
|
|
3867
|
+
customerFallback: customerById.get(msg.customer_id)
|
|
3868
|
+
}, msg.id))
|
|
3869
|
+
}),
|
|
3870
|
+
/* @__PURE__ */ jsx(QuoteMessageComposer, {
|
|
3871
|
+
quoteId: id,
|
|
3872
|
+
selectItems
|
|
3906
3873
|
})
|
|
3907
|
-
|
|
3908
|
-
className: "h-full overflow-y-auto",
|
|
3909
|
-
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(Table.Header, { children: /* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.HeaderCell, { children: t("companies.customerGroup.header") }), /* @__PURE__ */ jsx(Table.HeaderCell, {
|
|
3910
|
-
className: "text-right",
|
|
3911
|
-
children: t("companies.customerGroup.actionsHeader")
|
|
3912
|
-
})] }) }), /* @__PURE__ */ jsx(Table.Body, { children: customerGroups.length ? customerGroups.map((group) => {
|
|
3913
|
-
const isLinked = currentGroupId === group.id;
|
|
3914
|
-
const isOtherLinked = !!currentGroupId && !isLinked;
|
|
3915
|
-
return /* @__PURE__ */ jsxs(Table.Row, { children: [/* @__PURE__ */ jsx(Table.Cell, { children: group.name }), /* @__PURE__ */ jsx(Table.Cell, {
|
|
3916
|
-
className: "text-right",
|
|
3917
|
-
children: isLinked ? /* @__PURE__ */ jsx(Button, {
|
|
3918
|
-
size: "small",
|
|
3919
|
-
variant: "danger",
|
|
3920
|
-
isLoading: removeLoading,
|
|
3921
|
-
onClick: () => handleRemove(group.id),
|
|
3922
|
-
children: t("companies.customerGroup.remove")
|
|
3923
|
-
}) : /* @__PURE__ */ jsx(Button, {
|
|
3924
|
-
size: "small",
|
|
3925
|
-
disabled: isOtherLinked || addLoading,
|
|
3926
|
-
isLoading: addLoading,
|
|
3927
|
-
onClick: () => handleAdd(group.id),
|
|
3928
|
-
children: t("companies.customerGroup.add")
|
|
3929
|
-
})
|
|
3930
|
-
})] }, group.id);
|
|
3931
|
-
}) : /* @__PURE__ */ jsx(Table.Row, { children: /* @__PURE__ */ jsx(Table.Cell, { children: t("companies.customerGroup.noGroups") }) }) })] })
|
|
3932
|
-
})]
|
|
3874
|
+
]
|
|
3933
3875
|
});
|
|
3934
3876
|
};
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3877
|
+
// src/admin/routes/b2b/quotes/[id]/components/quote-order-section.tsx
|
|
3878
|
+
var ORDER_STATUS_COLOR = {
|
|
3879
|
+
completed: "green",
|
|
3880
|
+
pending: "orange",
|
|
3881
|
+
requires_action: "orange",
|
|
3882
|
+
draft: "grey",
|
|
3883
|
+
archived: "grey",
|
|
3884
|
+
cancelled: "red"
|
|
3941
3885
|
};
|
|
3942
|
-
var
|
|
3943
|
-
permission: "b2b.write",
|
|
3944
|
-
children: /* @__PURE__ */ jsx(CompanyCustomerGroup, {})
|
|
3945
|
-
});
|
|
3946
|
-
// src/admin/routes/b2b/companies/[id]/@edit/page.tsx
|
|
3947
|
-
var EditContent = ({ id }) => {
|
|
3886
|
+
var QuoteOrderSection = ({ quote }) => {
|
|
3948
3887
|
const { t } = useTranslation();
|
|
3949
|
-
const
|
|
3950
|
-
const
|
|
3951
|
-
const
|
|
3952
|
-
const
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
};
|
|
3964
|
-
try {
|
|
3965
|
-
await mutateAsync(payload, {
|
|
3966
|
-
onSuccess: (result) => {
|
|
3967
|
-
const name = result.company?.name ?? "";
|
|
3968
|
-
toast.success(t("companies.toasts.updated", { name }));
|
|
3969
|
-
handleSuccess();
|
|
3970
|
-
},
|
|
3971
|
-
onError: (err) => toast.error(err.message)
|
|
3972
|
-
});
|
|
3973
|
-
} catch {}
|
|
3888
|
+
const q = quote;
|
|
3889
|
+
const draftOrder = q.draft_order;
|
|
3890
|
+
const draftOrderId = q.draft_order_id;
|
|
3891
|
+
const OrderStatusBadge = ({ status }) => {
|
|
3892
|
+
if (!status) return /* @__PURE__ */ jsx("span", {
|
|
3893
|
+
className: "txt-compact-small text-ui-fg-subtle",
|
|
3894
|
+
children: "—"
|
|
3895
|
+
});
|
|
3896
|
+
const color = ORDER_STATUS_COLOR[status] ?? "grey";
|
|
3897
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
3898
|
+
size: "2xsmall",
|
|
3899
|
+
color,
|
|
3900
|
+
children: t(`quotes.orderStatus.${status}`, { defaultValue: status.replace(/_/g, " ") })
|
|
3901
|
+
});
|
|
3974
3902
|
};
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3903
|
+
return /* @__PURE__ */ jsxs(Container, {
|
|
3904
|
+
className: "divide-y p-0",
|
|
3905
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3906
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
3907
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
3908
|
+
level: "h2",
|
|
3909
|
+
children: t("quotes.detail.draftOrder")
|
|
3910
|
+
}), (draftOrder || draftOrderId) && /* @__PURE__ */ jsx(Link$1, {
|
|
3911
|
+
to: `/orders/${draftOrder?.id ?? draftOrderId}`,
|
|
3912
|
+
className: "flex shrink-0 items-center text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3913
|
+
tabIndex: -1,
|
|
3914
|
+
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, { className: "h-5 w-5" })
|
|
3915
|
+
})]
|
|
3916
|
+
}), draftOrder ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3917
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3918
|
+
title: t("quotes.detail.order"),
|
|
3919
|
+
value: /* @__PURE__ */ jsxs(Link$1, {
|
|
3920
|
+
to: `/orders/${draftOrder.id}`,
|
|
3921
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3922
|
+
children: ["#", draftOrder.display_id]
|
|
3923
|
+
})
|
|
3924
|
+
}),
|
|
3925
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3926
|
+
title: t("fields.status"),
|
|
3927
|
+
value: /* @__PURE__ */ jsx(OrderStatusBadge, { status: draftOrder.status })
|
|
3928
|
+
}),
|
|
3929
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3930
|
+
title: t("fields.total"),
|
|
3931
|
+
value: draftOrder.total != null && draftOrder.currency_code ? formatCurrency(draftOrder.total / 100, draftOrder.currency_code) : "—"
|
|
3932
|
+
}),
|
|
3933
|
+
/* @__PURE__ */ jsx(SectionRow, {
|
|
3934
|
+
title: t("fields.createdAt"),
|
|
3935
|
+
value: draftOrder.created_at ? new Date(draftOrder.created_at).toLocaleDateString() : "—"
|
|
3936
|
+
})
|
|
3937
|
+
] }) : draftOrderId ? /* @__PURE__ */ jsx(SectionRow, {
|
|
3938
|
+
title: t("fields.id"),
|
|
3939
|
+
value: /* @__PURE__ */ jsx(Link$1, {
|
|
3940
|
+
to: `/orders/${draftOrderId}`,
|
|
3941
|
+
className: "txt-compact-small text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-colors",
|
|
3942
|
+
children: draftOrderId
|
|
3943
|
+
})
|
|
3944
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
3945
|
+
className: "px-6 py-4 txt-compact-small text-ui-fg-subtle",
|
|
3946
|
+
children: t("quotes.detail.noDraftOrder")
|
|
3947
|
+
})]
|
|
3995
3948
|
});
|
|
3996
3949
|
};
|
|
3997
|
-
|
|
3998
|
-
|
|
3950
|
+
// src/admin/routes/b2b/quotes/[id]/page.tsx
|
|
3951
|
+
var CUSTOMER_FIELDS = "*customer,*customer.employee,*customer.employee.company";
|
|
3952
|
+
var QuoteDetail = () => {
|
|
3999
3953
|
const { id } = useParams();
|
|
4000
|
-
if (!id) return null;
|
|
4001
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(Heading, { children: t("companies.form.editTitle") }) }), /* @__PURE__ */ jsx(EditContent, { id })] });
|
|
4002
|
-
};
|
|
4003
|
-
var GuardedCompanyEdit = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
4004
|
-
permission: "b2b.write",
|
|
4005
|
-
children: /* @__PURE__ */ jsx(CompanyEdit, {})
|
|
4006
|
-
});
|
|
4007
|
-
// src/admin/routes/b2b/companies/[id]/@employee/[employeeId]/page.tsx
|
|
4008
|
-
var UpdateContent = () => {
|
|
4009
3954
|
const { t } = useTranslation();
|
|
4010
|
-
const
|
|
4011
|
-
const
|
|
4012
|
-
const
|
|
4013
|
-
const {
|
|
4014
|
-
const { mutateAsync, isPending
|
|
4015
|
-
|
|
4016
|
-
const
|
|
4017
|
-
const
|
|
4018
|
-
|
|
4019
|
-
|
|
3955
|
+
const navigate = useNavigate();
|
|
3956
|
+
const prompt = usePrompt();
|
|
3957
|
+
const [sendDrawerOpen, setSendDrawerOpen] = useState(false);
|
|
3958
|
+
const { quote, isPending, isError, error } = useQuote(id, { fields: CUSTOMER_FIELDS });
|
|
3959
|
+
const { mutateAsync: sendQuote, isPending: isSending } = useSendQuote(id);
|
|
3960
|
+
const { mutateAsync: rejectQuote, isPending: isRejecting } = useRejectQuote(id);
|
|
3961
|
+
const draftOrderId = quote?.draft_order_id;
|
|
3962
|
+
const draftOrderCurrencyCode = quote?.draft_order?.currency_code;
|
|
3963
|
+
const { order: orderPreview, isPending: isPreviewPending } = useOrderPreview(draftOrderId, { fields: [
|
|
3964
|
+
"currency_code",
|
|
3965
|
+
"total",
|
|
3966
|
+
"discount_total",
|
|
3967
|
+
"summary",
|
|
3968
|
+
"*shipping_methods",
|
|
3969
|
+
"*items",
|
|
3970
|
+
"*items.variant",
|
|
3971
|
+
"*items.variant.product",
|
|
3972
|
+
"*items.actions",
|
|
3973
|
+
"*items.detail"
|
|
3974
|
+
].join(",") }, { enabled: !!draftOrderId });
|
|
3975
|
+
const order = orderPreview ? {
|
|
3976
|
+
...orderPreview,
|
|
3977
|
+
currency_code: orderPreview.currency_code ?? draftOrderCurrencyCode
|
|
3978
|
+
} : orderPreview;
|
|
3979
|
+
if (isPending || !quote) return /* @__PURE__ */ jsx(TwoColumnPageSkeleton, {
|
|
3980
|
+
mainSections: 3,
|
|
3981
|
+
sidebarSections: 2
|
|
3982
|
+
});
|
|
3983
|
+
if (isError) throw error;
|
|
3984
|
+
const canSend = [EQuoteStatus.PendingMerchant, EQuoteStatus.CustomerRejected].includes(quote.status);
|
|
3985
|
+
const canReject = [EQuoteStatus.PendingMerchant, EQuoteStatus.PendingCustomer].includes(quote.status);
|
|
3986
|
+
const isAccepted = quote.status === EQuoteStatus.Accepted;
|
|
3987
|
+
const handleSendConfirm = async (expiresAt) => {
|
|
4020
3988
|
try {
|
|
4021
|
-
await
|
|
4022
|
-
...formData,
|
|
4023
|
-
id: employeeId
|
|
4024
|
-
}, {
|
|
3989
|
+
await sendQuote({ expires_at: expiresAt }, {
|
|
4025
3990
|
onSuccess: () => {
|
|
4026
|
-
|
|
4027
|
-
|
|
3991
|
+
setSendDrawerOpen(false);
|
|
3992
|
+
toast.success(t("quotes.toasts.sent"));
|
|
4028
3993
|
},
|
|
4029
3994
|
onError: (err) => toast.error(err.message)
|
|
4030
3995
|
});
|
|
4031
3996
|
} catch {}
|
|
4032
3997
|
};
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
};
|
|
4041
|
-
var EmployeeUpdate = () => {
|
|
4042
|
-
const { t } = useTranslation();
|
|
4043
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(Heading, { children: t("employees.drawers.editTitle") }) }), /* @__PURE__ */ jsx(UpdateContent, {})] });
|
|
4044
|
-
};
|
|
4045
|
-
var GuardedEmployeeUpdate = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
4046
|
-
permission: "b2b.read",
|
|
4047
|
-
children: /* @__PURE__ */ jsx(EmployeeUpdate, {})
|
|
4048
|
-
});
|
|
4049
|
-
// src/admin/routes/b2b/companies/[id]/@employee/create/page.tsx
|
|
4050
|
-
var CreateContent = () => {
|
|
4051
|
-
const { t } = useTranslation();
|
|
4052
|
-
const { id } = useParams();
|
|
4053
|
-
const { handleSuccess } = useRouteModal();
|
|
4054
|
-
const { data, isLoading } = useCompany(id);
|
|
4055
|
-
const company = data?.company;
|
|
4056
|
-
const { mutateAsync: createCustomer, isPending: creatingCustomer, error: customerError } = useCreateCustomer();
|
|
4057
|
-
const { mutateAsync: createEmployee, isPending: creatingEmployee, error: employeeError } = useCreateEmployee(id);
|
|
4058
|
-
if (isLoading || !company) return null;
|
|
4059
|
-
const handleSubmit = async (formData) => {
|
|
3998
|
+
const handleReject = async () => {
|
|
3999
|
+
if (!await prompt({
|
|
4000
|
+
title: t("quotes.prompts.reject.title"),
|
|
4001
|
+
description: t("quotes.prompts.reject.description"),
|
|
4002
|
+
confirmText: t("actions.reject"),
|
|
4003
|
+
cancelText: t("actions.cancel")
|
|
4004
|
+
})) return;
|
|
4060
4005
|
try {
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
last_name: formData.last_name || void 0,
|
|
4065
|
-
phone: formData.phone || void 0,
|
|
4066
|
-
company_name: company.name
|
|
4067
|
-
});
|
|
4068
|
-
if (!customer?.id) {
|
|
4069
|
-
toast.error(t("employees.toasts.createCustomerError"));
|
|
4070
|
-
return;
|
|
4071
|
-
}
|
|
4072
|
-
await createEmployee({
|
|
4073
|
-
spending_limit: formData.spending_limit,
|
|
4074
|
-
is_admin: formData.is_admin,
|
|
4075
|
-
customer_id: customer.id
|
|
4006
|
+
await rejectQuote(void 0, {
|
|
4007
|
+
onSuccess: () => toast.success(t("quotes.toasts.rejected")),
|
|
4008
|
+
onError: (err) => toast.error(err.message)
|
|
4076
4009
|
});
|
|
4077
|
-
toast.success(t("employees.toasts.created", {
|
|
4078
|
-
firstName: customer.first_name,
|
|
4079
|
-
lastName: customer.last_name
|
|
4080
|
-
}));
|
|
4081
|
-
handleSuccess();
|
|
4082
4010
|
} catch {}
|
|
4083
4011
|
};
|
|
4084
|
-
return /* @__PURE__ */
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4012
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4013
|
+
className: "flex flex-col gap-4",
|
|
4014
|
+
children: [
|
|
4015
|
+
/* @__PURE__ */ jsx(QuoteDetailActions, {
|
|
4016
|
+
canSend,
|
|
4017
|
+
canReject,
|
|
4018
|
+
isAccepted,
|
|
4019
|
+
draftOrderId,
|
|
4020
|
+
isSending,
|
|
4021
|
+
isRejecting,
|
|
4022
|
+
onViewOrder: () => navigate(`/orders/${draftOrderId}`),
|
|
4023
|
+
onReject: handleReject,
|
|
4024
|
+
onOpenSendDrawer: () => setSendDrawerOpen(true)
|
|
4025
|
+
}),
|
|
4026
|
+
/* @__PURE__ */ jsx(LayoutComposer, {
|
|
4027
|
+
widgetsZonePrefix: "b2b.quote.details",
|
|
4028
|
+
preferredLayoutId: CORE_LAYOUT_IDS.TWO_COLUMN,
|
|
4029
|
+
data: quote,
|
|
4030
|
+
sections: {
|
|
4031
|
+
main: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4032
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4033
|
+
id: "QuoteGeneralSection",
|
|
4034
|
+
children: /* @__PURE__ */ jsx(QuoteGeneralSection, { quote })
|
|
4035
|
+
}),
|
|
4036
|
+
order && !isPreviewPending && /* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4037
|
+
id: "QuoteOrderSummarySection",
|
|
4038
|
+
children: /* @__PURE__ */ jsx(OrderSummarySection, {
|
|
4039
|
+
order,
|
|
4040
|
+
plugins: [],
|
|
4041
|
+
readOnly: true
|
|
4042
|
+
})
|
|
4043
|
+
}),
|
|
4044
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4045
|
+
id: "QuoteMessagesSection",
|
|
4046
|
+
children: /* @__PURE__ */ jsx(QuoteMessagesSection, {
|
|
4047
|
+
quote,
|
|
4048
|
+
preview: order
|
|
4049
|
+
})
|
|
4050
|
+
}),
|
|
4051
|
+
isAccepted && /* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4052
|
+
id: "QuoteAcceptedMessage",
|
|
4053
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
4054
|
+
className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle px-6 py-4",
|
|
4055
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
4056
|
+
size: "small",
|
|
4057
|
+
children: t("quotes.detail.acceptedMessage")
|
|
4058
|
+
})
|
|
4059
|
+
})
|
|
4060
|
+
}),
|
|
4061
|
+
detailPageDefaultEntries(quote)
|
|
4062
|
+
] }),
|
|
4063
|
+
side: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4064
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4065
|
+
id: "QuoteCustomerSection",
|
|
4066
|
+
children: /* @__PURE__ */ jsx(QuoteCustomerSection, { quote })
|
|
4067
|
+
}),
|
|
4068
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4069
|
+
id: "QuoteCompanySection",
|
|
4070
|
+
children: /* @__PURE__ */ jsx(QuoteCompanySection, { quote })
|
|
4071
|
+
}),
|
|
4072
|
+
/* @__PURE__ */ jsx(LayoutComposer.Entry, {
|
|
4073
|
+
id: "QuoteOrderSection",
|
|
4074
|
+
children: /* @__PURE__ */ jsx(QuoteOrderSection, { quote })
|
|
4075
|
+
})
|
|
4076
|
+
] })
|
|
4077
|
+
}
|
|
4078
|
+
}),
|
|
4079
|
+
/* @__PURE__ */ jsx(SendQuoteDrawer, {
|
|
4080
|
+
open: sendDrawerOpen,
|
|
4081
|
+
onClose: () => setSendDrawerOpen(false),
|
|
4082
|
+
onConfirm: handleSendConfirm,
|
|
4083
|
+
isPending: isSending
|
|
4084
|
+
})
|
|
4085
|
+
]
|
|
4089
4086
|
});
|
|
4090
4087
|
};
|
|
4091
|
-
var
|
|
4088
|
+
var Breadcrumb = ({ id }) => {
|
|
4092
4089
|
const { t } = useTranslation();
|
|
4093
|
-
|
|
4090
|
+
const { quote } = useQuote(id ?? "", void 0, { enabled: !!id });
|
|
4091
|
+
const displayId = quote?.draft_order?.display_id;
|
|
4092
|
+
return displayId != null ? `#${displayId}` : id ?? t("quote.title");
|
|
4094
4093
|
};
|
|
4095
|
-
var
|
|
4096
|
-
|
|
4097
|
-
|
|
4094
|
+
var handle = { breadcrumb: (match) => /* @__PURE__ */ jsx(Breadcrumb, { id: match?.params?.id }) };
|
|
4095
|
+
var GuardedQuoteDetail = () => /* @__PURE__ */ jsx(RbacGuard, {
|
|
4096
|
+
permission: "b2b.read",
|
|
4097
|
+
children: /* @__PURE__ */ jsx(QuoteDetail, {})
|
|
4098
4098
|
});
|
|
4099
4099
|
// src/admin/routes/b2b/quotes/[id]/manage/components/manage-item-info.tsx
|
|
4100
4100
|
var ManageItemInfo = ({ item, isAddedItem, isItemUpdated, isItemRemoved }) => {
|
|
@@ -8565,28 +8565,28 @@ var plugin = {
|
|
|
8565
8565
|
}
|
|
8566
8566
|
},
|
|
8567
8567
|
{
|
|
8568
|
-
Component:
|
|
8569
|
-
path: "/b2b/
|
|
8568
|
+
Component: GuardedApprovals,
|
|
8569
|
+
path: "/b2b/approvals",
|
|
8570
8570
|
handle: {
|
|
8571
8571
|
label: config$2.label,
|
|
8572
8572
|
translationNs: config$2.translationNs,
|
|
8573
8573
|
permissions: config$2.permissions,
|
|
8574
8574
|
...handle$4
|
|
8575
|
-
}
|
|
8576
|
-
children: [{
|
|
8577
|
-
Component: GuardedCompanyCreate,
|
|
8578
|
-
path: "/b2b/companies/create"
|
|
8579
|
-
}]
|
|
8575
|
+
}
|
|
8580
8576
|
},
|
|
8581
8577
|
{
|
|
8582
|
-
Component:
|
|
8583
|
-
path: "/b2b/
|
|
8578
|
+
Component: GuardedCompanies,
|
|
8579
|
+
path: "/b2b/companies",
|
|
8584
8580
|
handle: {
|
|
8585
8581
|
label: config$1.label,
|
|
8586
8582
|
translationNs: config$1.translationNs,
|
|
8587
8583
|
permissions: config$1.permissions,
|
|
8588
8584
|
...handle$3
|
|
8589
|
-
}
|
|
8585
|
+
},
|
|
8586
|
+
children: [{
|
|
8587
|
+
Component: GuardedCompanyCreate,
|
|
8588
|
+
path: "/b2b/companies/create"
|
|
8589
|
+
}]
|
|
8590
8590
|
},
|
|
8591
8591
|
{
|
|
8592
8592
|
Component: GuardedQuotes,
|
|
@@ -8598,15 +8598,10 @@ var plugin = {
|
|
|
8598
8598
|
...handle$2
|
|
8599
8599
|
}
|
|
8600
8600
|
},
|
|
8601
|
-
{
|
|
8602
|
-
Component: GuardedQuoteDetail,
|
|
8603
|
-
path: "/b2b/quotes/:id",
|
|
8604
|
-
handle: handle$1
|
|
8605
|
-
},
|
|
8606
8601
|
{
|
|
8607
8602
|
Component: GuardedCompanyDetail,
|
|
8608
8603
|
path: "/b2b/companies/:id",
|
|
8609
|
-
handle,
|
|
8604
|
+
handle: handle$1,
|
|
8610
8605
|
children: [
|
|
8611
8606
|
{
|
|
8612
8607
|
Component: GuardedCompanyApprovalSettings,
|
|
@@ -8630,6 +8625,11 @@ var plugin = {
|
|
|
8630
8625
|
}
|
|
8631
8626
|
]
|
|
8632
8627
|
},
|
|
8628
|
+
{
|
|
8629
|
+
Component: GuardedQuoteDetail,
|
|
8630
|
+
path: "/b2b/quotes/:id",
|
|
8631
|
+
handle
|
|
8632
|
+
},
|
|
8633
8633
|
{
|
|
8634
8634
|
Component: GuardedQuoteManage,
|
|
8635
8635
|
path: "/b2b/quotes/:id/manage"
|
|
@@ -8646,8 +8646,8 @@ var plugin = {
|
|
|
8646
8646
|
permissions: void 0
|
|
8647
8647
|
},
|
|
8648
8648
|
{
|
|
8649
|
-
label: config$
|
|
8650
|
-
icon: config$
|
|
8649
|
+
label: config$2.label,
|
|
8650
|
+
icon: config$2.icon,
|
|
8651
8651
|
path: "/b2b/approvals",
|
|
8652
8652
|
nested: void 0,
|
|
8653
8653
|
rank: void 0,
|
|
@@ -8655,12 +8655,12 @@ var plugin = {
|
|
|
8655
8655
|
permissions: void 0
|
|
8656
8656
|
},
|
|
8657
8657
|
{
|
|
8658
|
-
label: config$
|
|
8659
|
-
icon: config$
|
|
8658
|
+
label: config$1.label,
|
|
8659
|
+
icon: config$1.icon,
|
|
8660
8660
|
path: "/b2b/companies",
|
|
8661
8661
|
nested: void 0,
|
|
8662
8662
|
rank: void 0,
|
|
8663
|
-
translationNs: config$
|
|
8663
|
+
translationNs: config$1.translationNs,
|
|
8664
8664
|
permissions: void 0
|
|
8665
8665
|
},
|
|
8666
8666
|
{
|