@medusajs/loyalty-plugin 0.0.3 → 0.0.4

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.
@@ -3,14 +3,14 @@ var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, {
3
3
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
4
4
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
5
5
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
6
- import { EllipsisHorizontal, InformationCircleSolid, ExclamationCircle, PlusMini, TriangleRightMini, Gift, Photo, AdjustmentsDone, Adjustments, TaxInclusive, TaxExclusive, MinusMini, ArrowDownTray, DotsSix, ThumbnailBadge, XMark, StackPerspective, Trash, XMarkMini, CreditCard, Tag, ArrowUpRightOnBox, TriangleDownMini, Check, SquareTwoStack, Calendar, ShoppingCart, UserMini, PencilSquare, Channels, TriangleLeftMini } from "@medusajs/icons";
7
- import { DropdownMenu, IconButton, clx, Heading, Text, Tooltip, Button, Container as Container$1, StatusBadge, useDataTable, DataTable as DataTable$1, createDataTableFilterHelper, Toaster, Label as Label$1, Hint as Hint$1, Prompt, Drawer, FocusModal, Badge, Checkbox, Skeleton, Input, Alert, Textarea, createDataTableColumnHelper, Divider, toast, ProgressTabs, Kbd, usePrompt, Copy, RadioGroup, DatePicker, Select, CommandBar } from "@medusajs/ui";
6
+ import { EllipsisHorizontal, InformationCircleSolid, ExclamationCircle, PlusMini, TriangleRightMini, Gift, Tag, Photo, AdjustmentsDone, Adjustments, TaxInclusive, TaxExclusive, MinusMini, ArrowDownTray, DotsSix, ThumbnailBadge, XMark, StackPerspective, Trash, XMarkMini, CreditCard, ArrowUpRightOnBox, TriangleDownMini, Check, SquareTwoStack, Calendar, ShoppingCart, UserMini, PencilSquare, Channels, TriangleLeftMini } from "@medusajs/icons";
7
+ import { DropdownMenu, IconButton, clx, Heading, Text, Tooltip, Button, Container as Container$1, StatusBadge, useDataTable, DataTable as DataTable$1, createDataTableColumnHelper, createDataTableFilterHelper, Toaster, Label as Label$1, Hint as Hint$1, Prompt, Drawer, FocusModal, Badge, Checkbox, Skeleton, Input, Alert, Textarea, Divider, toast, ProgressTabs, Kbd, usePrompt, Copy, RadioGroup, DatePicker, Select, CommandBar } from "@medusajs/ui";
8
8
  import { Link, useParams, useSearchParams, useNavigate, Outlet, useBlocker, useLocation } from "react-router-dom";
9
9
  import * as React from "react";
10
10
  import React__default, { createElement, useState, useCallback, useMemo, Fragment as Fragment$1, createContext, forwardRef, useId, useContext, useEffect, useRef, useImperativeHandle, useLayoutEffect, memo as memo$2, useReducer, cloneElement, isValidElement, Children, Suspense } from "react";
11
11
  import { useQuery, useQueryClient, useMutation, useInfiniteQuery, keepPreviousData } from "@tanstack/react-query";
12
12
  import Medusa, { FetchError } from "@medusajs/js-sdk";
13
- import { format as format$1, subDays, subMonths, formatDistance, sub } from "date-fns";
13
+ import { format as format$1, formatDistance, sub, subDays, subMonths } from "date-fns";
14
14
  import { enUS } from "date-fns/locale";
15
15
  import get$2 from "lodash/get";
16
16
  import set$1 from "lodash/set";
@@ -617,6 +617,147 @@ const OrderGiftCardsWidget = () => {
617
617
  defineWidgetConfig({
618
618
  zone: "order.details.side.after"
619
619
  });
620
+ const TwoColumnLayout = ({
621
+ firstCol,
622
+ secondCol
623
+ }) => {
624
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start", children: [
625
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-y-3", children: firstCol }),
626
+ /* @__PURE__ */ jsx("div", { className: "flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]", children: secondCol })
627
+ ] });
628
+ };
629
+ const PRODUCTS_QUERY_KEY = "products";
630
+ const productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY);
631
+ const VARIANTS_QUERY_KEY = "product_variants";
632
+ const variantsQueryKeys = queryKeysFactory(VARIANTS_QUERY_KEY);
633
+ const useProducts = (query, options) => {
634
+ const { data, ...rest } = useQuery({
635
+ queryFn: () => sdk.admin.product.list(query),
636
+ queryKey: productsQueryKeys.list(query),
637
+ ...options
638
+ });
639
+ return { ...data, ...rest };
640
+ };
641
+ const useProduct = (id, query, options) => {
642
+ const { data, ...rest } = useQuery({
643
+ queryFn: () => sdk.admin.product.retrieve(id, query),
644
+ queryKey: productsQueryKeys.detail(id, query),
645
+ ...options
646
+ });
647
+ return { ...data, ...rest };
648
+ };
649
+ const useCreateProduct = (options) => {
650
+ const queryClient = useQueryClient();
651
+ return useMutation({
652
+ mutationFn: (payload) => sdk.admin.product.create(payload),
653
+ onSuccess: (data, variables, context) => {
654
+ queryClient.invalidateQueries({ queryKey: productsQueryKeys.lists() });
655
+ },
656
+ ...options
657
+ });
658
+ };
659
+ const useDeleteProduct = (id, options) => {
660
+ const queryClient = useQueryClient();
661
+ return useMutation({
662
+ mutationFn: () => sdk.admin.product.delete(id),
663
+ onSuccess: (data, variables, context) => {
664
+ queryClient.invalidateQueries({ queryKey: productsQueryKeys.lists() });
665
+ queryClient.invalidateQueries({ queryKey: productsQueryKeys.detail(id) });
666
+ },
667
+ ...options
668
+ });
669
+ };
670
+ const useProductVariants = (productId, query, options) => {
671
+ const { data, ...rest } = useQuery({
672
+ queryFn: () => sdk.admin.product.listVariants(productId, query),
673
+ queryKey: variantsQueryKeys.list({ productId, ...query }),
674
+ ...options
675
+ });
676
+ return { ...data, ...rest };
677
+ };
678
+ const useDeleteVariantLazy = (productId, options) => {
679
+ const queryClient = useQueryClient();
680
+ return useMutation({
681
+ mutationFn: ({ variantId }) => sdk.admin.product.deleteVariant(productId, variantId),
682
+ onSuccess: (data, variables, context) => {
683
+ queryClient.invalidateQueries({ queryKey: variantsQueryKeys.lists() });
684
+ queryClient.invalidateQueries({
685
+ queryKey: variantsQueryKeys.detail(variables.variantId)
686
+ });
687
+ queryClient.invalidateQueries({
688
+ queryKey: productsQueryKeys.detail(productId)
689
+ });
690
+ },
691
+ ...options
692
+ });
693
+ };
694
+ const useUpdateProduct = (id, options) => {
695
+ const queryClient = useQueryClient();
696
+ return useMutation({
697
+ mutationFn: (payload) => sdk.admin.product.update(id, payload),
698
+ onSuccess: async (data, variables, context) => {
699
+ await queryClient.invalidateQueries({
700
+ queryKey: productsQueryKeys.lists()
701
+ });
702
+ await queryClient.invalidateQueries({
703
+ queryKey: productsQueryKeys.details()
704
+ });
705
+ await queryClient.invalidateQueries({
706
+ queryKey: variantsQueryKeys.lists()
707
+ });
708
+ await queryClient.invalidateQueries({
709
+ queryKey: variantsQueryKeys.details()
710
+ });
711
+ },
712
+ ...options
713
+ });
714
+ };
715
+ const useUpdateProductVariantsBatch = (productId, options) => {
716
+ const queryClient = useQueryClient();
717
+ return useMutation({
718
+ mutationFn: (payload) => sdk.admin.product.batchVariants(productId, {
719
+ update: payload
720
+ }),
721
+ onSuccess: (data, variables, context) => {
722
+ queryClient.invalidateQueries({ queryKey: variantsQueryKeys.lists() });
723
+ queryClient.invalidateQueries({ queryKey: variantsQueryKeys.details() });
724
+ queryClient.invalidateQueries({
725
+ queryKey: productsQueryKeys.detail(productId)
726
+ });
727
+ },
728
+ ...options
729
+ });
730
+ };
731
+ const GiftCardProductsSection = () => {
732
+ const { products: giftCardProducts } = useProducts({
733
+ is_giftcard: true
734
+ });
735
+ if (!(giftCardProducts == null ? void 0 : giftCardProducts.length)) {
736
+ return;
737
+ }
738
+ return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
739
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
740
+ /* @__PURE__ */ jsx(Header$5, { title: "Gift Card Products" }),
741
+ /* @__PURE__ */ jsx(
742
+ Link,
743
+ {
744
+ to: `/gift-card-products/create`,
745
+ className: "text-ui-fg-muted text-sm px-6",
746
+ children: "Create gift card product"
747
+ }
748
+ )
749
+ ] }),
750
+ giftCardProducts.map((giftCardProduct) => /* @__PURE__ */ jsx(
751
+ SidebarLink,
752
+ {
753
+ to: `/gift-card-products/${giftCardProduct.id}`,
754
+ labelKey: giftCardProduct.title,
755
+ descriptionKey: giftCardProduct.title,
756
+ icon: /* @__PURE__ */ jsx(Tag, {})
757
+ }
758
+ ))
759
+ ] });
760
+ };
620
761
  function useQueryParams(keys, prefix) {
621
762
  const [params] = useSearchParams();
622
763
  const result = {};
@@ -867,108 +1008,282 @@ const DataTableAction = ({
867
1008
  }
868
1009
  return /* @__PURE__ */ jsx(Button, { ...buttonProps, onClick: props.onClick, children: label });
869
1010
  };
870
- const PRODUCTS_QUERY_KEY = "products";
871
- const productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY);
872
- const VARIANTS_QUERY_KEY = "product_variants";
873
- const variantsQueryKeys = queryKeysFactory(VARIANTS_QUERY_KEY);
874
- const useProducts = (query, options) => {
875
- const { data, ...rest } = useQuery({
876
- queryFn: () => sdk.admin.product.list(query),
877
- queryKey: productsQueryKeys.list(query),
878
- ...options
879
- });
880
- return { ...data, ...rest };
881
- };
882
- const useProduct = (id, query, options) => {
883
- const { data, ...rest } = useQuery({
884
- queryFn: () => sdk.admin.product.retrieve(id, query),
885
- queryKey: productsQueryKeys.detail(id, query),
886
- ...options
887
- });
888
- return { ...data, ...rest };
889
- };
890
- const useCreateProduct = (options) => {
891
- const queryClient = useQueryClient();
892
- return useMutation({
893
- mutationFn: (payload) => sdk.admin.product.create(payload),
894
- onSuccess: (data, variables, context) => {
895
- queryClient.invalidateQueries({ queryKey: productsQueryKeys.lists() });
896
- },
897
- ...options
898
- });
899
- };
900
- const useDeleteProduct = (id, options) => {
901
- const queryClient = useQueryClient();
902
- return useMutation({
903
- mutationFn: () => sdk.admin.product.delete(id),
904
- onSuccess: (data, variables, context) => {
905
- queryClient.invalidateQueries({ queryKey: productsQueryKeys.lists() });
906
- queryClient.invalidateQueries({ queryKey: productsQueryKeys.detail(id) });
907
- },
908
- ...options
1011
+ function getRelativeDate(date) {
1012
+ const now = /* @__PURE__ */ new Date();
1013
+ return formatDistance(sub(new Date(date), { minutes: 0 }), now, {
1014
+ addSuffix: true,
1015
+ includeSeconds: false
909
1016
  });
1017
+ }
1018
+ function formatDate(date, withTime = true) {
1019
+ if (!date) {
1020
+ return "-";
1021
+ }
1022
+ if (withTime) {
1023
+ return format$1(new Date(date), "dd MMM, yyyy, HH:mm:ss");
1024
+ }
1025
+ return format$1(new Date(date), "dd MMM, yyyy");
1026
+ }
1027
+ const columnHelper$a = createDataTableColumnHelper();
1028
+ const useGiftCardTableColumns = () => {
1029
+ return useMemo(() => {
1030
+ return [
1031
+ columnHelper$a.accessor("line_item.product.title", {
1032
+ header: "Product",
1033
+ cell: ({ row }) => {
1034
+ var _a, _b;
1035
+ return ((_b = (_a = row.original.line_item) == null ? void 0 : _a.product) == null ? void 0 : _b.title) || "Custom Gift Card";
1036
+ }
1037
+ }),
1038
+ columnHelper$a.accessor("customer.first_name", {
1039
+ header: "Owner",
1040
+ cell: ({ row }) => {
1041
+ if (!row.original.customer) {
1042
+ return "N/A";
1043
+ }
1044
+ const fullName = [
1045
+ row.original.customer.first_name,
1046
+ row.original.customer.last_name
1047
+ ];
1048
+ if (fullName.join("").length > 0) {
1049
+ return fullName.join(" ");
1050
+ }
1051
+ return row.original.customer.email;
1052
+ }
1053
+ }),
1054
+ columnHelper$a.accessor("created_at", {
1055
+ header: "Date issued",
1056
+ cell: ({ row }) => getRelativeDate(row.original.created_at)
1057
+ }),
1058
+ columnHelper$a.accessor("status", {
1059
+ header: "Status",
1060
+ cell: ({ row }) => {
1061
+ const status = getGiftCardStatus(row.original);
1062
+ const color = getGiftCardStatusColor(status);
1063
+ return /* @__PURE__ */ jsx(StatusBadge, { color, children: status });
1064
+ }
1065
+ }),
1066
+ columnHelper$a.accessor("value", {
1067
+ header: "Value",
1068
+ cell: ({ row }) => {
1069
+ return formatAmount(row.original.value, row.original.currency_code);
1070
+ }
1071
+ })
1072
+ ];
1073
+ }, []);
910
1074
  };
911
- const useProductVariants = (productId, query, options) => {
912
- const { data, ...rest } = useQuery({
913
- queryFn: () => sdk.admin.product.listVariants(productId, query),
914
- queryKey: variantsQueryKeys.list({ productId, ...query }),
915
- ...options
1075
+ const LOCALE = enUS;
1076
+ const getFullDate = ({
1077
+ date,
1078
+ includeTime = false
1079
+ }) => {
1080
+ const ensuredDate = new Date(date);
1081
+ if (isNaN(ensuredDate.getTime())) {
1082
+ return "";
1083
+ }
1084
+ const timeFormat = includeTime ? "p" : "";
1085
+ return format$1(ensuredDate, `PP ${timeFormat}`, {
1086
+ locale: LOCALE
916
1087
  });
917
- return { ...data, ...rest };
918
1088
  };
919
- const useDeleteVariantLazy = (productId, options) => {
920
- const queryClient = useQueryClient();
921
- return useMutation({
922
- mutationFn: ({ variantId }) => sdk.admin.product.deleteVariant(productId, variantId),
923
- onSuccess: (data, variables, context) => {
924
- queryClient.invalidateQueries({ queryKey: variantsQueryKeys.lists() });
925
- queryClient.invalidateQueries({
926
- queryKey: variantsQueryKeys.detail(variables.variantId)
927
- });
928
- queryClient.invalidateQueries({
929
- queryKey: productsQueryKeys.detail(productId)
930
- });
931
- },
932
- ...options
933
- });
1089
+ const filterHelper$4 = createDataTableFilterHelper();
1090
+ const useDateFilterOptions$1 = () => {
1091
+ const today = useMemo(() => {
1092
+ const date = /* @__PURE__ */ new Date();
1093
+ date.setHours(0, 0, 0, 0);
1094
+ return date;
1095
+ }, []);
1096
+ return useMemo(() => {
1097
+ return [
1098
+ {
1099
+ label: "Today",
1100
+ value: {
1101
+ $gte: today.toISOString()
1102
+ }
1103
+ },
1104
+ {
1105
+ label: "Last 7 days",
1106
+ value: {
1107
+ $gte: subDays(today, 7).toISOString()
1108
+ // 7 days ago
1109
+ }
1110
+ },
1111
+ {
1112
+ label: "Last 30 days",
1113
+ value: {
1114
+ $gte: subDays(today, 30).toISOString()
1115
+ // 30 days ago
1116
+ }
1117
+ },
1118
+ {
1119
+ label: "Last 90 days",
1120
+ value: {
1121
+ $gte: subDays(today, 90).toISOString()
1122
+ // 90 days ago
1123
+ }
1124
+ },
1125
+ {
1126
+ label: "Last 12 months",
1127
+ value: {
1128
+ $gte: subMonths(today, 12).toISOString()
1129
+ // 12 months ago
1130
+ }
1131
+ }
1132
+ ];
1133
+ }, [today]);
934
1134
  };
935
- const useUpdateProduct = (id, options) => {
936
- const queryClient = useQueryClient();
937
- return useMutation({
938
- mutationFn: (payload) => sdk.admin.product.update(id, payload),
939
- onSuccess: async (data, variables, context) => {
940
- await queryClient.invalidateQueries({
941
- queryKey: productsQueryKeys.lists()
942
- });
943
- await queryClient.invalidateQueries({
944
- queryKey: productsQueryKeys.details()
945
- });
946
- await queryClient.invalidateQueries({
947
- queryKey: variantsQueryKeys.lists()
948
- });
949
- await queryClient.invalidateQueries({
950
- queryKey: variantsQueryKeys.details()
951
- });
952
- },
1135
+ const useDataTableDateFilters$1 = (disableRangeOption) => {
1136
+ const dateFilterOptions = useDateFilterOptions$1();
1137
+ const rangeOptions = useMemo(() => {
1138
+ return {
1139
+ rangeOptionStartLabel: "Starting",
1140
+ rangeOptionEndLabel: "Ending",
1141
+ rangeOptionLabel: "Custom",
1142
+ options: dateFilterOptions
1143
+ };
1144
+ }, [disableRangeOption, dateFilterOptions]);
1145
+ return useMemo(() => {
1146
+ return [
1147
+ filterHelper$4.accessor("created_at", {
1148
+ type: "date",
1149
+ label: "Created at",
1150
+ format: "date",
1151
+ formatDateValue: (date) => getFullDate({ date }),
1152
+ options: dateFilterOptions,
1153
+ ...rangeOptions
1154
+ }),
1155
+ filterHelper$4.accessor("updated_at", {
1156
+ type: "date",
1157
+ label: "Updated at",
1158
+ format: "date",
1159
+ formatDateValue: (date) => getFullDate({ date }),
1160
+ options: dateFilterOptions,
1161
+ ...rangeOptions
1162
+ })
1163
+ ];
1164
+ }, [dateFilterOptions, getFullDate, rangeOptions]);
1165
+ };
1166
+ const CUSTOMERS_QUERY_KEY = "customers";
1167
+ const customersQueryKeys = queryKeysFactory(CUSTOMERS_QUERY_KEY);
1168
+ const useCustomers = (query, options) => {
1169
+ const { data, ...rest } = useQuery({
1170
+ queryFn: () => sdk.admin.customer.list(query),
1171
+ queryKey: customersQueryKeys.list(query),
953
1172
  ...options
954
1173
  });
1174
+ return { ...data, ...rest };
955
1175
  };
956
- const useUpdateProductVariantsBatch = (productId, options) => {
957
- const queryClient = useQueryClient();
958
- return useMutation({
959
- mutationFn: (payload) => sdk.admin.product.batchVariants(productId, {
960
- update: payload
961
- }),
962
- onSuccess: (data, variables, context) => {
963
- queryClient.invalidateQueries({ queryKey: variantsQueryKeys.lists() });
964
- queryClient.invalidateQueries({ queryKey: variantsQueryKeys.details() });
965
- queryClient.invalidateQueries({
966
- queryKey: productsQueryKeys.detail(productId)
967
- });
968
- },
969
- ...options
1176
+ const filterHelper$3 = createDataTableFilterHelper();
1177
+ const useCustomerFilterOptions = () => {
1178
+ const { customers } = useCustomers({ limit: 1e3 });
1179
+ return useMemo(() => {
1180
+ return customers == null ? void 0 : customers.map((customer) => {
1181
+ return {
1182
+ label: customer.email,
1183
+ value: customer.id
1184
+ };
1185
+ });
1186
+ }, [customers]);
1187
+ };
1188
+ const useCustomerFilters = () => {
1189
+ const customerFilterOptions = useCustomerFilterOptions();
1190
+ return useMemo(() => {
1191
+ return [
1192
+ filterHelper$3.accessor("customer_id", {
1193
+ type: "select",
1194
+ label: "Owner",
1195
+ options: customerFilterOptions ?? []
1196
+ })
1197
+ ];
1198
+ }, [customerFilterOptions]);
1199
+ };
1200
+ const useGiftCardFilters = () => {
1201
+ const dateFilterOptions = useDataTableDateFilters$1();
1202
+ const customerFilterOptions = useCustomerFilters();
1203
+ return useMemo(() => {
1204
+ return [...dateFilterOptions, ...customerFilterOptions];
1205
+ }, [dateFilterOptions, customerFilterOptions]);
1206
+ };
1207
+ const useGiftCardTableQuery = ({
1208
+ prefix,
1209
+ pageSize = 20
1210
+ }) => {
1211
+ const queryObject = useQueryParams(
1212
+ ["offset", "customer_id", "created_at", "updated_at"],
1213
+ prefix
1214
+ );
1215
+ const { offset, created_at, updated_at, customer_id, ...rest } = queryObject;
1216
+ const searchParams = {
1217
+ limit: pageSize,
1218
+ offset: offset ? Number(offset) : 0,
1219
+ created_at: created_at ? JSON.parse(created_at) : void 0,
1220
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
1221
+ customer_id: customer_id ? JSON.parse(customer_id) : void 0,
1222
+ ...rest
1223
+ };
1224
+ return searchParams;
1225
+ };
1226
+ const PAGE_SIZE$6 = 10;
1227
+ function GiftCardsTable() {
1228
+ const queryParams = useGiftCardTableQuery({
1229
+ pageSize: PAGE_SIZE$6
1230
+ });
1231
+ const {
1232
+ gift_cards: giftCards,
1233
+ isPending,
1234
+ count: count2
1235
+ } = useGiftCards({
1236
+ ...queryParams,
1237
+ order: queryParams.order ?? "-created_at",
1238
+ fields: "+line_item.product.title"
970
1239
  });
1240
+ const columns = useGiftCardTableColumns();
1241
+ const filters = useGiftCardFilters();
1242
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1243
+ /* @__PURE__ */ jsx(Container$1, { className: "p-0", children: /* @__PURE__ */ jsx(
1244
+ DataTable,
1245
+ {
1246
+ data: giftCards,
1247
+ getRowId: (row) => row.id,
1248
+ columns,
1249
+ filters,
1250
+ isLoading: isPending,
1251
+ pageSize: PAGE_SIZE$6,
1252
+ rowCount: count2,
1253
+ enableSearch: false,
1254
+ heading: "Gift Cards",
1255
+ rowHref: (row) => `${row.id}`,
1256
+ emptyState: {
1257
+ empty: {
1258
+ heading: "No gift cards found",
1259
+ description: "Create a new gift card to get started."
1260
+ },
1261
+ filtered: {
1262
+ heading: "No results found",
1263
+ description: "No gift cards match your filter criteria."
1264
+ }
1265
+ }
1266
+ }
1267
+ ) }),
1268
+ /* @__PURE__ */ jsx(Outlet, {})
1269
+ ] });
1270
+ }
1271
+ const GiftCardsPage = () => {
1272
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1273
+ /* @__PURE__ */ jsx(
1274
+ TwoColumnLayout,
1275
+ {
1276
+ firstCol: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(GiftCardsTable, {}) }),
1277
+ secondCol: /* @__PURE__ */ jsx(GiftCardProductsSection, {})
1278
+ }
1279
+ ),
1280
+ /* @__PURE__ */ jsx(Toaster, {})
1281
+ ] });
971
1282
  };
1283
+ const config$2 = defineRouteConfig({
1284
+ label: "Gift Cards",
1285
+ icon: Gift
1286
+ });
972
1287
  /**
973
1288
  * table-core
974
1289
  *
@@ -3744,24 +4059,24 @@ const VariantCell = ({ variants }) => {
3744
4059
  const VariantHeader = () => {
3745
4060
  return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { children: "Denominations" }) });
3746
4061
  };
3747
- const columnHelper$a = createColumnHelper();
4062
+ const columnHelper$9 = createColumnHelper();
3748
4063
  const useGiftCardProductsTableColumns = () => {
3749
4064
  return useMemo(
3750
4065
  () => [
3751
- columnHelper$a.display({
4066
+ columnHelper$9.display({
3752
4067
  id: "product",
3753
4068
  header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
3754
4069
  cell: ({ row }) => /* @__PURE__ */ jsx(ProductCell, { product: row.original })
3755
4070
  }),
3756
- columnHelper$a.accessor("sales_channels", {
4071
+ columnHelper$9.accessor("sales_channels", {
3757
4072
  header: () => /* @__PURE__ */ jsx(SalesChannelHeader, {}),
3758
4073
  cell: ({ row }) => /* @__PURE__ */ jsx(SalesChannelsCell, { salesChannels: row.original.sales_channels })
3759
4074
  }),
3760
- columnHelper$a.accessor("variants", {
4075
+ columnHelper$9.accessor("variants", {
3761
4076
  header: () => /* @__PURE__ */ jsx(VariantHeader, {}),
3762
4077
  cell: ({ row }) => /* @__PURE__ */ jsx(VariantCell, { variants: row.original.variants })
3763
4078
  }),
3764
- columnHelper$a.accessor("status", {
4079
+ columnHelper$9.accessor("status", {
3765
4080
  header: () => /* @__PURE__ */ jsx(ProductStatusHeader, {}),
3766
4081
  cell: ({ row }) => /* @__PURE__ */ jsx(ProductStatusCell, { status: row.original.status })
3767
4082
  })
@@ -3769,102 +4084,11 @@ const useGiftCardProductsTableColumns = () => {
3769
4084
  []
3770
4085
  );
3771
4086
  };
3772
- const LOCALE = enUS;
3773
- const getFullDate = ({
3774
- date,
3775
- includeTime = false
3776
- }) => {
3777
- const ensuredDate = new Date(date);
3778
- if (isNaN(ensuredDate.getTime())) {
3779
- return "";
3780
- }
3781
- const timeFormat = includeTime ? "p" : "";
3782
- return format$1(ensuredDate, `PP ${timeFormat}`, {
3783
- locale: LOCALE
3784
- });
3785
- };
3786
- const filterHelper$4 = createDataTableFilterHelper();
3787
- const useDateFilterOptions$1 = () => {
3788
- const today = useMemo(() => {
3789
- const date = /* @__PURE__ */ new Date();
3790
- date.setHours(0, 0, 0, 0);
3791
- return date;
3792
- }, []);
3793
- return useMemo(() => {
3794
- return [
3795
- {
3796
- label: "Today",
3797
- value: {
3798
- $gte: today.toISOString()
3799
- }
3800
- },
3801
- {
3802
- label: "Last 7 days",
3803
- value: {
3804
- $gte: subDays(today, 7).toISOString()
3805
- // 7 days ago
3806
- }
3807
- },
3808
- {
3809
- label: "Last 30 days",
3810
- value: {
3811
- $gte: subDays(today, 30).toISOString()
3812
- // 30 days ago
3813
- }
3814
- },
3815
- {
3816
- label: "Last 90 days",
3817
- value: {
3818
- $gte: subDays(today, 90).toISOString()
3819
- // 90 days ago
3820
- }
3821
- },
3822
- {
3823
- label: "Last 12 months",
3824
- value: {
3825
- $gte: subMonths(today, 12).toISOString()
3826
- // 12 months ago
3827
- }
3828
- }
3829
- ];
3830
- }, [today]);
3831
- };
3832
- const useDataTableDateFilters$1 = (disableRangeOption) => {
3833
- const dateFilterOptions = useDateFilterOptions$1();
3834
- const rangeOptions = useMemo(() => {
3835
- return {
3836
- rangeOptionStartLabel: "Starting",
3837
- rangeOptionEndLabel: "Ending",
3838
- rangeOptionLabel: "Custom",
3839
- options: dateFilterOptions
3840
- };
3841
- }, [disableRangeOption, dateFilterOptions]);
3842
- return useMemo(() => {
3843
- return [
3844
- filterHelper$4.accessor("created_at", {
3845
- type: "date",
3846
- label: "Created at",
3847
- format: "date",
3848
- formatDateValue: (date) => getFullDate({ date }),
3849
- options: dateFilterOptions,
3850
- ...rangeOptions
3851
- }),
3852
- filterHelper$4.accessor("updated_at", {
3853
- type: "date",
3854
- label: "Updated at",
3855
- format: "date",
3856
- formatDateValue: (date) => getFullDate({ date }),
3857
- options: dateFilterOptions,
3858
- ...rangeOptions
3859
- })
3860
- ];
3861
- }, [dateFilterOptions, getFullDate, rangeOptions]);
3862
- };
3863
- const useGiftCardProductsFilters = () => {
3864
- const dateFilterOptions = useDataTableDateFilters$1();
3865
- return useMemo(() => {
3866
- return [...dateFilterOptions];
3867
- }, [dateFilterOptions]);
4087
+ const useGiftCardProductsFilters = () => {
4088
+ const dateFilterOptions = useDataTableDateFilters$1();
4089
+ return useMemo(() => {
4090
+ return [...dateFilterOptions];
4091
+ }, [dateFilterOptions]);
3868
4092
  };
3869
4093
  const useGiftCardProductsTableQuery = ({
3870
4094
  prefix,
@@ -3885,10 +4109,10 @@ const useGiftCardProductsTableQuery = ({
3885
4109
  };
3886
4110
  return searchParams;
3887
4111
  };
3888
- const PAGE_SIZE$6 = 10;
4112
+ const PAGE_SIZE$5 = 10;
3889
4113
  function GiftCardProductsTable() {
3890
4114
  const queryParams = useGiftCardProductsTableQuery({
3891
- pageSize: PAGE_SIZE$6
4115
+ pageSize: PAGE_SIZE$5
3892
4116
  });
3893
4117
  const {
3894
4118
  products: giftCardProducts,
@@ -3910,7 +4134,7 @@ function GiftCardProductsTable() {
3910
4134
  columns,
3911
4135
  filters,
3912
4136
  isLoading: isPending,
3913
- pageSize: PAGE_SIZE$6,
4137
+ pageSize: PAGE_SIZE$5,
3914
4138
  rowCount: count2,
3915
4139
  enableSearch: false,
3916
4140
  heading: "Gift Card Products",
@@ -3940,7 +4164,7 @@ const GiftCardProductsPage = () => {
3940
4164
  /* @__PURE__ */ jsx(Toaster, {})
3941
4165
  ] });
3942
4166
  };
3943
- const config$2 = defineRouteConfig({
4167
+ const config$1 = defineRouteConfig({
3944
4168
  label: "Gift Cards",
3945
4169
  nested: "/products"
3946
4170
  });
@@ -17806,7 +18030,7 @@ const GiftCardProductCreateDenominationsForm = ({
17806
18030
  }
17807
18031
  ) });
17808
18032
  };
17809
- const columnHelper$9 = createDataGridHelper();
18033
+ const columnHelper$8 = createDataGridHelper();
17810
18034
  const useColumns$3 = ({
17811
18035
  denominations = [],
17812
18036
  currencies: currencies2 = [],
@@ -17815,7 +18039,7 @@ const useColumns$3 = ({
17815
18039
  }) => {
17816
18040
  return useMemo(
17817
18041
  () => [
17818
- columnHelper$9.column({
18042
+ columnHelper$8.column({
17819
18043
  id: "denominations",
17820
18044
  header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: "Denomination" }) }),
17821
18045
  cell: (context) => {
@@ -17823,7 +18047,7 @@ const useColumns$3 = ({
17823
18047
  },
17824
18048
  disableHiding: true
17825
18049
  }),
17826
- columnHelper$9.column({
18050
+ columnHelper$8.column({
17827
18051
  id: "sku",
17828
18052
  name: "SKU",
17829
18053
  header: "SKU",
@@ -23461,12 +23685,12 @@ const useDate = () => {
23461
23685
  getRelativeDate: getRelativeDate2
23462
23686
  };
23463
23687
  };
23464
- const columnHelper$8 = createDataTableColumnHelper();
23688
+ const columnHelper$7 = createDataTableColumnHelper();
23465
23689
  const useDataTableDateColumns = () => {
23466
23690
  const { getFullDate: getFullDate2 } = useDate();
23467
23691
  return useMemo(() => {
23468
23692
  return [
23469
- columnHelper$8.accessor("created_at", {
23693
+ columnHelper$7.accessor("created_at", {
23470
23694
  header: "Created at",
23471
23695
  cell: ({ row }) => {
23472
23696
  return /* @__PURE__ */ jsx(
@@ -23484,7 +23708,7 @@ const useDataTableDateColumns = () => {
23484
23708
  sortAscLabel: "Asc",
23485
23709
  sortDescLabel: "Desc"
23486
23710
  }),
23487
- columnHelper$8.accessor("updated_at", {
23711
+ columnHelper$7.accessor("updated_at", {
23488
23712
  header: "Updated at",
23489
23713
  cell: ({ row }) => {
23490
23714
  return /* @__PURE__ */ jsx(
@@ -23505,19 +23729,19 @@ const useDataTableDateColumns = () => {
23505
23729
  ];
23506
23730
  }, [getFullDate2]);
23507
23731
  };
23508
- const columnHelper$7 = createDataTableColumnHelper();
23732
+ const columnHelper$6 = createDataTableColumnHelper();
23509
23733
  const useSalesChannelTableColumns = () => {
23510
23734
  const dateColumns = useDataTableDateColumns();
23511
23735
  return useMemo(
23512
23736
  () => [
23513
- columnHelper$7.accessor("name", {
23737
+ columnHelper$6.accessor("name", {
23514
23738
  header: () => "Name",
23515
23739
  enableSorting: true,
23516
23740
  sortLabel: "Name",
23517
23741
  sortAscLabel: "Asc",
23518
23742
  sortDescLabel: "Desc"
23519
23743
  }),
23520
- columnHelper$7.accessor("description", {
23744
+ columnHelper$6.accessor("description", {
23521
23745
  header: () => "Description",
23522
23746
  cell: ({ getValue }) => {
23523
23747
  return /* @__PURE__ */ jsx(Tooltip, { content: getValue(), children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: getValue() }) }) });
@@ -23529,7 +23753,7 @@ const useSalesChannelTableColumns = () => {
23529
23753
  maxSize: 250,
23530
23754
  minSize: 100
23531
23755
  }),
23532
- columnHelper$7.accessor("is_disabled", {
23756
+ columnHelper$6.accessor("is_disabled", {
23533
23757
  header: () => "Status",
23534
23758
  enableSorting: true,
23535
23759
  sortLabel: "Status",
@@ -23560,7 +23784,7 @@ const useSalesChannelTableEmptyState = () => {
23560
23784
  return content;
23561
23785
  }, []);
23562
23786
  };
23563
- const filterHelper$3 = createDataTableFilterHelper();
23787
+ const filterHelper$2 = createDataTableFilterHelper();
23564
23788
  const useDateFilterOptions = () => {
23565
23789
  const today = useMemo(() => {
23566
23790
  const date = /* @__PURE__ */ new Date();
@@ -23619,7 +23843,7 @@ const useDataTableDateFilters = (disableRangeOption) => {
23619
23843
  }, [disableRangeOption, dateFilterOptions]);
23620
23844
  return useMemo(() => {
23621
23845
  return [
23622
- filterHelper$3.accessor("created_at", {
23846
+ filterHelper$2.accessor("created_at", {
23623
23847
  type: "date",
23624
23848
  label: "Created At",
23625
23849
  format: "date",
@@ -23627,7 +23851,7 @@ const useDataTableDateFilters = (disableRangeOption) => {
23627
23851
  options: dateFilterOptions,
23628
23852
  ...rangeOptions
23629
23853
  }),
23630
- filterHelper$3.accessor("updated_at", {
23854
+ filterHelper$2.accessor("updated_at", {
23631
23855
  type: "date",
23632
23856
  label: "Updated At",
23633
23857
  format: "date",
@@ -23638,12 +23862,12 @@ const useDataTableDateFilters = (disableRangeOption) => {
23638
23862
  ];
23639
23863
  }, [dateFilterOptions, getFullDate2, rangeOptions]);
23640
23864
  };
23641
- const filterHelper$2 = createDataTableFilterHelper();
23865
+ const filterHelper$1 = createDataTableFilterHelper();
23642
23866
  const useSalesChannelTableFilters = () => {
23643
23867
  const dateFilters = useDataTableDateFilters();
23644
23868
  return useMemo(
23645
23869
  () => [
23646
- filterHelper$2.accessor("is_disabled", {
23870
+ filterHelper$1.accessor("is_disabled", {
23647
23871
  label: "Status",
23648
23872
  type: "radio",
23649
23873
  options: [
@@ -23784,7 +24008,7 @@ const PRODUCT_CREATE_FORM_DEFAULTS = {
23784
24008
  weight: "",
23785
24009
  width: ""
23786
24010
  };
23787
- const PAGE_SIZE$5 = 50;
24011
+ const PAGE_SIZE$4 = 50;
23788
24012
  const GiftCardProductSalesChannelStackedModal = ({
23789
24013
  form
23790
24014
  }) => {
@@ -23795,7 +24019,7 @@ const GiftCardProductSalesChannelStackedModal = ({
23795
24019
  );
23796
24020
  const [state, setState] = useState([]);
23797
24021
  const searchParams = useSalesChannelTableQuery({
23798
- pageSize: PAGE_SIZE$5,
24022
+ pageSize: PAGE_SIZE$4,
23799
24023
  prefix: SC_STACKED_MODAL_ID
23800
24024
  });
23801
24025
  const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
@@ -23864,7 +24088,7 @@ const GiftCardProductSalesChannelStackedModal = ({
23864
24088
  filters,
23865
24089
  emptyState,
23866
24090
  rowCount: count2,
23867
- pageSize: PAGE_SIZE$5,
24091
+ pageSize: PAGE_SIZE$4,
23868
24092
  getRowId: (row) => row.id,
23869
24093
  rowSelection: {
23870
24094
  state: rowSelection,
@@ -23881,10 +24105,10 @@ const GiftCardProductSalesChannelStackedModal = ({
23881
24105
  ] }) })
23882
24106
  ] });
23883
24107
  };
23884
- const columnHelper$6 = createDataTableColumnHelper();
24108
+ const columnHelper$5 = createDataTableColumnHelper();
23885
24109
  const useColumns$2 = () => {
23886
24110
  const base = useSalesChannelTableColumns();
23887
- return useMemo(() => [columnHelper$6.select(), ...base], [base]);
24111
+ return useMemo(() => [columnHelper$5.select(), ...base], [base]);
23888
24112
  };
23889
24113
  const GiftCardProductCreateOrganizeForm = ({
23890
24114
  form
@@ -24233,39 +24457,23 @@ const GiftCardProductCreate = () => {
24233
24457
  )
24234
24458
  ] });
24235
24459
  };
24236
- function getRelativeDate(date) {
24237
- const now = /* @__PURE__ */ new Date();
24238
- return formatDistance(sub(new Date(date), { minutes: 0 }), now, {
24239
- addSuffix: true,
24240
- includeSeconds: false
24241
- });
24242
- }
24243
- function formatDate(date, withTime = true) {
24244
- if (!date) {
24245
- return "-";
24246
- }
24247
- if (withTime) {
24248
- return format$1(new Date(date), "dd MMM, yyyy, HH:mm:ss");
24249
- }
24250
- return format$1(new Date(date), "dd MMM, yyyy");
24251
- }
24252
- const columnHelper$5 = createDataTableColumnHelper();
24460
+ const columnHelper$4 = createDataTableColumnHelper();
24253
24461
  const useStoreCreditAccountTableColumns = () => {
24254
24462
  return useMemo(() => {
24255
24463
  return [
24256
- columnHelper$5.accessor("currency_code", {
24464
+ columnHelper$4.accessor("currency_code", {
24257
24465
  header: "Currency",
24258
24466
  cell: ({ row }) => {
24259
24467
  return /* @__PURE__ */ jsx(Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
24260
24468
  }
24261
24469
  }),
24262
- columnHelper$5.accessor("customer.email", {
24470
+ columnHelper$4.accessor("customer.email", {
24263
24471
  header: "Customer",
24264
24472
  cell: ({ row }) => {
24265
24473
  return row.original.customer.email;
24266
24474
  }
24267
24475
  }),
24268
- columnHelper$5.accessor("balance", {
24476
+ columnHelper$4.accessor("balance", {
24269
24477
  header: "Balance",
24270
24478
  cell: ({ row }) => {
24271
24479
  return formatAmount(
@@ -24274,7 +24482,7 @@ const useStoreCreditAccountTableColumns = () => {
24274
24482
  );
24275
24483
  }
24276
24484
  }),
24277
- columnHelper$5.accessor("credits", {
24485
+ columnHelper$4.accessor("credits", {
24278
24486
  header: "Credits",
24279
24487
  cell: ({ row }) => {
24280
24488
  return formatAmount(
@@ -24283,7 +24491,7 @@ const useStoreCreditAccountTableColumns = () => {
24283
24491
  );
24284
24492
  }
24285
24493
  }),
24286
- columnHelper$5.accessor("debits", {
24494
+ columnHelper$4.accessor("debits", {
24287
24495
  header: "Debits",
24288
24496
  cell: ({ row }) => {
24289
24497
  return formatAmount(
@@ -24292,47 +24500,13 @@ const useStoreCreditAccountTableColumns = () => {
24292
24500
  );
24293
24501
  }
24294
24502
  }),
24295
- columnHelper$5.accessor("created_at", {
24503
+ columnHelper$4.accessor("created_at", {
24296
24504
  header: "Created at",
24297
24505
  cell: ({ row }) => getRelativeDate(row.original.created_at)
24298
24506
  })
24299
24507
  ];
24300
24508
  }, []);
24301
24509
  };
24302
- const CUSTOMERS_QUERY_KEY = "customers";
24303
- const customersQueryKeys = queryKeysFactory(CUSTOMERS_QUERY_KEY);
24304
- const useCustomers = (query, options) => {
24305
- const { data, ...rest } = useQuery({
24306
- queryFn: () => sdk.admin.customer.list(query),
24307
- queryKey: customersQueryKeys.list(query),
24308
- ...options
24309
- });
24310
- return { ...data, ...rest };
24311
- };
24312
- const filterHelper$1 = createDataTableFilterHelper();
24313
- const useCustomerFilterOptions = () => {
24314
- const { customers } = useCustomers({ limit: 1e3 });
24315
- return useMemo(() => {
24316
- return customers == null ? void 0 : customers.map((customer) => {
24317
- return {
24318
- label: customer.email,
24319
- value: customer.id
24320
- };
24321
- });
24322
- }, [customers]);
24323
- };
24324
- const useCustomerFilters = () => {
24325
- const customerFilterOptions = useCustomerFilterOptions();
24326
- return useMemo(() => {
24327
- return [
24328
- filterHelper$1.accessor("customer_id", {
24329
- type: "select",
24330
- label: "Owner",
24331
- options: customerFilterOptions ?? []
24332
- })
24333
- ];
24334
- }, [customerFilterOptions]);
24335
- };
24336
24510
  const useStoreCreditAccountFilters = () => {
24337
24511
  const dateFilterOptions = useDataTableDateFilters$1();
24338
24512
  const customerFilterOptions = useCustomerFilters();
@@ -24367,10 +24541,10 @@ const useStoreCreditAccountsTableQuery = ({
24367
24541
  };
24368
24542
  return searchParams;
24369
24543
  };
24370
- const PAGE_SIZE$4 = 10;
24544
+ const PAGE_SIZE$3 = 10;
24371
24545
  function StoreCreditAccountsTable() {
24372
24546
  const queryParams = useStoreCreditAccountsTableQuery({
24373
- pageSize: PAGE_SIZE$4
24547
+ pageSize: PAGE_SIZE$3
24374
24548
  });
24375
24549
  const {
24376
24550
  store_credit_accounts: storeCreditAccounts,
@@ -24391,7 +24565,7 @@ function StoreCreditAccountsTable() {
24391
24565
  columns,
24392
24566
  filters,
24393
24567
  isLoading: isPending,
24394
- pageSize: PAGE_SIZE$4,
24568
+ pageSize: PAGE_SIZE$3,
24395
24569
  rowCount: count2,
24396
24570
  enableSearch: false,
24397
24571
  heading: "Store Credit Accounts",
@@ -24417,630 +24591,46 @@ const StoreCreditAccountsPage = () => {
24417
24591
  /* @__PURE__ */ jsx(Toaster, {})
24418
24592
  ] });
24419
24593
  };
24420
- const config$1 = defineRouteConfig({
24594
+ const config = defineRouteConfig({
24421
24595
  label: "Store Credits",
24422
24596
  icon: CreditCard
24423
24597
  });
24424
- const TwoColumnLayout = ({
24425
- firstCol,
24426
- secondCol
24427
- }) => {
24428
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start", children: [
24429
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-y-3", children: firstCol }),
24430
- /* @__PURE__ */ jsx("div", { className: "flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]", children: secondCol })
24431
- ] });
24598
+ function _objectWithoutPropertiesLoose(r2, e2) {
24599
+ if (null == r2) return {};
24600
+ var t2 = {};
24601
+ for (var n2 in r2) if ({}.hasOwnProperty.call(r2, n2)) {
24602
+ if (-1 !== e2.indexOf(n2)) continue;
24603
+ t2[n2] = r2[n2];
24604
+ }
24605
+ return t2;
24606
+ }
24607
+ var initialState$5 = {};
24608
+ var Context$5 = /* @__PURE__ */ createContext(initialState$5);
24609
+ var reducer$5 = (state, action) => _extends({}, state, action);
24610
+ var useShowToolsStore = () => {
24611
+ return useContext(Context$5);
24432
24612
  };
24433
- const GiftCardProductsSection = () => {
24434
- const { products: giftCardProducts } = useProducts({
24435
- is_giftcard: true
24436
- });
24437
- if (!(giftCardProducts == null ? void 0 : giftCardProducts.length)) {
24438
- return;
24439
- }
24440
- return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
24441
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
24442
- /* @__PURE__ */ jsx(Header$5, { title: "Gift Card Products" }),
24443
- /* @__PURE__ */ jsx(
24444
- Link,
24445
- {
24446
- to: `/gift-card-products/create`,
24447
- className: "text-ui-fg-muted text-sm px-6",
24448
- children: "Create gift card product"
24449
- }
24450
- )
24451
- ] }),
24452
- giftCardProducts.map((giftCardProduct) => /* @__PURE__ */ jsx(
24453
- SidebarLink,
24454
- {
24455
- to: `/gift-card-products/${giftCardProduct.id}`,
24456
- labelKey: giftCardProduct.title,
24457
- descriptionKey: giftCardProduct.title,
24458
- icon: /* @__PURE__ */ jsx(Tag, {})
24459
- }
24460
- ))
24461
- ] });
24462
- };
24463
- const columnHelper$4 = createDataTableColumnHelper();
24464
- const useGiftCardTableColumns = () => {
24465
- return useMemo(() => {
24466
- return [
24467
- columnHelper$4.accessor("line_item.product.title", {
24468
- header: "Product",
24469
- cell: ({ row }) => {
24470
- var _a, _b;
24471
- return ((_b = (_a = row.original.line_item) == null ? void 0 : _a.product) == null ? void 0 : _b.title) || "Custom Gift Card";
24472
- }
24473
- }),
24474
- columnHelper$4.accessor("customer.first_name", {
24475
- header: "Owner",
24476
- cell: ({ row }) => {
24477
- if (!row.original.customer) {
24478
- return "N/A";
24479
- }
24480
- const fullName = [
24481
- row.original.customer.first_name,
24482
- row.original.customer.last_name
24483
- ];
24484
- if (fullName.join("").length > 0) {
24485
- return fullName.join(" ");
24486
- }
24487
- return row.original.customer.email;
24488
- }
24489
- }),
24490
- columnHelper$4.accessor("created_at", {
24491
- header: "Date issued",
24492
- cell: ({ row }) => getRelativeDate(row.original.created_at)
24493
- }),
24494
- columnHelper$4.accessor("status", {
24495
- header: "Status",
24496
- cell: ({ row }) => {
24497
- const status = getGiftCardStatus(row.original);
24498
- const color = getGiftCardStatusColor(status);
24499
- return /* @__PURE__ */ jsx(StatusBadge, { color, children: status });
24500
- }
24501
- }),
24502
- columnHelper$4.accessor("value", {
24503
- header: "Value",
24504
- cell: ({ row }) => {
24505
- return formatAmount(row.original.value, row.original.currency_code);
24506
- }
24507
- })
24508
- ];
24509
- }, []);
24510
- };
24511
- const useGiftCardFilters = () => {
24512
- const dateFilterOptions = useDataTableDateFilters$1();
24513
- const customerFilterOptions = useCustomerFilters();
24514
- return useMemo(() => {
24515
- return [...dateFilterOptions, ...customerFilterOptions];
24516
- }, [dateFilterOptions, customerFilterOptions]);
24517
- };
24518
- const useGiftCardTableQuery = ({
24519
- prefix,
24520
- pageSize = 20
24521
- }) => {
24522
- const queryObject = useQueryParams(
24523
- ["offset", "customer_id", "created_at", "updated_at"],
24524
- prefix
24525
- );
24526
- const { offset, created_at, updated_at, customer_id, ...rest } = queryObject;
24527
- const searchParams = {
24528
- limit: pageSize,
24529
- offset: offset ? Number(offset) : 0,
24530
- created_at: created_at ? JSON.parse(created_at) : void 0,
24531
- updated_at: updated_at ? JSON.parse(updated_at) : void 0,
24532
- customer_id: customer_id ? JSON.parse(customer_id) : void 0,
24533
- ...rest
24534
- };
24535
- return searchParams;
24536
- };
24537
- const PAGE_SIZE$3 = 10;
24538
- function GiftCardsTable() {
24539
- const queryParams = useGiftCardTableQuery({
24540
- pageSize: PAGE_SIZE$3
24541
- });
24542
- const {
24543
- gift_cards: giftCards,
24544
- isPending,
24545
- count: count2
24546
- } = useGiftCards({
24547
- ...queryParams,
24548
- order: queryParams.order ?? "-created_at",
24549
- fields: "+line_item.product.title"
24550
- });
24551
- const columns = useGiftCardTableColumns();
24552
- const filters = useGiftCardFilters();
24553
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
24554
- /* @__PURE__ */ jsx(Container$1, { className: "p-0", children: /* @__PURE__ */ jsx(
24555
- DataTable,
24556
- {
24557
- data: giftCards,
24558
- getRowId: (row) => row.id,
24559
- columns,
24560
- filters,
24561
- isLoading: isPending,
24562
- pageSize: PAGE_SIZE$3,
24563
- rowCount: count2,
24564
- enableSearch: false,
24565
- heading: "Gift Cards",
24566
- rowHref: (row) => `${row.id}`,
24567
- emptyState: {
24568
- empty: {
24569
- heading: "No gift cards found",
24570
- description: "Create a new gift card to get started."
24571
- },
24572
- filtered: {
24573
- heading: "No results found",
24574
- description: "No gift cards match your filter criteria."
24575
- }
24576
- }
24577
- }
24578
- ) }),
24579
- /* @__PURE__ */ jsx(Outlet, {})
24580
- ] });
24581
- }
24582
- const GiftCardsPage = () => {
24583
- return /* @__PURE__ */ jsxs(Fragment, { children: [
24584
- /* @__PURE__ */ jsx(
24585
- TwoColumnLayout,
24586
- {
24587
- firstCol: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(GiftCardsTable, {}) }),
24588
- secondCol: /* @__PURE__ */ jsx(GiftCardProductsSection, {})
24589
- }
24590
- ),
24591
- /* @__PURE__ */ jsx(Toaster, {})
24592
- ] });
24593
- };
24594
- const config = defineRouteConfig({
24595
- label: "Gift Cards",
24596
- icon: Gift
24597
- });
24598
- const StoreCreditAccountBalanceSection = ({
24599
- storeCreditAccount
24600
- }) => {
24601
- if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
24602
- return;
24603
- }
24604
- return /* @__PURE__ */ jsx(Container$1, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
24605
- /* @__PURE__ */ jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
24606
- /* @__PURE__ */ jsxs("div", { children: [
24607
- /* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
24608
- /* @__PURE__ */ jsx(
24609
- Text,
24610
- {
24611
- weight: "plus",
24612
- size: "xlarge",
24613
- className: "tabular-nums text-ui-fg-base",
24614
- children: formatAmount(
24615
- storeCreditAccount.balance,
24616
- storeCreditAccount.currency_code
24617
- )
24618
- }
24619
- )
24620
- ] })
24621
- ] }) });
24622
- };
24623
- var toggleSelection = function() {
24624
- var selection = document.getSelection();
24625
- if (!selection.rangeCount) {
24626
- return function() {
24627
- };
24628
- }
24629
- var active = document.activeElement;
24630
- var ranges = [];
24631
- for (var i2 = 0; i2 < selection.rangeCount; i2++) {
24632
- ranges.push(selection.getRangeAt(i2));
24633
- }
24634
- switch (active.tagName.toUpperCase()) {
24635
- case "INPUT":
24636
- case "TEXTAREA":
24637
- active.blur();
24638
- break;
24639
- default:
24640
- active = null;
24641
- break;
24642
- }
24643
- selection.removeAllRanges();
24644
- return function() {
24645
- selection.type === "Caret" && selection.removeAllRanges();
24646
- if (!selection.rangeCount) {
24647
- ranges.forEach(function(range) {
24648
- selection.addRange(range);
24649
- });
24650
- }
24651
- active && active.focus();
24652
- };
24653
- };
24654
- var deselectCurrent = toggleSelection;
24655
- var clipboardToIE11Formatting = {
24656
- "text/plain": "Text",
24657
- "text/html": "Url",
24658
- "default": "Text"
24659
- };
24660
- var defaultMessage = "Copy to clipboard: #{key}, Enter";
24661
- function format(message) {
24662
- var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
24663
- return message.replace(/#{\s*key\s*}/g, copyKey);
24664
- }
24665
- function copy(text2, options) {
24666
- var debug2, message, reselectPrevious, range, selection, mark, success = false;
24667
- if (!options) {
24668
- options = {};
24669
- }
24670
- debug2 = options.debug || false;
24671
- try {
24672
- reselectPrevious = deselectCurrent();
24673
- range = document.createRange();
24674
- selection = document.getSelection();
24675
- mark = document.createElement("span");
24676
- mark.textContent = text2;
24677
- mark.ariaHidden = "true";
24678
- mark.style.all = "unset";
24679
- mark.style.position = "fixed";
24680
- mark.style.top = 0;
24681
- mark.style.clip = "rect(0, 0, 0, 0)";
24682
- mark.style.whiteSpace = "pre";
24683
- mark.style.webkitUserSelect = "text";
24684
- mark.style.MozUserSelect = "text";
24685
- mark.style.msUserSelect = "text";
24686
- mark.style.userSelect = "text";
24687
- mark.addEventListener("copy", function(e2) {
24688
- e2.stopPropagation();
24689
- if (options.format) {
24690
- e2.preventDefault();
24691
- if (typeof e2.clipboardData === "undefined") {
24692
- debug2 && console.warn("unable to use e.clipboardData");
24693
- debug2 && console.warn("trying IE specific stuff");
24694
- window.clipboardData.clearData();
24695
- var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
24696
- window.clipboardData.setData(format2, text2);
24697
- } else {
24698
- e2.clipboardData.clearData();
24699
- e2.clipboardData.setData(options.format, text2);
24700
- }
24701
- }
24702
- if (options.onCopy) {
24703
- e2.preventDefault();
24704
- options.onCopy(e2.clipboardData);
24705
- }
24706
- });
24707
- document.body.appendChild(mark);
24708
- range.selectNodeContents(mark);
24709
- selection.addRange(range);
24710
- var successful = document.execCommand("copy");
24711
- if (!successful) {
24712
- throw new Error("copy command was unsuccessful");
24713
- }
24714
- success = true;
24715
- } catch (err) {
24716
- debug2 && console.error("unable to copy using execCommand: ", err);
24717
- debug2 && console.warn("trying IE specific stuff");
24718
- try {
24719
- window.clipboardData.setData(options.format || "text", text2);
24720
- options.onCopy && options.onCopy(window.clipboardData);
24721
- success = true;
24722
- } catch (err2) {
24723
- debug2 && console.error("unable to copy using clipboardData: ", err2);
24724
- debug2 && console.error("falling back to prompt");
24725
- message = format("message" in options ? options.message : defaultMessage);
24726
- window.prompt(message, text2);
24727
- }
24728
- } finally {
24729
- if (selection) {
24730
- if (typeof selection.removeRange == "function") {
24731
- selection.removeRange(range);
24732
- } else {
24733
- selection.removeAllRanges();
24734
- }
24735
- }
24736
- if (mark) {
24737
- document.body.removeChild(mark);
24738
- }
24739
- reselectPrevious();
24740
- }
24741
- return success;
24742
- }
24743
- var copyToClipboard = copy;
24744
- const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
24745
- function DisplayId({ id, className }) {
24746
- const [open, setOpen] = useState(false);
24747
- const onClick = () => {
24748
- copy$1(id);
24749
- toast.success("Copied to clipboard");
24750
- };
24751
- return /* @__PURE__ */ jsx(Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs("span", { onClick, className: clx("cursor-pointer", className), children: [
24752
- "#",
24753
- id.slice(-7)
24754
- ] }) });
24755
- }
24756
- const StoreCreditAccountDetailsSection = ({
24757
- storeCreditAccount
24758
- }) => {
24759
- if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
24760
- return;
24761
- }
24762
- return /* @__PURE__ */ jsx(Container$1, { className: "grid grid-cols-2 gap-x-2 px-6 py-6", children: /* @__PURE__ */ jsxs(
24763
- Text,
24764
- {
24765
- weight: "plus",
24766
- size: "xlarge",
24767
- className: "text-ui-fg-base flex gap-x-4",
24768
- children: [
24769
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
24770
- /* @__PURE__ */ jsx(CreditCardIcon, { className: "inline" }),
24771
- " "
24772
- ] }),
24773
- /* @__PURE__ */ jsxs("div", { children: [
24774
- /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle", children: [
24775
- storeCreditAccount.currency_code.toUpperCase(),
24776
- " Account"
24777
- ] }),
24778
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsx(
24779
- Text,
24780
- {
24781
- weight: "regular",
24782
- size: "small",
24783
- className: "text-ui-fg-base flex gap-x-4",
24784
- children: /* @__PURE__ */ jsx(DisplayId, { id: storeCreditAccount.id })
24785
- }
24786
- ) })
24787
- ] })
24788
- ]
24789
- }
24790
- ) });
24791
- };
24792
- const transactionQueryKey = queryKeysFactory("transaction");
24793
- const useStoreCreditAccountTransactions = (id, query, options) => {
24794
- const fetchStoreCreditAccountTransactions = (query2, headers) => sdk.client.fetch(
24795
- `/admin/store-credit-accounts/${id}/transactions`,
24796
- {
24797
- query: query2,
24798
- headers
24799
- }
24800
- );
24801
- const { data, ...rest } = useQuery({
24802
- queryFn: () => fetchStoreCreditAccountTransactions(query),
24803
- queryKey: transactionQueryKey.list(query),
24804
- ...options
24805
- });
24806
- return { ...data, ...rest };
24807
- };
24808
- const columnHelper$3 = createDataTableColumnHelper();
24809
- const useTransactionsTableColumns = () => {
24810
- return useMemo(() => {
24811
- return [
24812
- columnHelper$3.accessor("id", {
24813
- header: "ID",
24814
- cell: ({ row }) => {
24815
- return /* @__PURE__ */ jsx(DisplayId, { id: row.original.id });
24816
- }
24817
- }),
24818
- columnHelper$3.accessor("created_at", {
24819
- header: "Created At",
24820
- cell: ({ row }) => formatDate(row.original.created_at, false)
24821
- }),
24822
- columnHelper$3.accessor("reference", {
24823
- header: "Reference",
24824
- cell: ({ row }) => {
24825
- var _a;
24826
- const prettyReference = (_a = row.original.reference) == null ? void 0 : _a.split("_").join(" ").split("-").join(" ");
24827
- return /* @__PURE__ */ jsx(Text, { className: "capitalize", children: prettyReference });
24828
- }
24829
- }),
24830
- columnHelper$3.accessor("reference_id", {
24831
- header: "Reference ID",
24832
- cell: ({ row }) => {
24833
- return /* @__PURE__ */ jsx(DisplayId, { id: row.original.reference_id });
24834
- }
24835
- }),
24836
- columnHelper$3.accessor("amount", {
24837
- header: "Amount",
24838
- cell: ({ row }) => {
24839
- return row.original.account.currency_code && formatAmount(
24840
- row.original.amount,
24841
- row.original.account.currency_code
24842
- );
24843
- }
24844
- })
24845
- ];
24846
- }, []);
24847
- };
24848
- const transactionGroupQueryKey = queryKeysFactory("transaction-group");
24849
- const useTransactionGroups = (query, options) => {
24850
- const fetchTransactionGroups = (query2, headers) => sdk.client.fetch(
24851
- `/admin/transaction-groups`,
24852
- {
24853
- query: query2,
24854
- headers
24855
- }
24856
- );
24857
- const { data, ...rest } = useQuery({
24858
- queryFn: () => fetchTransactionGroups(query),
24859
- queryKey: transactionGroupQueryKey.list(query),
24860
- ...options
24861
- });
24862
- return { ...data, ...rest };
24863
- };
24864
- const filterHelper = createDataTableFilterHelper();
24865
- const useTransactionGroupFilterOptions = () => {
24866
- const { transaction_groups } = useTransactionGroups({ limit: 1e3 });
24867
- return useMemo(() => {
24868
- return transaction_groups == null ? void 0 : transaction_groups.map((transactionGroup) => {
24869
- return {
24870
- label: transactionGroup.code,
24871
- value: transactionGroup.id
24872
- };
24873
- });
24874
- }, [transaction_groups]);
24875
- };
24876
- const useTransactionGroupFilters = () => {
24877
- const transactionGroupFilterOptions = useTransactionGroupFilterOptions();
24878
- return useMemo(() => {
24879
- return [
24880
- filterHelper.accessor("transaction_group_id", {
24881
- type: "select",
24882
- label: "Transaction Group",
24883
- options: transactionGroupFilterOptions ?? []
24884
- })
24885
- ];
24886
- }, [transactionGroupFilterOptions]);
24887
- };
24888
- const useTransactionsTableFilters = ({
24889
- transactionGroup
24890
- }) => {
24891
- const dateFilterOptions = useDataTableDateFilters$1();
24892
- const transactionGroupFilters = useTransactionGroupFilters();
24893
- return useMemo(() => {
24894
- if (transactionGroup) {
24895
- return [...dateFilterOptions];
24896
- }
24897
- return [...dateFilterOptions, ...transactionGroupFilters];
24898
- }, [dateFilterOptions, transactionGroupFilters, transactionGroup]);
24899
- };
24900
- const useTransactionsTableQuery = ({
24901
- prefix,
24902
- pageSize = 20
24903
- }) => {
24904
- const queryObject = useQueryParams(
24905
- [
24906
- "offset",
24907
- "limit",
24908
- "transaction_group_id",
24909
- "currency_code",
24910
- "created_at",
24911
- "updated_at"
24912
- ],
24913
- prefix
24914
- );
24915
- const {
24916
- offset,
24917
- limit,
24918
- created_at,
24919
- updated_at,
24920
- transaction_group_id,
24921
- ...rest
24922
- } = queryObject;
24923
- const searchParams = {
24924
- limit: limit ? Number(limit) : pageSize,
24925
- offset: offset ? Number(offset) : 0,
24926
- created_at: created_at ? JSON.parse(created_at) : void 0,
24927
- updated_at: updated_at ? JSON.parse(updated_at) : void 0,
24928
- transaction_group_id: transaction_group_id ? JSON.parse(transaction_group_id) : void 0,
24929
- ...rest
24930
- };
24931
- return searchParams;
24932
- };
24933
- const PAGE_SIZE$2 = 10;
24934
- function TransactionsTable({
24935
- id,
24936
- transactionGroup
24937
- }) {
24938
- const queryParams = useTransactionsTableQuery({
24939
- pageSize: PAGE_SIZE$2
24940
- });
24941
- const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
24942
- id,
24943
- {
24944
- ...queryParams,
24945
- transaction_group_id: transactionGroup == null ? void 0 : transactionGroup.id,
24946
- order: queryParams.order ?? "-created_at",
24947
- fields: "*account,*transaction_group"
24948
- }
24949
- );
24950
- const columns = useTransactionsTableColumns();
24951
- const filters = useTransactionsTableFilters({ transactionGroup });
24952
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
24953
- /* @__PURE__ */ jsx(Container$1, { className: "p-0", children: /* @__PURE__ */ jsx(
24954
- DataTable,
24955
- {
24956
- data: transactions ?? [],
24957
- getRowId: (row) => row.id,
24958
- columns,
24959
- filters,
24960
- isLoading,
24961
- pageSize: PAGE_SIZE$2,
24962
- rowCount: count2,
24963
- enableSearch: false,
24964
- heading: "Transactions",
24965
- emptyState: {
24966
- empty: {
24967
- heading: "No transactions found"
24968
- },
24969
- filtered: {
24970
- heading: "No results found",
24971
- description: "No transactions match your filter criteria."
24972
- }
24973
- }
24974
- }
24975
- ) }),
24976
- /* @__PURE__ */ jsx(Outlet, {})
24977
- ] });
24978
- }
24979
- const StoreCreditAccountPage = () => {
24980
- const { id } = useParams();
24981
- const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
24982
- id
24983
- );
24984
- if (!storeCreditAccount) {
24985
- return;
24986
- }
24987
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
24988
- TwoColumnLayout,
24989
- {
24990
- firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
24991
- /* @__PURE__ */ jsx(
24992
- StoreCreditAccountDetailsSection,
24993
- {
24994
- storeCreditAccount
24995
- }
24996
- ),
24997
- /* @__PURE__ */ jsx(TransactionsTable, { id: storeCreditAccount.id })
24998
- ] }),
24999
- secondCol: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
25000
- StoreCreditAccountBalanceSection,
25001
- {
25002
- storeCreditAccount
25003
- }
25004
- ) })
25005
- }
25006
- ) });
25007
- };
25008
- function _objectWithoutPropertiesLoose(r2, e2) {
25009
- if (null == r2) return {};
25010
- var t2 = {};
25011
- for (var n2 in r2) if ({}.hasOwnProperty.call(r2, n2)) {
25012
- if (-1 !== e2.indexOf(n2)) continue;
25013
- t2[n2] = r2[n2];
25014
- }
25015
- return t2;
25016
- }
25017
- var initialState$5 = {};
25018
- var Context$5 = /* @__PURE__ */ createContext(initialState$5);
25019
- var reducer$5 = (state, action) => _extends({}, state, action);
25020
- var useShowToolsStore = () => {
25021
- return useContext(Context$5);
25022
- };
25023
- var DispatchShowTools = /* @__PURE__ */ createContext(() => {
25024
- });
25025
- DispatchShowTools.displayName = "JVR.DispatchShowTools";
25026
- function useShowTools() {
25027
- return useReducer(reducer$5, initialState$5);
25028
- }
25029
- function useShowToolsDispatch() {
25030
- return useContext(DispatchShowTools);
25031
- }
25032
- var ShowTools = (_ref) => {
25033
- var {
25034
- initial,
25035
- dispatch,
25036
- children
25037
- } = _ref;
25038
- return /* @__PURE__ */ jsx(Context$5.Provider, {
25039
- value: initial,
25040
- children: /* @__PURE__ */ jsx(DispatchShowTools.Provider, {
25041
- value: dispatch,
25042
- children
25043
- })
24613
+ var DispatchShowTools = /* @__PURE__ */ createContext(() => {
24614
+ });
24615
+ DispatchShowTools.displayName = "JVR.DispatchShowTools";
24616
+ function useShowTools() {
24617
+ return useReducer(reducer$5, initialState$5);
24618
+ }
24619
+ function useShowToolsDispatch() {
24620
+ return useContext(DispatchShowTools);
24621
+ }
24622
+ var ShowTools = (_ref) => {
24623
+ var {
24624
+ initial,
24625
+ dispatch,
24626
+ children
24627
+ } = _ref;
24628
+ return /* @__PURE__ */ jsx(Context$5.Provider, {
24629
+ value: initial,
24630
+ children: /* @__PURE__ */ jsx(DispatchShowTools.Provider, {
24631
+ value: dispatch,
24632
+ children
24633
+ })
25044
24634
  });
25045
24635
  };
25046
24636
  ShowTools.displayName = "JVR.ShowTools";
@@ -27390,6 +26980,22 @@ const Copied = ({ style, value }) => {
27390
26980
  }
27391
26981
  return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, onClick: handler, children: /* @__PURE__ */ jsx(SquareTwoStack, { className: "text-ui-contrast-fg-secondary" }) });
27392
26982
  };
26983
+ const transactionGroupQueryKey = queryKeysFactory("transaction-group");
26984
+ const useTransactionGroups = (query, options) => {
26985
+ const fetchTransactionGroups = (query2, headers) => sdk.client.fetch(
26986
+ `/admin/transaction-groups`,
26987
+ {
26988
+ query: query2,
26989
+ headers
26990
+ }
26991
+ );
26992
+ const { data, ...rest } = useQuery({
26993
+ queryFn: () => fetchTransactionGroups(query),
26994
+ queryKey: transactionGroupQueryKey.list(query),
26995
+ ...options
26996
+ });
26997
+ return { ...data, ...rest };
26998
+ };
27393
26999
  const GiftCardBalanceSection = ({
27394
27000
  storeCreditAccount,
27395
27001
  giftCard
@@ -27614,81 +27220,385 @@ const GiftCardGeneralSection = ({ giftCard }) => {
27614
27220
  }
27615
27221
  ),
27616
27222
  /* @__PURE__ */ jsx(
27617
- SectionRow,
27223
+ SectionRow,
27224
+ {
27225
+ title: "Creation Date",
27226
+ value: getRelativeDate(giftCard.created_at)
27227
+ }
27228
+ )
27229
+ ] });
27230
+ };
27231
+ const GiftCardNoteSection = ({ giftCard }) => {
27232
+ if (!giftCard) {
27233
+ return;
27234
+ }
27235
+ return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
27236
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27237
+ /* @__PURE__ */ jsx(Header$5, { title: "Note" }),
27238
+ /* @__PURE__ */ jsx(Link, { to: "note", className: "text-ui-fg-muted text-sm px-6", children: "Edit note" })
27239
+ ] }),
27240
+ giftCard.note && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col", children: /* @__PURE__ */ jsx(
27241
+ Text,
27242
+ {
27243
+ size: "small",
27244
+ leading: "compact",
27245
+ className: "text-ui-fg-subtle",
27246
+ children: giftCard.note ?? ""
27247
+ }
27248
+ ) }) }) }) })
27249
+ ] });
27250
+ };
27251
+ const GiftCardOrderSection = ({ giftCard }) => {
27252
+ if (!giftCard || giftCard.reference !== "order") {
27253
+ return;
27254
+ }
27255
+ const { order, isLoading, isError, error } = useOrder(giftCard.reference_id);
27256
+ if (isError) {
27257
+ throw error;
27258
+ }
27259
+ if (isLoading) {
27260
+ return null;
27261
+ }
27262
+ return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
27263
+ /* @__PURE__ */ jsx(Header$5, { title: "Order" }),
27264
+ /* @__PURE__ */ jsx(
27265
+ SidebarLink,
27618
27266
  {
27619
- title: "Creation Date",
27620
- value: getRelativeDate(giftCard.created_at)
27267
+ to: `/orders/${order.id}`,
27268
+ labelKey: `#${order.display_id}`,
27269
+ icon: /* @__PURE__ */ jsx(ShoppingCart, {}),
27270
+ descriptionKey: `Order #${order.display_id}`
27621
27271
  }
27622
27272
  )
27623
27273
  ] });
27624
27274
  };
27625
- const GiftCardNoteSection = ({ giftCard }) => {
27275
+ const GiftCardOwnerSection = ({ giftCard }) => {
27626
27276
  if (!giftCard) {
27627
27277
  return;
27628
27278
  }
27629
27279
  return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
27630
27280
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27631
- /* @__PURE__ */ jsx(Header$5, { title: "Note" }),
27632
- /* @__PURE__ */ jsx(Link, { to: "note", className: "text-ui-fg-muted text-sm px-6", children: "Edit note" })
27281
+ /* @__PURE__ */ jsx(Header$5, { title: "Owner" }),
27282
+ giftCard.status !== GiftCardStatus.REDEEMED && /* @__PURE__ */ jsx(Link, { to: `owner`, className: "text-ui-fg-muted text-sm px-6", children: "Transfer ownership" })
27633
27283
  ] }),
27634
- giftCard.note && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col", children: /* @__PURE__ */ jsx(
27635
- Text,
27284
+ /* @__PURE__ */ jsx(
27285
+ SidebarLink,
27636
27286
  {
27637
- size: "small",
27638
- leading: "compact",
27639
- className: "text-ui-fg-subtle",
27640
- children: giftCard.note ?? ""
27287
+ to: `/customers/${giftCard.customer.id}`,
27288
+ labelKey: `${[
27289
+ giftCard.customer.first_name,
27290
+ giftCard.customer.last_name
27291
+ ].join(" ")}`,
27292
+ descriptionKey: giftCard.customer.email,
27293
+ icon: /* @__PURE__ */ jsx(UserMini, {})
27641
27294
  }
27642
- ) }) }) }) })
27295
+ )
27643
27296
  ] });
