@acmekit/dashboard 2.13.7 → 2.13.9

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.
Files changed (83) hide show
  1. package/dist/api-key-management-create-VWUERPPB.mjs +170 -0
  2. package/dist/api-key-management-detail-V4ENQHYY.mjs +306 -0
  3. package/dist/api-key-management-edit-R44OHS7B.mjs +106 -0
  4. package/dist/api-key-management-list-K2XPKF5E.mjs +400 -0
  5. package/dist/app.js +16765 -1370
  6. package/dist/app.mjs +786 -1030
  7. package/dist/chunk-22YYMH6M.mjs +382 -0
  8. package/dist/chunk-2U3RK3JG.mjs +474 -0
  9. package/dist/chunk-535OVBXR.mjs +226 -0
  10. package/dist/chunk-774WSTCC.mjs +19 -0
  11. package/dist/chunk-C76H5USB.mjs +16 -0
  12. package/dist/chunk-DFFLVEZ5.mjs +40 -0
  13. package/dist/chunk-DN3MIYQH.mjs +140 -0
  14. package/dist/chunk-DQCEH3X2.mjs +28 -0
  15. package/dist/chunk-DTY37DDZ.mjs +20 -0
  16. package/dist/chunk-EFRMWHRX.mjs +84 -0
  17. package/dist/chunk-FXYH54JP.mjs +16 -0
  18. package/dist/chunk-G22WWLPG.mjs +44 -0
  19. package/dist/chunk-G2VJOHHV.mjs +32 -0
  20. package/dist/chunk-GBFVWROS.mjs +58 -0
  21. package/dist/chunk-ITNQKZQQ.mjs +142 -0
  22. package/dist/chunk-IUCDCPJU.mjs +0 -0
  23. package/dist/chunk-LKWTBYYC.mjs +35 -0
  24. package/dist/{chunk-4VYJHIB3.mjs → chunk-ND3ODI36.mjs} +0 -72
  25. package/dist/chunk-OAHCJFG3.mjs +17 -0
  26. package/dist/chunk-RPAL6FHW.mjs +73 -0
  27. package/dist/{chunk-JSJZMTQG.mjs → chunk-RREPQMYC.mjs} +14 -41
  28. package/dist/chunk-S3REQHPQ.mjs +86 -0
  29. package/dist/chunk-S4DMV3ZT.mjs +35 -0
  30. package/dist/chunk-ST2YB7JN.mjs +74 -0
  31. package/dist/chunk-TCNCAWYD.mjs +9 -0
  32. package/dist/chunk-ULSPL3DR.mjs +126 -0
  33. package/dist/chunk-WILMJYUB.mjs +35 -0
  34. package/dist/chunk-XIM7X4FB.mjs +83 -0
  35. package/dist/chunk-YLPAZ2DP.mjs +1837 -0
  36. package/dist/chunk-YRWSG3YM.mjs +80 -0
  37. package/dist/{invite-S5USGDOZ.mjs → invite-XGPZZBUP.mjs} +15 -7
  38. package/dist/{login-AIMR26AL.mjs → login-GNP3QIPI.mjs} +25 -12
  39. package/dist/profile-detail-YX27F7N6.mjs +96 -0
  40. package/dist/profile-edit-2VRDU75O.mjs +173 -0
  41. package/dist/{reset-password-UQPRHMB3.mjs → reset-password-TWRNZO6Z.mjs} +7 -3
  42. package/dist/settings-3XWLL5LG.mjs +545 -0
  43. package/dist/translation-list-CCEQJNED.mjs +581 -0
  44. package/dist/translations-edit-E57GVUFV.mjs +5376 -0
  45. package/dist/user-detail-KUSRRVNX.mjs +169 -0
  46. package/dist/user-edit-HTN3ZGCL.mjs +114 -0
  47. package/dist/user-invite-E3FAAU3V.mjs +361 -0
  48. package/dist/user-list-KNJ5S3IM.mjs +1116 -0
  49. package/dist/user-metadata-5GQK75DT.mjs +425 -0
  50. package/dist/workflow-execution-detail-LZXCRVNC.mjs +819 -0
  51. package/dist/workflow-execution-list-HQ3V6TML.mjs +175 -0
  52. package/package.json +9 -9
  53. package/src/components/layout/settings-layout/settings-layout.tsx +8 -2
  54. package/src/dashboard-app/routes/get-route.map.tsx +1 -14
  55. package/src/hooks/api/api-keys.tsx +0 -49
  56. package/src/hooks/api/index.ts +0 -1
  57. package/src/providers/keybind-provider/hooks.tsx +0 -145
  58. package/src/routes/translations/translation-list/translation-list.tsx +10 -21
  59. package/src/routes/translations/translations-edit/translations-edit.tsx +14 -11
  60. package/src/vite-env.d.ts +3 -1
  61. package/dist/chunk-FBTP4AJM.mjs +0 -221
  62. package/dist/chunk-QYOO4QR6.mjs +0 -73
  63. package/src/components/data-table/helpers/sales-channels/index.ts +0 -4
  64. package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.tsx +0 -61
  65. package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.tsx +0 -22
  66. package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.tsx +0 -33
  67. package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-query.tsx +0 -30
  68. package/src/routes/api-key-management/api-key-management-detail/components/api-key-sales-channel-section/api-key-sales-channel-section.tsx +0 -206
  69. package/src/routes/api-key-management/api-key-management-detail/components/api-key-sales-channel-section/index.ts +0 -1
  70. package/src/routes/store/common/hooks/use-currencies-table-columns.tsx +0 -29
  71. package/src/routes/store/common/hooks/use-currencies-table-query.tsx +0 -21
  72. package/src/routes/store/common/hooks/use-locales-table-columns.tsx +0 -29
  73. package/src/routes/store/common/hooks/use-locales-table-query.tsx +0 -21
  74. package/src/routes/store/store-detail/components/store-general-section/index.ts +0 -1
  75. package/src/routes/store/store-detail/components/store-general-section/store-general-section.tsx +0 -48
  76. package/src/routes/store/store-detail/index.ts +0 -2
  77. package/src/routes/store/store-detail/loader.ts +0 -18
  78. package/src/routes/store/store-detail/store-detail.tsx +0 -42
  79. package/src/routes/store/store-edit/components/edit-store-form/edit-store-form.tsx +0 -83
  80. package/src/routes/store/store-edit/index.ts +0 -1
  81. package/src/routes/store/store-edit/store-edit.tsx +0 -25
  82. package/src/routes/store/store-metadata/index.ts +0 -1
  83. package/src/routes/store/store-metadata/store-metadata.tsx +0 -24