27644
27297
  };
27645
- const GiftCardOrderSection = ({ giftCard }) => {
27646
- if (!giftCard || giftCard.reference !== "order") {
27647
- return;
27648
- }
27649
- const { order, isLoading, isError, error } = useOrder(giftCard.reference_id);
27650
- if (isError) {
27651
- throw error;
27652
- }
27653
- if (isLoading) {
27654
- return null;
27655
- }
27656
- return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
27657
- /* @__PURE__ */ jsx(Header$5, { title: "Order" }),
27658
- /* @__PURE__ */ jsx(
27659
- SidebarLink,
27660
- {
27661
- to: `/orders/${order.id}`,
27662
- labelKey: `#${order.display_id}`,
27663
- icon: /* @__PURE__ */ jsx(ShoppingCart, {}),
27664
- descriptionKey: `Order #${order.display_id}`
27665
- }
27666
- )
27667
- ] });
27298
+ const transactionQueryKey = queryKeysFactory("transaction");
27299
+ const useStoreCreditAccountTransactions = (id, query, options) => {
27300
+ const fetchStoreCreditAccountTransactions = (query2, headers) => sdk.client.fetch(
27301
+ `/admin/store-credit-accounts/${id}/transactions`,
27302
+ {
27303
+ query: query2,
27304
+ headers
27305
+ }
27306
+ );
27307
+ const { data, ...rest } = useQuery({
27308
+ queryFn: () => fetchStoreCreditAccountTransactions(query),
27309
+ queryKey: transactionQueryKey.list(query),
27310
+ ...options
27311
+ });
27312
+ return { ...data, ...rest };
27313
+ };
27314
+ var toggleSelection = function() {
27315
+ var selection = document.getSelection();
27316
+ if (!selection.rangeCount) {
27317
+ return function() {
27318
+ };
27319
+ }
27320
+ var active = document.activeElement;
27321
+ var ranges = [];
27322
+ for (var i2 = 0; i2 < selection.rangeCount; i2++) {
27323
+ ranges.push(selection.getRangeAt(i2));
27324
+ }
27325
+ switch (active.tagName.toUpperCase()) {
27326
+ case "INPUT":
27327
+ case "TEXTAREA":
27328
+ active.blur();
27329
+ break;
27330
+ default:
27331
+ active = null;
27332
+ break;
27333
+ }
27334
+ selection.removeAllRanges();
27335
+ return function() {
27336
+ selection.type === "Caret" && selection.removeAllRanges();
27337
+ if (!selection.rangeCount) {
27338
+ ranges.forEach(function(range) {
27339
+ selection.addRange(range);
27340
+ });
27341
+ }
27342
+ active && active.focus();
27343
+ };
27344
+ };
27345
+ var deselectCurrent = toggleSelection;
27346
+ var clipboardToIE11Formatting = {
27347
+ "text/plain": "Text",
27348
+ "text/html": "Url",
27349
+ "default": "Text"
27350
+ };
27351
+ var defaultMessage = "Copy to clipboard: #{key}, Enter";
27352
+ function format(message) {
27353
+ var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
27354
+ return message.replace(/#{\s*key\s*}/g, copyKey);
27355
+ }
27356
+ function copy(text2, options) {
27357
+ var debug2, message, reselectPrevious, range, selection, mark, success = false;
27358
+ if (!options) {
27359
+ options = {};
27360
+ }
27361
+ debug2 = options.debug || false;
27362
+ try {
27363
+ reselectPrevious = deselectCurrent();
27364
+ range = document.createRange();
27365
+ selection = document.getSelection();
27366
+ mark = document.createElement("span");
27367
+ mark.textContent = text2;
27368
+ mark.ariaHidden = "true";
27369
+ mark.style.all = "unset";
27370
+ mark.style.position = "fixed";
27371
+ mark.style.top = 0;
27372
+ mark.style.clip = "rect(0, 0, 0, 0)";
27373
+ mark.style.whiteSpace = "pre";
27374
+ mark.style.webkitUserSelect = "text";
27375
+ mark.style.MozUserSelect = "text";
27376
+ mark.style.msUserSelect = "text";
27377
+ mark.style.userSelect = "text";
27378
+ mark.addEventListener("copy", function(e2) {
27379
+ e2.stopPropagation();
27380
+ if (options.format) {
27381
+ e2.preventDefault();
27382
+ if (typeof e2.clipboardData === "undefined") {
27383
+ debug2 && console.warn("unable to use e.clipboardData");
27384
+ debug2 && console.warn("trying IE specific stuff");
27385
+ window.clipboardData.clearData();
27386
+ var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
27387
+ window.clipboardData.setData(format2, text2);
27388
+ } else {
27389
+ e2.clipboardData.clearData();
27390
+ e2.clipboardData.setData(options.format, text2);
27391
+ }
27392
+ }
27393
+ if (options.onCopy) {
27394
+ e2.preventDefault();
27395
+ options.onCopy(e2.clipboardData);
27396
+ }
27397
+ });
27398
+ document.body.appendChild(mark);
27399
+ range.selectNodeContents(mark);
27400
+ selection.addRange(range);
27401
+ var successful = document.execCommand("copy");
27402
+ if (!successful) {
27403
+ throw new Error("copy command was unsuccessful");
27404
+ }
27405
+ success = true;
27406
+ } catch (err) {
27407
+ debug2 && console.error("unable to copy using execCommand: ", err);
27408
+ debug2 && console.warn("trying IE specific stuff");
27409
+ try {
27410
+ window.clipboardData.setData(options.format || "text", text2);
27411
+ options.onCopy && options.onCopy(window.clipboardData);
27412
+ success = true;
27413
+ } catch (err2) {
27414
+ debug2 && console.error("unable to copy using clipboardData: ", err2);
27415
+ debug2 && console.error("falling back to prompt");
27416
+ message = format("message" in options ? options.message : defaultMessage);
27417
+ window.prompt(message, text2);
27418
+ }
27419
+ } finally {
27420
+ if (selection) {
27421
+ if (typeof selection.removeRange == "function") {
27422
+ selection.removeRange(range);
27423
+ } else {
27424
+ selection.removeAllRanges();
27425
+ }
27426
+ }
27427
+ if (mark) {
27428
+ document.body.removeChild(mark);
27429
+ }
27430
+ reselectPrevious();
27431
+ }
27432
+ return success;
27433
+ }
27434
+ var copyToClipboard = copy;
27435
+ const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
27436
+ function DisplayId({ id, className }) {
27437
+ const [open, setOpen] = useState(false);
27438
+ const onClick = () => {
27439
+ copy$1(id);
27440
+ toast.success("Copied to clipboard");
27441
+ };
27442
+ return /* @__PURE__ */ jsx(Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs("span", { onClick, className: clx("cursor-pointer", className), children: [
27443
+ "#",
27444
+ id.slice(-7)
27445
+ ] }) });
27446
+ }
27447
+ const columnHelper$3 = createDataTableColumnHelper();
27448
+ const useTransactionsTableColumns = () => {
27449
+ return useMemo(() => {
27450
+ return [
27451
+ columnHelper$3.accessor("id", {
27452
+ header: "ID",
27453
+ cell: ({ row }) => {
27454
+ return /* @__PURE__ */ jsx(DisplayId, { id: row.original.id });
27455
+ }
27456
+ }),
27457
+ columnHelper$3.accessor("created_at", {
27458
+ header: "Created At",
27459
+ cell: ({ row }) => formatDate(row.original.created_at, false)
27460
+ }),
27461
+ columnHelper$3.accessor("reference", {
27462
+ header: "Reference",
27463
+ cell: ({ row }) => {
27464
+ var _a;
27465
+ const prettyReference = (_a = row.original.reference) == null ? void 0 : _a.split("_").join(" ").split("-").join(" ");
27466
+ return /* @__PURE__ */ jsx(Text, { className: "capitalize", children: prettyReference });
27467
+ }
27468
+ }),
27469
+ columnHelper$3.accessor("reference_id", {
27470
+ header: "Reference ID",
27471
+ cell: ({ row }) => {
27472
+ return /* @__PURE__ */ jsx(DisplayId, { id: row.original.reference_id });
27473
+ }
27474
+ }),
27475
+ columnHelper$3.accessor("amount", {
27476
+ header: "Amount",
27477
+ cell: ({ row }) => {
27478
+ return row.original.account.currency_code && formatAmount(
27479
+ row.original.amount,
27480
+ row.original.account.currency_code
27481
+ );
27482
+ }
27483
+ })
27484
+ ];
27485
+ }, []);
27486
+ };
27487
+ const filterHelper = createDataTableFilterHelper();
27488
+ const useTransactionGroupFilterOptions = () => {
27489
+ const { transaction_groups } = useTransactionGroups({ limit: 1e3 });
27490
+ return useMemo(() => {
27491
+ return transaction_groups == null ? void 0 : transaction_groups.map((transactionGroup) => {
27492
+ return {
27493
+ label: transactionGroup.code,
27494
+ value: transactionGroup.id
27495
+ };
27496
+ });
27497
+ }, [transaction_groups]);
27498
+ };
27499
+ const useTransactionGroupFilters = () => {
27500
+ const transactionGroupFilterOptions = useTransactionGroupFilterOptions();
27501
+ return useMemo(() => {
27502
+ return [
27503
+ filterHelper.accessor("transaction_group_id", {
27504
+ type: "select",
27505
+ label: "Transaction Group",
27506
+ options: transactionGroupFilterOptions ?? []
27507
+ })
27508
+ ];
27509
+ }, [transactionGroupFilterOptions]);
27510
+ };
27511
+ const useTransactionsTableFilters = ({
27512
+ transactionGroup
27513
+ }) => {
27514
+ const dateFilterOptions = useDataTableDateFilters$1();
27515
+ const transactionGroupFilters = useTransactionGroupFilters();
27516
+ return useMemo(() => {
27517
+ if (transactionGroup) {
27518
+ return [...dateFilterOptions];
27519
+ }
27520
+ return [...dateFilterOptions, ...transactionGroupFilters];
27521
+ }, [dateFilterOptions, transactionGroupFilters, transactionGroup]);
27522
+ };
27523
+ const useTransactionsTableQuery = ({
27524
+ prefix,
27525
+ pageSize = 20
27526
+ }) => {
27527
+ const queryObject = useQueryParams(
27528
+ [
27529
+ "offset",
27530
+ "limit",
27531
+ "transaction_group_id",
27532
+ "currency_code",
27533
+ "created_at",
27534
+ "updated_at"
27535
+ ],
27536
+ prefix
27537
+ );
27538
+ const {
27539
+ offset,
27540
+ limit,
27541
+ created_at,
27542
+ updated_at,
27543
+ transaction_group_id,
27544
+ ...rest
27545
+ } = queryObject;
27546
+ const searchParams = {
27547
+ limit: limit ? Number(limit) : pageSize,
27548
+ offset: offset ? Number(offset) : 0,
27549
+ created_at: created_at ? JSON.parse(created_at) : void 0,
27550
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
27551
+ transaction_group_id: transaction_group_id ? JSON.parse(transaction_group_id) : void 0,
27552
+ ...rest
27553
+ };
27554
+ return searchParams;
27668
27555
  };
27669
- const GiftCardOwnerSection = ({ giftCard }) => {
27670
- if (!giftCard) {
27671
- return;
27672
- }
27673
- return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
27674
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27675
- /* @__PURE__ */ jsx(Header$5, { title: "Owner" }),
27676
- giftCard.status !== GiftCardStatus.REDEEMED && /* @__PURE__ */ jsx(Link, { to: `owner`, className: "text-ui-fg-muted text-sm px-6", children: "Transfer ownership" })
27677
- ] }),
27678
- /* @__PURE__ */ jsx(
27679
- SidebarLink,
27556
+ const PAGE_SIZE$2 = 10;
27557
+ function TransactionsTable({
27558
+ id,
27559
+ transactionGroup
27560
+ }) {
27561
+ const queryParams = useTransactionsTableQuery({
27562
+ pageSize: PAGE_SIZE$2
27563
+ });
27564
+ const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
27565
+ id,
27566
+ {
27567
+ ...queryParams,
27568
+ transaction_group_id: transactionGroup == null ? void 0 : transactionGroup.id,
27569
+ order: queryParams.order ?? "-created_at",
27570
+ fields: "*account,*transaction_group"
27571
+ }
27572
+ );
27573
+ const columns = useTransactionsTableColumns();
27574
+ const filters = useTransactionsTableFilters({ transactionGroup });
27575
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
27576
+ /* @__PURE__ */ jsx(Container$1, { className: "p-0", children: /* @__PURE__ */ jsx(
27577
+ DataTable,
27680
27578
  {
27681
- to: `/customers/${giftCard.customer.id}`,
27682
- labelKey: `${[
27683
- giftCard.customer.first_name,
27684
- giftCard.customer.last_name
27685
- ].join(" ")}`,
27686
- descriptionKey: giftCard.customer.email,
27687
- icon: /* @__PURE__ */ jsx(UserMini, {})
27579
+ data: transactions ?? [],
27580
+ getRowId: (row) => row.id,
27581
+ columns,
27582
+ filters,
27583
+ isLoading,
27584
+ pageSize: PAGE_SIZE$2,
27585
+ rowCount: count2,
27586
+ enableSearch: false,
27587
+ heading: "Transactions",
27588
+ emptyState: {
27589
+ empty: {
27590
+ heading: "No transactions found"
27591
+ },
27592
+ filtered: {
27593
+ heading: "No results found",
27594
+ description: "No transactions match your filter criteria."
27595
+ }
27596
+ }
27688
27597
  }
27689
- )
27598
+ ) }),
27599
+ /* @__PURE__ */ jsx(Outlet, {})
27690
27600
  ] });