@@ -1,221 +0,0 @@
1
- import {
2
- queryKeysFactory
3
- } from "./chunk-QYOO4QR6.mjs";
4
- import {
5
- sdk
6
- } from "./chunk-4VYJHIB3.mjs";
7
-
8
- // src/hooks/api/api-keys.tsx
9
- import {
10
- useMutation as useMutation4,
11
- useQuery as useQuery4
12
- } from "@tanstack/react-query";
13
-
14
- // src/hooks/api/sales-channels.tsx
15
- import {
16
- useMutation as useMutation3,
17
- useQuery as useQuery3
18
- } from "@tanstack/react-query";
19
-
20
- // src/hooks/api/products.tsx
21
- import {
22
- useMutation as useMutation2,
23
- useQuery as useQuery2
24
- } from "@tanstack/react-query";
25
-
26
- // src/hooks/api/inventory.tsx
27
- import {
28
- useMutation,
29
- useQuery
30
- } from "@tanstack/react-query";
31
- var INVENTORY_ITEMS_QUERY_KEY = "inventory_items";
32
- var inventoryItemsQueryKeys = queryKeysFactory(
33
- INVENTORY_ITEMS_QUERY_KEY
34
- );
35
- var INVENTORY_ITEM_LEVELS_QUERY_KEY = "inventory_item_levels";
36
- var inventoryItemLevelsQueryKeys = queryKeysFactory(
37
- INVENTORY_ITEM_LEVELS_QUERY_KEY
38
- );
39
-
40
- // src/hooks/use-infinite-list.tsx
41
- import {
42
- useInfiniteQuery
43
- } from "@tanstack/react-query";
44
-
45
- // src/hooks/api/products.tsx
46
- var PRODUCTS_QUERY_KEY = "products";
47
- var productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY);
48
- var VARIANTS_QUERY_KEY = "product_variants";
49
- var variantsQueryKeys = queryKeysFactory(VARIANTS_QUERY_KEY);
50
- var OPTIONS_QUERY_KEY = "product_options";
51
- var optionsQueryKeys = queryKeysFactory(OPTIONS_QUERY_KEY);
52
-
53
- // src/hooks/api/sales-channels.tsx
54
- var SALES_CHANNELS_QUERY_KEY = "sales-channels";
55
- var salesChannelsQueryKeys = queryKeysFactory(SALES_CHANNELS_QUERY_KEY);
56
-
57
- // src/hooks/api/api-keys.tsx
58
- var API_KEYS_QUERY_KEY = "api_keys";
59
- var apiKeysQueryKeys = queryKeysFactory(API_KEYS_QUERY_KEY);
60
-
61
- // src/hooks/api/cloud.tsx
62
- import {
63
- useMutation as useMutation5,
64
- useQuery as useQuery5
65
- } from "@tanstack/react-query";
66
- var cloudQueryKeys = {
67
- all: ["cloud"],
68
- auth: () => [...cloudQueryKeys.all, "auth"]
69
- };
70
- var useCloudAuthEnabled = (options) => {
71
- return useQuery5({
72
- queryKey: cloudQueryKeys.auth(),
73
- queryFn: async () => {
74
- return await sdk.client.fetch("/cloud/auth");
75
- },
76
- ...options
77
- });
78
- };
79
- var useCreateCloudAuthUser = (options) => {
80
- return useMutation5({
81
- mutationFn: async () => {
82
- await sdk.client.fetch("/cloud/auth/users", {
83
- method: "POST"
84
- });
85
- },
86
- ...options
87
- });
88
- };
89
-
90
- // src/hooks/api/feature-flags.tsx
91
- import { useQuery as useQuery6 } from "@tanstack/react-query";
92
- var useFeatureFlags = () => {
93
- return useQuery6({
94
- queryKey: ["admin", "feature-flags"],
95
- queryFn: async () => {
96
- const response = await sdk.client.fetch(
97
- "/admin/feature-flags",
98
- {
99
- method: "GET"
100
- }
101
- );
102
- return response.feature_flags;
103
- },
104
- staleTime: 5 * 60 * 1e3,
105
- // Cache for 5 minutes
106
- cacheTime: 10 * 60 * 1e3
107
- // Keep in cache for 10 minutes
108
- });
109
- };
110
-
111
- // src/hooks/api/locales.tsx
112
- import { useQuery as useQuery7 } from "@tanstack/react-query";
113
- var LOCALES_QUERY_KEY = "locales";
114
- var localesQueryKeys = queryKeysFactory(LOCALES_QUERY_KEY);
115
-
116
- // src/hooks/api/notification.tsx
117
- import { useQuery as useQuery8 } from "@tanstack/react-query";
118
- var NOTIFICATION_QUERY_KEY = "notification";
119
- var notificationQueryKeys = queryKeysFactory(NOTIFICATION_QUERY_KEY);
120
- var useNotifications = (query, options) => {
121
- const { data, ...rest } = useQuery8({
122
- queryFn: () => sdk.admin.notification.list(query),
123
- queryKey: notificationQueryKeys.list(query),
124
- ...options
125
- });
126
- return { ...data, ...rest };
127
- };
128
-
129
- // src/hooks/api/plugins.tsx
130
- import { useQuery as useQuery9 } from "@tanstack/react-query";
131
- var PLUGINS_QUERY_KEY = "plugins";
132
- var pluginsQueryKeys = queryKeysFactory(PLUGINS_QUERY_KEY);
133
-
134
- // src/hooks/api/store.tsx
135
- import {
136
- useMutation as useMutation6,
137
- useQuery as useQuery10
138
- } from "@tanstack/react-query";
139
- import { FetchError } from "@acmekit/js-sdk";
140
- var STORE_QUERY_KEY = "store";
141
- var storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
142
-
143
- // src/hooks/api/translations.tsx
144
- import {
145
- useInfiniteQuery as useInfiniteQuery2,
146
- useMutation as useMutation7,
147
- useQuery as useQuery11
148
- } from "@tanstack/react-query";
149
- var TRANSLATIONS_QUERY_KEY = "translations";
150
- var translationsQueryKeys = queryKeysFactory(TRANSLATIONS_QUERY_KEY);
151
- var TRANSLATION_SETTINGS_QUERY_KEY = "translation_settings";
152
- var translationSettingsQueryKeys = queryKeysFactory(
153
- TRANSLATION_SETTINGS_QUERY_KEY
154
- );
155
- var TRANSLATION_STATISTICS_QUERY_KEY = "translation_statistics";
156
- var translationStatisticsQueryKeys = queryKeysFactory(
157
- TRANSLATION_STATISTICS_QUERY_KEY
158
- );
159
- var TRANSLATION_ENTITIES_QUERY_KEY = "translation_entities";
160
- var translationEntitiesQueryKeys = queryKeysFactory(
161
- TRANSLATION_ENTITIES_QUERY_KEY
162
- );
163
-
164
- // src/hooks/api/users.tsx
165
- import {
166
- useMutation as useMutation8,
167
- useQuery as useQuery12
168
- } from "@tanstack/react-query";
169
- var USERS_QUERY_KEY = "users";
170
- var usersQueryKeys = {
171
- ...queryKeysFactory(USERS_QUERY_KEY),
172
- me: () => [USERS_QUERY_KEY, "me"]
173
- };
174
- var useMe = (query, options) => {
175
- const { data, ...rest } = useQuery12({
176
- queryFn: () => sdk.admin.user.me(query),
177
- queryKey: usersQueryKeys.me(),
178
- ...options
179
- });
180
- return {
181
- ...data,
182
- ...rest
183
- };
184
- };
185
-
186
- // src/hooks/api/views.tsx
187
- import {
188
- useMutation as useMutation9,
189
- useQuery as useQuery13
190
- } from "@tanstack/react-query";
191
- var VIEWS_QUERY_KEY = "views";
192
- var _viewsKeys = queryKeysFactory(VIEWS_QUERY_KEY);
193
- _viewsKeys.columns = function(entity) {
194
- return [this.all, "columns", entity];
195
- };
196
- _viewsKeys.active = function(entity) {
197
- return [this.detail(entity), "active"];
198
- };
199
- _viewsKeys.configurations = function(entity, query) {
200
- const key = [this.all, "configurations", entity];
201
- if (query !== void 0) {
202
- key.push(query);
203
- }
204
- return key;
205
- };
206
-
207
- // src/hooks/api/workflow-executions.tsx
208
- import { useQuery as useQuery14 } from "@tanstack/react-query";
209
- var WORKFLOW_EXECUTIONS_QUERY_KEY = "workflow_executions";
210
- var workflowExecutionsQueryKeys = queryKeysFactory(
211
- WORKFLOW_EXECUTIONS_QUERY_KEY
212
- );
213
-
214
- export {
215
- useFeatureFlags,
216
- useMe,
217
- useCloudAuthEnabled,
218
- useCreateCloudAuthUser,
219
- notificationQueryKeys,
220
- useNotifications
221
- };
@@ -1,73 +0,0 @@
1
- import {
2
- sdk
3
- } from "./chunk-4VYJHIB3.mjs";
4
-
5
- // src/hooks/api/invites.tsx
6
- import {
7
- useMutation,
8
- useQuery
9
- } from "@tanstack/react-query";
10
-
11
- // src/lib/query-client.ts
12
- import { QueryClient } from "@tanstack/react-query";
13
- var MEDUSA_BACKEND_URL = __BACKEND_URL__ ?? "/";
14
- var queryClient = new QueryClient({
15
- defaultOptions: {
16
- queries: {
17
- refetchOnWindowFocus: false,
18
- staleTime: 9e4,
19
- retry: 1
20
- }
21
- }
22
- });
23
-
24
- // src/lib/query-key-factory.ts
25
- var queryKeysFactory = (globalKey) => {
26
- const queryKeyFactory = {
27
- all: [globalKey],
28
- lists: () => [...queryKeyFactory.all, "list"],
29
- list: (query) => [...queryKeyFactory.lists(), query ? { query } : void 0].filter(
30
- (k) => !!k
31
- ),
32
- details: () => [...queryKeyFactory.all, "detail"],
33
- detail: (id, query) => [...queryKeyFactory.details(), id, query ? { query } : void 0].filter(
34
- (k) => !!k
35
- )
36
- };
37
- return queryKeyFactory;
38
- };
39
-
40
- // src/hooks/api/invites.tsx
41
- var INVITES_QUERY_KEY = "invites";
42
- var invitesQueryKeys = queryKeysFactory(INVITES_QUERY_KEY);
43
- var useAcceptInvite = (inviteToken, options) => {
44
- return useMutation({
45
- mutationFn: (payload) => {
46
- const { auth_token, ...rest } = payload;
47
- return sdk.admin.invite.accept(
48
- { invite_token: inviteToken, ...rest },
49
- {},
50
- {
51
- Authorization: `Bearer ${auth_token}`
52
- }
53
- );
54
- },
55
- onSuccess: (data, variables, context) => {
56
- options?.onSuccess?.(data, variables, context);
57
- },
58
- ...options
59
- });
60
- };
61
-
62
- // src/lib/is-fetch-error.ts
63
- import { FetchError } from "@acmekit/js-sdk";
64
- var isFetchError = (error) => {
65
- return error instanceof FetchError;
66
- };
67
-
68
- export {
69
- queryClient,
70
- queryKeysFactory,
71
- useAcceptInvite,
72
- isFetchError
73
- };
@@ -1,4 +0,0 @@
1
- export * from "./use-sales-channel-table-columns"
2
- export * from "./use-sales-channel-table-empty-state"
3
- export * from "./use-sales-channel-table-filters"
4
- export * from "./use-sales-channel-table-query"
@@ -1,61 +0,0 @@
1
- import { HttpTypes } from "@acmekit/types"
2
- import { useMemo } from "react"
3
- import { useTranslation } from "react-i18next"
4
-
5
- import { createDataTableColumnHelper, Tooltip } from "@acmekit/ui"
6
- import { DataTableStatusCell } from "../../components/data-table-status-cell/data-table-status-cell"
7
- import { useDataTableDateColumns } from "../general/use-data-table-date-columns"
8
-
9
- const columnHelper = createDataTableColumnHelper<HttpTypes.AdminSalesChannel>()
10
-
11
- export const useSalesChannelTableColumns = () => {
12
- const { t } = useTranslation()
13
- const dateColumns = useDataTableDateColumns<HttpTypes.AdminSalesChannel>()
14
-
15
- return useMemo(
16
- () => [
17
- columnHelper.accessor("name", {
18
- header: () => t("fields.name"),
19
- enableSorting: true,
20
- sortLabel: t("fields.name"),
21
- sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
22
- sortDescLabel: t("filters.sorting.alphabeticallyDesc"),
23
- }),
24
- columnHelper.accessor("description", {
25
- header: () => t("fields.description"),
26
- cell: ({ getValue }) => {
27
- return (
28
- <Tooltip content={getValue()}>
29
- <div className="flex h-full w-full items-center overflow-hidden">
30
- <span className="truncate">{getValue()}</span>
31
- </div>
32
- </Tooltip>
33
- )
34
- },
35
- enableSorting: true,
36
- sortLabel: t("fields.description"),
37
- sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
38
- sortDescLabel: t("filters.sorting.alphabeticallyDesc"),
39
- maxSize: 250,
40
- minSize: 100,
41
- }),
42
- columnHelper.accessor("is_disabled", {
43
- header: () => t("fields.status"),
44
- enableSorting: true,
45
- sortLabel: t("fields.status"),
46
- sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
47
- sortDescLabel: t("filters.sorting.alphabeticallyDesc"),
48
- cell: ({ getValue }) => {
49
- const value = getValue()
50
- return (
51
- <DataTableStatusCell color={value ? "grey" : "green"}>
52
- {value ? t("general.disabled") : t("general.enabled")}
53
- </DataTableStatusCell>
54
- )
55
- },
56
- }),
57
- ...dateColumns,
58
- ],
59
- [t, dateColumns]
60
- )
61
- }
@@ -1,22 +0,0 @@
1
- import { DataTableEmptyStateProps } from "@acmekit/ui"
2
- import { useMemo } from "react"
3
- import { useTranslation } from "react-i18next"
4
-
5
- export const useSalesChannelTableEmptyState = (): DataTableEmptyStateProps => {
6
- const { t } = useTranslation()
7
-
8
- return useMemo(() => {
9
- const content: DataTableEmptyStateProps = {
10
- empty: {
11
- heading: t("salesChannels.list.empty.heading"),
12
- description: t("salesChannels.list.empty.description"),
13
- },
14
- filtered: {
15
- heading: t("salesChannels.list.filtered.heading"),
16
- description: t("salesChannels.list.filtered.description"),
17
- },
18
- }
19
-
20
- return content
21
- }, [t])
22
- }
@@ -1,33 +0,0 @@
1
- import { HttpTypes } from "@acmekit/types"
2
- import { createDataTableFilterHelper } from "@acmekit/ui"
3
- import { useMemo } from "react"
4
- import { useTranslation } from "react-i18next"
5
- import { useDataTableDateFilters } from "../general/use-data-table-date-filters"
6
-
7
- const filterHelper = createDataTableFilterHelper<HttpTypes.AdminSalesChannel>()
8
-
9
- export const useSalesChannelTableFilters = () => {
10
- const { t } = useTranslation()
11
- const dateFilters = useDataTableDateFilters()
12
-
13
- return useMemo(
14
- () => [
15
- filterHelper.accessor("is_disabled", {
16
- label: t("fields.status"),
17
- type: "radio",
18
- options: [
19
- {
20
- label: t("general.enabled"),
21
- value: "false",
22
- },
23
- {
24
- label: t("general.disabled"),
25
- value: "true",
26
- },
27
- ],
28
- }),
29
- ...dateFilters,
30
- ],
31
- [dateFilters, t]
32
- )
33
- }
@@ -1,30 +0,0 @@
1
- import { HttpTypes } from "@acmekit/types"
2
- import { useQueryParams } from "../../../../hooks/use-query-params"
3
-
4
- type UseSalesChannelTableQueryProps = {
5
- prefix?: string
6
- pageSize?: number
7
- }
8
-
9
- export const useSalesChannelTableQuery = ({
10
- prefix,
11
- pageSize = 20,
12
- }: UseSalesChannelTableQueryProps) => {
13
- const queryObject = useQueryParams(
14
- ["offset", "q", "order", "created_at", "updated_at", "is_disabled"],
15
- prefix
16
- )
17
-
18
- const { offset, created_at, updated_at, is_disabled, ...rest } = queryObject
19
-
20
- const searchParams: HttpTypes.AdminSalesChannelListParams = {
21
- limit: pageSize,
22
- offset: offset ? Number(offset) : 0,
23
- created_at: created_at ? JSON.parse(created_at) : undefined,
24
- updated_at: updated_at ? JSON.parse(updated_at) : undefined,
25
- is_disabled: is_disabled ? JSON.parse(is_disabled) : undefined,
26
- ...rest,
27
- }
28
-
29
- return searchParams
30
- }
@@ -1,206 +0,0 @@
1
- import { PencilSquare, Trash } from "@acmekit/icons"
2
- import { AdminApiKeyResponse, HttpTypes } from "@acmekit/types"
3
- import {
4
- Container,
5
- createDataTableColumnHelper,
6
- createDataTableCommandHelper,
7
- DataTableRowSelectionState,
8
- toast,
9
- usePrompt,
10
- } from "@acmekit/ui"
11
- import { keepPreviousData } from "@tanstack/react-query"
12
- import { RowSelectionState } from "@tanstack/react-table"
13
- import { useCallback, useMemo, useState } from "react"
14
- import { useTranslation } from "react-i18next"
15
- import { useNavigate } from "react-router-dom"
16
- import { DataTable } from "../../../../../components/data-table"
17
- import * as hooks from "../../../../../components/data-table/helpers/sales-channels"
18
- import { useBatchRemoveSalesChannelsFromApiKey } from "../../../../../hooks/api/api-keys"
19
- import { useSalesChannels } from "../../../../../hooks/api/sales-channels"
20
-
21
- type ApiKeySalesChannelSectionProps = {
22
- apiKey: AdminApiKeyResponse["api_key"]
23
- }
24
-
25
- const PAGE_SIZE = 10
26
- const PREFIX = "sc"
27
-
28
- export const ApiKeySalesChannelSection = ({
29
- apiKey,
30
- }: ApiKeySalesChannelSectionProps) => {
31
- const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
32
- const { t } = useTranslation()
33
-
34
- const searchParams = hooks.useSalesChannelTableQuery({
35
- pageSize: PAGE_SIZE,
36
- prefix: PREFIX,
37
- })
38
-
39
- const { sales_channels, count, isPending } = useSalesChannels(
40
- { ...searchParams, publishable_key_id: apiKey.id },
41
- {
42
- placeholderData: keepPreviousData,
43
- }
44
- )
45
-
46
- const columns = useColumns(apiKey.id)
47
- const filters = hooks.useSalesChannelTableFilters()
48
- const commands = useCommands(apiKey.id, setRowSelection)
49
- const emptyState = hooks.useSalesChannelTableEmptyState()
50
-
51
- return (
52
- <Container className="divide-y p-0">
53
- <DataTable
54
- data={sales_channels}
55
- columns={columns}
56
- filters={filters}
57
- commands={commands}
58
- heading={t("salesChannels.domain")}
59
- headingLevel="h2"
60
- getRowId={(row) => row.id}
61
- rowCount={count}
62
- isLoading={isPending}
63
- emptyState={emptyState}
64
- rowSelection={{
65
- state: rowSelection,
66
- onRowSelectionChange: setRowSelection,
67
- }}
68
- rowHref={(row) => `/settings/sales-channels/${row.id}`}
69
- action={{
70
- label: t("actions.add"),
71
- to: "sales-channels",
72
- }}
73
- prefix={PREFIX}
74
- pageSize={PAGE_SIZE}
75
- />
76
- </Container>
77
- )
78
- }
79
-
80
- const columnHelper = createDataTableColumnHelper<HttpTypes.AdminSalesChannel>()
81
-
82
- const useColumns = (id: string) => {
83
- const { t } = useTranslation()
84
- const navigate = useNavigate()
85
- const prompt = usePrompt()
86
-
87
- const base = hooks.useSalesChannelTableColumns()
88
-
89
- const { mutateAsync } = useBatchRemoveSalesChannelsFromApiKey(id)
90
-
91
- const handleDelete = useCallback(
92
- async (salesChannel: HttpTypes.AdminSalesChannel) => {
93
- const res = await prompt({
94
- title: t("general.areYouSure"),
95
- description: t("apiKeyManagement.removeSalesChannel.warning", {
96
- name: salesChannel.name,
97
- }),
98
- confirmText: t("actions.delete"),
99
- cancelText: t("actions.cancel"),
100
- })
101
-
102
- if (!res) {
103
- return
104
- }
105
-
106
- await mutateAsync([salesChannel.id], {
107
- onSuccess: () => {
108
- toast.success(
109
- t("apiKeyManagement.removeSalesChannel.successToast", {
110
- count: 1,
111
- })
112
- )
113
- },
114
- onError: (err) => {
115
- toast.error(err.message)
116
- },
117
- })
118
- },
119
- [mutateAsync, prompt, t]
120
- )
121
-
122
- return useMemo(
123
- () => [
124
- columnHelper.select(),
125
- ...base,
126
- columnHelper.action({
127
- actions: (ctx) => [
128
- [
129
- {
130
- label: t("actions.edit"),
131
- icon: <PencilSquare />,
132
- onClick: () => {
133
- navigate(`/settings/sales-channels/${ctx.row.original.id}/edit`)
134
- },
135
- },
136
- ],
137
- [
138
- {
139
- icon: <Trash />,
140
- label: t("actions.delete"),
141
- onClick: () => handleDelete(ctx.row.original),
142
- },
143
- ],
144
- ],
145
- }),
146
- ],
147
- [base, handleDelete, navigate, t]
148
- )
149
- }
150
-
151
- const commandHelper = createDataTableCommandHelper()
152
-
153
- const useCommands = (
154
- id: string,
155
- setRowSelection: (state: DataTableRowSelectionState) => void
156
- ) => {
157
- const { t } = useTranslation()
158
- const prompt = usePrompt()
159
-
160
- const { mutateAsync } = useBatchRemoveSalesChannelsFromApiKey(id)
161
-
162
- const handleRemove = useCallback(
163
- async (rowSelection: DataTableRowSelectionState) => {
164
- const keys = Object.keys(rowSelection)
165
-
166
- const res = await prompt({
167
- title: t("general.areYouSure"),
168
- description: t("apiKeyManagement.removeSalesChannel.warningBatch", {
169
- count: keys.length,
170
- }),
171
- confirmText: t("actions.continue"),
172
- cancelText: t("actions.cancel"),
173
- })
174
-
175
- if (!res) {
176
- return
177
- }
178
-
179
- await mutateAsync(keys, {
180
- onSuccess: () => {
181
- toast.success(
182
- t("apiKeyManagement.removeSalesChannel.successToastBatch", {
183
- count: keys.length,
184
- })
185
- )
186
- setRowSelection({})
187
- },
188
- onError: (err) => {
189
- toast.error(err.message)
190
- },
191
- })
192
- },
193
- [mutateAsync, prompt, t, setRowSelection]
194
- )
195
-
196
- return useMemo(
197
- () => [
198
- commandHelper.command({
199
- action: handleRemove,
200
- label: t("actions.remove"),
201
- shortcut: "r",
202
- }),
203
- ],
204
- [handleRemove, t]
205
- )
206
- }
@@ -1 +0,0 @@
1
- export * from "./api-key-sales-channel-section"
@@ -1,29 +0,0 @@
1
- import { HttpTypes } from "@acmekit/types"
2
- import { createColumnHelper } from "@tanstack/react-table"
3
- import { useMemo } from "react"
4
- import { useTranslation } from "react-i18next"
5
-
6
- import {
7
- TextCell,
8
- TextHeader,
9
- } from "../../../../components/table/table-cells/common/text-cell"
10
-
11
- const columnHelper = createColumnHelper<HttpTypes.AdminCurrency>()
12
-
13
- export const useCurrenciesTableColumns = () => {
14
- const { t } = useTranslation()
15
-
16
- return useMemo(
17
- () => [
18
- columnHelper.accessor("code", {
19
- header: () => <TextHeader text={t("fields.code")} />,
20
- cell: ({ getValue }) => <TextCell text={getValue().toUpperCase()} />,
21
- }),
22
- columnHelper.accessor("name", {
23
- header: () => <TextHeader text={t("fields.name")} />,
24
- cell: ({ getValue }) => <TextCell text={getValue()} />,
25
- }),
26
- ],
27
- [t]
28
- )
29
- }