27691
- };
27601
+ }
27692
27602
  const GiftCardTransactionsSection = ({
27693
27603
  storeCreditAccount,
27694
27604
  transactionGroup
@@ -27880,73 +27790,6 @@ const GiftCardExpirationForm = ({ giftCard }) => {
27880
27790
  const schema$2 = z.object({
27881
27791
  expires_at: z.date().nullish()
27882
27792
  });
27883
- const Note$1 = () => {
27884
- const { id } = useParams();
27885
- const {
27886
- gift_card: giftCard,
27887
- isPending,
27888
- isError,
27889
- error
27890
- } = useGiftCard(id, {});
27891
- if (isError) {
27892
- throw error;
27893
- }
27894
- const isReady = !isPending && !!giftCard;
27895
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
27896
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
27897
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
27898
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
27899
- ] }),
27900
- isReady && /* @__PURE__ */ jsx(GiftCardNoteForm$1, { giftCard })
27901
- ] });
27902
- };
27903
- const GiftCardNoteForm$1 = ({ giftCard }) => {
27904
- const form = useForm({
27905
- defaultValues: {
27906
- note: giftCard.note ?? ""
27907
- },
27908
- resolver: t$1(schema$1)
27909
- });
27910
- const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
27911
- const { handleSuccess } = useRouteModal();
27912
- const onSubmit = form.handleSubmit(async (data) => {
27913
- await mutateAsync(
27914
- { note: data.note },
27915
- {
27916
- onSuccess: () => handleSuccess(),
27917
- onError: (error) => toast.error(error.message)
27918
- }
27919
- );
27920
- });
27921
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
27922
- KeyboundForm,
27923
- {
27924
- className: "flex flex-1 flex-col overflow-hidden",
27925
- onSubmit,
27926
- children: [
27927
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
27928
- Form$2.Field,
27929
- {
27930
- control: form.control,
27931
- name: "note",
27932
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
27933
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
27934
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
27935
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
27936
- ] })
27937
- }
27938
- ) }),
27939
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
27940
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
27941
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
27942
- ] }) })
27943
- ]
27944
- }
27945
- ) });
27946
- };
27947
- const schema$1 = z.object({
27948
- note: z.string().optional()
27949
- });
27950
27793
  const TransferIcon = () => /* @__PURE__ */ jsxs(
27951
27794
  "svg",
27952
27795
  {
@@ -28294,7 +28137,7 @@ const TransferIcon = () => /* @__PURE__ */ jsxs(
28294
28137
  ]
28295
28138
  }
28296
28139
  );
28297
- const Note = () => {
28140
+ const Note$1 = () => {
28298
28141
  const { id } = useParams();
28299
28142
  const {
28300
28143
  gift_card: giftCard,
@@ -28311,16 +28154,16 @@ const Note = () => {
28311
28154
  /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Gift Card" }) }),
28312
28155
  /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the gift card to a new owner" }) })
28313
28156
  ] }),
28314
- isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
28157
+ isReady && /* @__PURE__ */ jsx(GiftCardNoteForm$1, { giftCard })
28315
28158
  ] });
28316
28159
  };
28317
- const GiftCardNoteForm = ({ giftCard }) => {
28160
+ const GiftCardNoteForm$1 = ({ giftCard }) => {
28318
28161
  const { customers } = useCustomers();
28319
28162
  const form = useForm({
28320
28163
  defaultValues: {
28321
28164
  customer_id: giftCard.customer.id
28322
28165
  },
28323
- resolver: t$1(schema)
28166
+ resolver: t$1(schema$1)
28324
28167
  });
28325
28168
  const { mutateAsync, isPending } = useTransferGiftCard(giftCard.id);
28326
28169
  const { handleSuccess } = useRouteModal();
@@ -28385,8 +28228,75 @@ const GiftCardNoteForm = ({ giftCard }) => {
28385
28228
  }
28386
28229
  ) });
28387
28230
  };
28231
+ const schema$1 = z.object({
28232
+ customer_id: z.string()
28233
+ });
28234
+ const Note = () => {
28235
+ const { id } = useParams();
28236
+ const {
28237
+ gift_card: giftCard,
28238
+ isPending,
28239
+ isError,
28240
+ error
28241
+ } = useGiftCard(id, {});
28242
+ if (isError) {
28243
+ throw error;
28244
+ }
28245
+ const isReady = !isPending && !!giftCard;
28246
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
28247
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
28248
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
28249
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
28250
+ ] }),
28251
+ isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
28252
+ ] });
28253
+ };
28254
+ const GiftCardNoteForm = ({ giftCard }) => {
28255
+ const form = useForm({
28256
+ defaultValues: {
28257
+ note: giftCard.note ?? ""
28258
+ },
28259
+ resolver: t$1(schema)
28260
+ });
28261
+ const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
28262
+ const { handleSuccess } = useRouteModal();
28263
+ const onSubmit = form.handleSubmit(async (data) => {
28264
+ await mutateAsync(
28265
+ { note: data.note },
28266
+ {
28267
+ onSuccess: () => handleSuccess(),
28268
+ onError: (error) => toast.error(error.message)
28269
+ }
28270
+ );
28271
+ });
28272
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
28273
+ KeyboundForm,
28274
+ {
28275
+ className: "flex flex-1 flex-col overflow-hidden",
28276
+ onSubmit,
28277
+ children: [
28278
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
28279
+ Form$2.Field,
28280
+ {
28281
+ control: form.control,
28282
+ name: "note",
28283
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
28284
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
28285
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
28286
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
28287
+ ] })
28288
+ }
28289
+ ) }),
28290
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
28291
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
28292
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
28293
+ ] }) })
28294
+ ]
28295
+ }
28296
+ ) });
28297
+ };
28388
28298
  const schema = z.object({
28389
- customer_id: z.string()
28299
+ note: z.string().optional()
28390
28300
  });
28391
28301
  const productStatusColor = (status) => {
28392
28302
  switch (status) {
@@ -28920,180 +28830,6 @@ const ProductDetail = () => {
28920
28830
  ] });
28921
28831
  };
28922
28832
  const EditProductSchema$1 = z.object({
28923
- status: z.enum(["draft", "published", "proposed", "rejected"]),
28924
- title: z.string().min(1),
28925
- subtitle: z.string().optional(),
28926
- handle: z.string().min(1),
28927
- description: z.string().optional()
28928
- });
28929
- const GiftCardProductEditForm = ({
28930
- product
28931
- }) => {
28932
- const { handleSuccess } = useRouteModal();
28933
- const form = useForm({
28934
- defaultValues: {
28935
- status: product.status,
28936
- title: product.title,
28937
- subtitle: product.subtitle || "",
28938
- handle: product.handle || "",
28939
- description: product.description || ""
28940
- },
28941
- resolver: t$1(EditProductSchema$1)
28942
- });
28943
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
28944
- const handleSubmit = form.handleSubmit(async (data) => {
28945
- const { title, handle, status, ...optional } = data;
28946
- await mutateAsync(
28947
- {
28948
- ...optional,
28949
- title,
28950
- handle,
28951
- status
28952
- },
28953
- {
28954
- onSuccess: ({ product: product2 }) => {
28955
- toast.success(
28956
- `Gift card product ${product2.title} updated successfully`
28957
- );
28958
- handleSuccess();
28959
- },
28960
- onError: (e2) => {
28961
- toast.error(e2.message);
28962
- }
28963
- }
28964
- );
28965
- });
28966
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
28967
- KeyboundForm,
28968
- {
28969
- onSubmit: handleSubmit,
28970
- className: "flex flex-1 flex-col overflow-hidden",
28971
- children: [
28972
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
28973
- /* @__PURE__ */ jsx(
28974
- Form$2.Field,
28975
- {
28976
- control: form.control,
28977
- name: "status",
28978
- render: ({ field: { onChange, ref, ...field } }) => {
28979
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
28980
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Status" }),
28981
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
28982
- /* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
28983
- /* @__PURE__ */ jsx(Select.Content, { children: [
28984
- "draft",
28985
- "published",
28986
- "proposed",
28987
- "rejected"
28988
- ].map((status) => {
28989
- return /* @__PURE__ */ jsx(
28990
- Select.Item,
28991
- {
28992
- value: status,
28993
- className: "capitalize",
28994
- children: status
28995
- },
28996
- status
28997
- );
28998
- }) })
28999
- ] }) }),
29000
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29001
- ] });
29002
- }
29003
- }
29004
- ),
29005
- /* @__PURE__ */ jsx(
29006
- Form$2.Field,
29007
- {
29008
- control: form.control,
29009
- name: "title",
29010
- render: ({ field }) => {
29011
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29012
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
29013
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
29014
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29015
- ] });
29016
- }
29017
- }
29018
- ),
29019
- /* @__PURE__ */ jsx(
29020
- Form$2.Field,
29021
- {
29022
- control: form.control,
29023
- name: "subtitle",
29024
- render: ({ field }) => {
29025
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29026
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
29027
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
29028
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29029
- ] });
29030
- }
29031
- }
29032
- ),
29033
- /* @__PURE__ */ jsx(
29034
- Form$2.Field,
29035
- {
29036
- control: form.control,
29037
- name: "handle",
29038
- render: ({ field }) => {
29039
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29040
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Handle" }),
29041
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
29042
- /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
29043
- Text,
29044
- {
29045
- className: "text-ui-fg-muted",
29046
- size: "small",
29047
- leading: "compact",
29048
- weight: "plus",
29049
- children: "/"
29050
- }
29051
- ) }),
29052
- /* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
29053
- ] }) }),
29054
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29055
- ] });
29056
- }
29057
- }
29058
- ),
29059
- /* @__PURE__ */ jsx(
29060
- Form$2.Field,
29061
- {
29062
- control: form.control,
29063
- name: "description",
29064
- render: ({ field }) => {
29065
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29066
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
29067
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
29068
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29069
- ] });
29070
- }
29071
- }
29072
- )
29073
- ] }) }) }),
29074
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
29075
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
29076
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
29077
- ] }) })
29078
- ]
29079
- }
29080
- ) });
29081
- };
29082
- const GiftCardProductEdit$1 = () => {
29083
- const { id } = useParams();
29084
- const { product, isLoading, isError, error } = useProduct(id, {});
29085
- if (isError) {
29086
- throw error;
29087
- }
29088
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
29089
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
29090
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
29091
- /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
29092
- ] }),
29093
- !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
29094
- ] });
29095
- };
29096
- const EditProductSchema = z.object({
29097
28833
  denominations: z.array(
29098
28834
  z.object({
29099
28835
  id: z.string().optional(),
@@ -29119,7 +28855,7 @@ const GiftCardProductEditDenominationsForm = ({
29119
28855
  };
29120
28856
  })
29121
28857
  },
29122
- resolver: t$1(EditProductSchema)
28858
+ resolver: t$1(EditProductSchema$1)
29123
28859
  });
29124
28860
  const { mutateAsync, isPending } = useUpdateProduct(product.id);
29125
28861
  const handleSubmit = form.handleSubmit(async (data) => {
@@ -29221,20 +28957,194 @@ const GiftCardProductEditDenominationsForm = ({
29221
28957
  );
29222
28958
  }),
29223
28959
  /* @__PURE__ */ jsx(
29224
- Button,
28960
+ Button,
28961
+ {
28962
+ size: "small",
28963
+ variant: "secondary",
28964
+ type: "button",
28965
+ className: "w-full",
28966
+ onClick: () => {
28967
+ addDenomination({ value: "", sku: "", prices: {} });
28968
+ },
28969
+ children: "Add denomination"
28970
+ }
28971
+ ),
28972
+ form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
28973
+ ] }) }) }) }),
28974
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
28975
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
28976
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
28977
+ ] }) })
28978
+ ]
28979
+ }
28980
+ ) });
28981
+ };
28982
+ const GiftCardProductEdit$1 = () => {
28983
+ const { id } = useParams();
28984
+ const { product, isLoading, isError, error } = useProduct(id, {});
28985
+ if (isError) {
28986
+ throw error;
28987
+ }
28988
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
28989
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
28990
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
28991
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
28992
+ ] }),
28993
+ !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
28994
+ ] });
28995
+ };
28996
+ const EditProductSchema = z.object({
28997
+ status: z.enum(["draft", "published", "proposed", "rejected"]),
28998
+ title: z.string().min(1),
28999
+ subtitle: z.string().optional(),
29000
+ handle: z.string().min(1),
29001
+ description: z.string().optional()
29002
+ });
29003
+ const GiftCardProductEditForm = ({
29004
+ product
29005
+ }) => {
29006
+ const { handleSuccess } = useRouteModal();
29007
+ const form = useForm({
29008
+ defaultValues: {
29009
+ status: product.status,
29010
+ title: product.title,
29011
+ subtitle: product.subtitle || "",
29012
+ handle: product.handle || "",
29013
+ description: product.description || ""
29014
+ },
29015
+ resolver: t$1(EditProductSchema)
29016
+ });
29017
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
29018
+ const handleSubmit = form.handleSubmit(async (data) => {
29019
+ const { title, handle, status, ...optional } = data;
29020
+ await mutateAsync(
29021
+ {
29022
+ ...optional,
29023
+ title,
29024
+ handle,
29025
+ status
29026
+ },
29027
+ {
29028
+ onSuccess: ({ product: product2 }) => {
29029
+ toast.success(
29030
+ `Gift card product ${product2.title} updated successfully`
29031
+ );
29032
+ handleSuccess();
29033
+ },
29034
+ onError: (e2) => {
29035
+ toast.error(e2.message);
29036
+ }
29037
+ }
29038
+ );
29039
+ });
29040
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
29041
+ KeyboundForm,
29042
+ {
29043
+ onSubmit: handleSubmit,
29044
+ className: "flex flex-1 flex-col overflow-hidden",
29045
+ children: [
29046
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
29047
+ /* @__PURE__ */ jsx(
29048
+ Form$2.Field,
29225
29049
  {
29226
- size: "small",
29227
- variant: "secondary",
29228
- type: "button",
29229
- className: "w-full",
29230
- onClick: () => {
29231
- addDenomination({ value: "", sku: "", prices: {} });
29232
- },
29233
- children: "Add denomination"
29050
+ control: form.control,
29051
+ name: "status",
29052
+ render: ({ field: { onChange, ref, ...field } }) => {
29053
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29054
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Status" }),
29055
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
29056
+ /* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
29057
+ /* @__PURE__ */ jsx(Select.Content, { children: [
29058
+ "draft",
29059
+ "published",
29060
+ "proposed",
29061
+ "rejected"
29062
+ ].map((status) => {
29063
+ return /* @__PURE__ */ jsx(
29064
+ Select.Item,
29065
+ {
29066
+ value: status,
29067
+ className: "capitalize",
29068
+ children: status
29069
+ },
29070
+ status
29071
+ );
29072
+ }) })
29073
+ ] }) }),
29074
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29075
+ ] });
29076
+ }
29234
29077
  }
29235
29078
  ),
29236
- form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
29237
- ] }) }) }) }),
29079
+ /* @__PURE__ */ jsx(
29080
+ Form$2.Field,
29081
+ {
29082
+ control: form.control,
29083
+ name: "title",
29084
+ render: ({ field }) => {
29085
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29086
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
29087
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
29088
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29089
+ ] });
29090
+ }
29091
+ }
29092
+ ),
29093
+ /* @__PURE__ */ jsx(
29094
+ Form$2.Field,
29095
+ {
29096
+ control: form.control,
29097
+ name: "subtitle",
29098
+ render: ({ field }) => {
29099
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29100
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
29101
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
29102
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29103
+ ] });
29104
+ }
29105
+ }
29106
+ ),
29107
+ /* @__PURE__ */ jsx(
29108
+ Form$2.Field,
29109
+ {
29110
+ control: form.control,
29111
+ name: "handle",
29112
+ render: ({ field }) => {
29113
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29114
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Handle" }),
29115
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
29116
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
29117
+ Text,
29118
+ {
29119
+ className: "text-ui-fg-muted",
29120
+ size: "small",
29121
+ leading: "compact",
29122
+ weight: "plus",
29123
+ children: "/"
29124
+ }
29125
+ ) }),
29126
+ /* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
29127
+ ] }) }),
29128
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29129
+ ] });
29130
+ }
29131
+ }
29132
+ ),
29133
+ /* @__PURE__ */ jsx(
29134
+ Form$2.Field,
29135
+ {
29136
+ control: form.control,
29137
+ name: "description",
29138
+ render: ({ field }) => {
29139
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
29140
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
29141
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
29142
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
29143
+ ] });
29144
+ }
29145
+ }
29146
+ )
29147
+ ] }) }) }),
29238
29148
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
29239
29149
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
29240
29150
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -29254,9 +29164,99 @@ const GiftCardProductEdit = () => {
29254
29164
  /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
29255
29165
  /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
29256
29166
  ] }),
29257
- !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
29167
+ !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
29258
29168
  ] });
29259
29169
  };
29170
+ const StoreCreditAccountBalanceSection = ({
29171
+ storeCreditAccount
29172
+ }) => {
29173
+ if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
29174
+ return;
29175
+ }
29176
+ return /* @__PURE__ */ jsx(Container$1, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
29177
+ /* @__PURE__ */ jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
29178
+ /* @__PURE__ */ jsxs("div", { children: [
29179
+ /* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
29180
+ /* @__PURE__ */ jsx(
29181
+ Text,
29182
+ {
29183
+ weight: "plus",
29184
+ size: "xlarge",
29185
+ className: "tabular-nums text-ui-fg-base",
29186
+ children: formatAmount(
29187
+ storeCreditAccount.balance,
29188
+ storeCreditAccount.currency_code
29189
+ )
29190
+ }
29191
+ )
29192
+ ] })
29193
+ ] }) });
29194
+ };
29195
+ const StoreCreditAccountDetailsSection = ({
29196
+ storeCreditAccount
29197
+ }) => {
29198
+ if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
29199
+ return;
29200
+ }
29201
+ return /* @__PURE__ */ jsx(Container$1, { className: "grid grid-cols-2 gap-x-2 px-6 py-6", children: /* @__PURE__ */ jsxs(
29202
+ Text,
29203
+ {
29204
+ weight: "plus",
29205
+ size: "xlarge",
29206
+ className: "text-ui-fg-base flex gap-x-4",
29207
+ children: [
29208
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
29209
+ /* @__PURE__ */ jsx(CreditCardIcon, { className: "inline" }),
29210
+ " "
29211
+ ] }),
29212
+ /* @__PURE__ */ jsxs("div", { children: [
29213
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle", children: [
29214
+ storeCreditAccount.currency_code.toUpperCase(),
29215
+ " Account"
29216
+ ] }),
29217
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsx(
29218
+ Text,
29219
+ {
29220
+ weight: "regular",
29221
+ size: "small",
29222
+ className: "text-ui-fg-base flex gap-x-4",
29223
+ children: /* @__PURE__ */ jsx(DisplayId, { id: storeCreditAccount.id })
29224
+ }
29225
+ ) })
29226
+ ] })
29227
+ ]
29228
+ }
29229
+ ) });
29230
+ };
29231
+ const StoreCreditAccountPage = () => {
29232
+ const { id } = useParams();
29233
+ const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
29234
+ id
29235
+ );
29236
+ if (!storeCreditAccount) {
29237
+ return;
29238
+ }
29239
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
29240
+ TwoColumnLayout,
29241
+ {
29242
+ firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
29243
+ /* @__PURE__ */ jsx(
29244
+ StoreCreditAccountDetailsSection,
29245
+ {
29246
+ storeCreditAccount
29247
+ }
29248
+ ),
29249
+ /* @__PURE__ */ jsx(TransactionsTable, { id: storeCreditAccount.id })
29250
+ ] }),
29251
+ secondCol: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
29252
+ StoreCreditAccountBalanceSection,
29253
+ {
29254
+ storeCreditAccount
29255
+ }
29256
+ ) })
29257
+ }
29258
+ ) });
29259
+ };
29260
29260
  const EditProductMediaForm = ({ product }) => {
29261
29261
  const [selection, setSelection] = useState({});
29262
29262
  const { handleSuccess } = useRouteModal();
@@ -30150,6 +30150,10 @@ const widgetModule = { widgets: [
30150
30150
  ] };
30151
30151
  const routeModule = {
30152
30152
  routes: [
30153
+ {
30154
+ Component: GiftCardsPage,
30155
+ path: "/gift-cards"
30156
+ },
30153
30157
  {
30154
30158
  Component: GiftCardProductsPage,
30155
30159
  path: "/gift-card-products",
@@ -30164,14 +30168,6 @@ const routeModule = {
30164
30168
  Component: StoreCreditAccountsPage,
30165
30169
  path: "/store-credit-accounts"
30166
30170
  },
30167
- {
30168
- Component: GiftCardsPage,
30169
- path: "/gift-cards"
30170
- },
30171
- {
30172
- Component: StoreCreditAccountPage,
30173
- path: "/store-credit-accounts/:id"
30174
- },
30175
30171
  {
30176
30172
  Component: GiftCardDetailsPage,
30177
30173
  path: "/gift-cards/:id",
@@ -30182,11 +30178,11 @@ const routeModule = {
30182
30178
  },
30183
30179
  {
30184
30180
  Component: Note$1,
30185
- path: "/gift-cards/:id/note"
30181
+ path: "/gift-cards/:id/owner"
30186
30182
  },
30187
30183
  {
30188
30184
  Component: Note,
30189
- path: "/gift-cards/:id/owner"
30185
+ path: "/gift-cards/:id/note"
30190
30186
  }
30191
30187
  ]
30192
30188
  },
@@ -30196,14 +30192,18 @@ const routeModule = {
30196
30192
  children: [
30197
30193
  {
30198
30194
  Component: GiftCardProductEdit$1,
30199
- path: "/gift-card-products/:id/edit"
30195
+ path: "/gift-card-products/:id/denominations"
30200
30196
  },
30201
30197
  {
30202
30198
  Component: GiftCardProductEdit,
30203
- path: "/gift-card-products/:id/denominations"
30199
+ path: "/gift-card-products/:id/edit"
30204
30200
  }
30205
30201
  ]
30206
30202
  },
30203
+ {
30204
+ Component: StoreCreditAccountPage,
30205
+ path: "/store-credit-accounts/:id"
30206
+ },
30207
30207
  {
30208
30208
  Component: ProductMedia,
30209
30209
  path: "/gift-card-products/:id/media"
@@ -30221,22 +30221,22 @@ const routeModule = {
30221
30221
  const menuItemModule = {
30222
30222
  menuItems: [
30223
30223
  {
30224
- label: config$1.label,
30225
- icon: config$1.icon,
30226
- path: "/store-credit-accounts",
30227
- nested: void 0
30228
- },
30229
- {
30230
- label: config.label,
30231
- icon: config.icon,
30224
+ label: config$2.label,
30225
+ icon: config$2.icon,
30232
30226
  path: "/gift-cards",
30233
30227
  nested: void 0
30234
30228
  },
30235
30229
  {
30236
- label: config$2.label,
30230
+ label: config$1.label,
30237
30231
  icon: void 0,
30238
30232
  path: "/gift-card-products",
30239
30233
  nested: "/products"
30234
+ },
30235
+ {
30236
+ label: config.label,
30237
+ icon: config.icon,
30238
+ path: "/store-credit-accounts",
30239
+ nested: void 0
30240
30240
  }
30241
30241
  ]
30242
30242
  };