@medusajs/loyalty-plugin 0.0.1 → 0.0.3
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.
- package/.medusa/server/src/admin/index.js +30277 -0
- package/.medusa/server/src/admin/index.mjs +30256 -0
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +24 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +9 -1
- package/.medusa/server/src/api/store/carts/validators.js +5 -2
- package/.medusa/server/src/links/customer-gift-card-link.js +2 -2
- package/.medusa/server/src/links/customer-store-credit-account-link.js +2 -2
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +2 -2
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +104 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +2 -2
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +3 -3
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +1 -1
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +1 -1
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +115 -0
- package/package.json +14 -9
- package/.medusa/server/src/admin/components/action-menu.js +0 -63
- package/.medusa/server/src/admin/components/chip-group.js +0 -82
- package/.medusa/server/src/admin/components/chip-input.js +0 -157
- package/.medusa/server/src/admin/components/combobox.js +0 -324
- package/.medusa/server/src/admin/components/conditional-tooltip.js +0 -15
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +0 -66
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +0 -77
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +0 -110
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +0 -16
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +0 -214
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +0 -77
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +0 -32
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +0 -743
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +0 -37
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +0 -54
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +0 -66
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +0 -166
- package/.medusa/server/src/admin/components/data-grid/components/index.js +0 -16
- package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +0 -7
- package/.medusa/server/src/admin/components/data-grid/context/index.js +0 -6
- package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +0 -14
- package/.medusa/server/src/admin/components/data-grid/data-grid.js +0 -31
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +0 -28
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +0 -85
- package/.medusa/server/src/admin/components/data-grid/helpers/index.js +0 -6
- package/.medusa/server/src/admin/components/data-grid/hooks/index.js +0 -31
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +0 -50
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +0 -123
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +0 -52
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +0 -43
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +0 -191
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +0 -70
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +0 -51
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +0 -15
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +0 -86
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +0 -149
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +0 -482
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +0 -64
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +0 -81
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +0 -14
- package/.medusa/server/src/admin/components/data-grid/index.js +0 -8
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +0 -27
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +0 -296
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +0 -62
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +0 -25
- package/.medusa/server/src/admin/components/data-grid/models/index.js +0 -10
- package/.medusa/server/src/admin/components/data-grid/types.js +0 -1
- package/.medusa/server/src/admin/components/data-grid/utils.js +0 -18
- package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +0 -36
- package/.medusa/server/src/admin/components/data-table/data-table.js +0 -271
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +0 -51
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +0 -90
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +0 -10
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +0 -48
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +0 -19
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +0 -30
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +0 -23
- package/.medusa/server/src/admin/components/data-table/index.js +0 -4
- package/.medusa/server/src/admin/components/data-table.js +0 -249
- package/.medusa/server/src/admin/components/display-id.js +0 -18
- package/.medusa/server/src/admin/components/file-upload.js +0 -116
- package/.medusa/server/src/admin/components/form.js +0 -151
- package/.medusa/server/src/admin/components/handle-input.js +0 -22
- package/.medusa/server/src/admin/components/header.js +0 -41
- package/.medusa/server/src/admin/components/icon-avatar.js +0 -27
- package/.medusa/server/src/admin/components/json-view-section.js +0 -139
- package/.medusa/server/src/admin/components/keybound-form.js +0 -32
- package/.medusa/server/src/admin/components/layouts/single-column.js +0 -7
- package/.medusa/server/src/admin/components/layouts/two-column.js +0 -13
- package/.medusa/server/src/admin/components/listicle.js +0 -20
- package/.medusa/server/src/admin/components/modals/index.js +0 -19
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +0 -57
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +0 -71
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +0 -60
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +0 -30
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +0 -12
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +0 -55
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +0 -63
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +0 -47
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +0 -14
- package/.medusa/server/src/admin/components/placeholder-cell.js +0 -7
- package/.medusa/server/src/admin/components/product/product-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +0 -15
- package/.medusa/server/src/admin/components/product/product-status-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +0 -18
- package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +0 -31
- package/.medusa/server/src/admin/components/product/variant-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +0 -15
- package/.medusa/server/src/admin/components/section-row.js +0 -32
- package/.medusa/server/src/admin/components/sidebar-link.js +0 -31
- package/.medusa/server/src/admin/components/sortable-list.js +0 -152
- package/.medusa/server/src/admin/components/switch-box.js +0 -43
- package/.medusa/server/src/admin/components/tax-badge.js +0 -18
- package/.medusa/server/src/admin/components/thumbnail.js +0 -28
- package/.medusa/server/src/admin/components/upload-media-form-item.js +0 -83
- package/.medusa/server/src/admin/hooks/api/customers.js +0 -26
- package/.medusa/server/src/admin/hooks/api/gift-cards.js +0 -107
- package/.medusa/server/src/admin/hooks/api/order.js +0 -16
- package/.medusa/server/src/admin/hooks/api/price-preferences.js +0 -19
- package/.medusa/server/src/admin/hooks/api/products.js +0 -127
- package/.medusa/server/src/admin/hooks/api/regions.js +0 -17
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +0 -28
- package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +0 -41
- package/.medusa/server/src/admin/hooks/api/store.js +0 -31
- package/.medusa/server/src/admin/hooks/api/transaction-groups.js +0 -23
- package/.medusa/server/src/admin/hooks/api/transactions.js +0 -23
- package/.medusa/server/src/admin/hooks/commands/use-command-history.js +0 -45
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +0 -59
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +0 -89
- package/.medusa/server/src/admin/hooks/common/use-date.js +0 -32
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +0 -22
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +0 -14
- package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/sales-channels/index.js +0 -10
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +0 -48
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +0 -19
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +0 -23
- package/.medusa/server/src/admin/lib/currencies.js +0 -729
- package/.medusa/server/src/admin/lib/query-key.js +0 -17
- package/.medusa/server/src/admin/lib/sdk.js +0 -10
- package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +0 -75
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +0 -172
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +0 -30
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +0 -180
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +0 -30
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +0 -97
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +0 -162
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +0 -89
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +0 -199
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +0 -353
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +0 -5
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +0 -247
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +0 -5
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +0 -48
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +0 -14
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +0 -28
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +0 -40
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +0 -121
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +0 -72
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +0 -123
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +0 -1
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +0 -98
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +0 -28
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +0 -96
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +0 -90
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +0 -288
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +0 -111
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +0 -285
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +0 -124
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +0 -112
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +0 -1
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +0 -35
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +0 -11
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +0 -61
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/page.js +0 -18
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +0 -137
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +0 -87
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +0 -352
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +0 -116
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +0 -49
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +0 -177
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +0 -27
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +0 -33
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +0 -33
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +0 -18
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +0 -50
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +0 -78
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +0 -40
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +0 -57
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +0 -13
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +0 -61
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-cards/page.js +0 -27
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +0 -126
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +0 -31
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +0 -43
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +0 -44
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +0 -18
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +0 -37
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +0 -58
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +0 -39
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +0 -58
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +0 -13
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +0 -31
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +0 -56
- package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +0 -19
- package/.medusa/server/src/admin/utils/date-utils.js +0 -27
- package/.medusa/server/src/admin/utils/format-amount.js +0 -9
- package/.medusa/server/src/admin/utils/format-date.js +0 -21
- package/.medusa/server/src/admin/utils/refs.js +0 -20
- package/.medusa/server/src/admin/utils/statuses.js +0 -23
- package/.medusa/server/src/admin/utils/validations.js +0 -71
- package/.medusa/server/src/admin/utils/variants.js +0 -92
- package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +0 -67
- package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +0 -42
- package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +0 -58
- package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +0 -96
- package/.medusa/server/types/loyalty/module.js +0 -8
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { zodResolver } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@hookform/resolvers/zod/dist/zod.mjs";
|
|
3
|
-
import { Heading, toast, Input, Select, Button } from "@medusajs/ui";
|
|
4
|
-
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
5
|
-
import { useParams } from "react-router-dom";
|
|
6
|
-
import { z } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
7
|
-
import { Form } from "../../../../components/form.js";
|
|
8
|
-
import { KeyboundForm } from "../../../../components/keybound-form.js";
|
|
9
|
-
import { RouteDrawer } from "../../../../components/modals/route-drawer/route-drawer.js";
|
|
10
|
-
import "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
11
|
-
import "react";
|
|
12
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
13
|
-
import { useRouteModal } from "../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
14
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
15
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
16
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
17
|
-
import { useCustomers } from "../../../../hooks/api/customers.js";
|
|
18
|
-
import { useGiftCard, useTransferGiftCard } from "../../../../hooks/api/gift-cards.js";
|
|
19
|
-
import { TransferIcon } from "./components/transfer-icon.js";
|
|
20
|
-
const Note = () => {
|
|
21
|
-
const { id } = useParams();
|
|
22
|
-
const {
|
|
23
|
-
gift_card: giftCard,
|
|
24
|
-
isPending,
|
|
25
|
-
isError,
|
|
26
|
-
error
|
|
27
|
-
} = useGiftCard(id, {});
|
|
28
|
-
if (isError) {
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
const isReady = !isPending && !!giftCard;
|
|
32
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
33
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
34
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Gift Card" }) }),
|
|
35
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the gift card to a new owner" }) })
|
|
36
|
-
] }),
|
|
37
|
-
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
38
|
-
] });
|
|
39
|
-
};
|
|
40
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
41
|
-
const { customers } = useCustomers();
|
|
42
|
-
const form = useForm({
|
|
43
|
-
defaultValues: {
|
|
44
|
-
customer_id: giftCard.customer.id
|
|
45
|
-
},
|
|
46
|
-
resolver: zodResolver(schema)
|
|
47
|
-
});
|
|
48
|
-
const { mutateAsync, isPending } = useTransferGiftCard(giftCard.id);
|
|
49
|
-
const { handleSuccess } = useRouteModal();
|
|
50
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
51
|
-
await mutateAsync(
|
|
52
|
-
{ customer_id: data.customer_id },
|
|
53
|
-
{
|
|
54
|
-
onSuccess: () => {
|
|
55
|
-
toast.success("Gift card transferred successfully");
|
|
56
|
-
handleSuccess();
|
|
57
|
-
},
|
|
58
|
-
onError: (error) => toast.error(error.message)
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
63
|
-
KeyboundForm,
|
|
64
|
-
{
|
|
65
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
66
|
-
onSubmit,
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
69
|
-
/* @__PURE__ */ jsx(TransferIcon, {}),
|
|
70
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
71
|
-
/* @__PURE__ */ jsx(Form.Label, { children: "Current Owner" }),
|
|
72
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { value: giftCard.customer.email, readOnly: true, disabled: true }) }),
|
|
73
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
74
|
-
] }) }),
|
|
75
|
-
/* @__PURE__ */ jsx(
|
|
76
|
-
Form.Field,
|
|
77
|
-
{
|
|
78
|
-
control: form.control,
|
|
79
|
-
name: "customer_id",
|
|
80
|
-
render: ({ field: { onChange, ref, ...field } }) => {
|
|
81
|
-
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
82
|
-
/* @__PURE__ */ jsx(Form.Label, { children: "New Owner" }),
|
|
83
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
|
|
84
|
-
/* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
85
|
-
/* @__PURE__ */ jsx(Select.Content, { children: customers == null ? void 0 : customers.map((customer) => {
|
|
86
|
-
const customerName = [
|
|
87
|
-
customer.first_name,
|
|
88
|
-
customer.last_name
|
|
89
|
-
];
|
|
90
|
-
return /* @__PURE__ */ jsxs(Select.Item, { value: customer.id, children: [
|
|
91
|
-
customer.email,
|
|
92
|
-
" ",
|
|
93
|
-
customerName.join("").length ? `(${customerName.join(" ")})` : ""
|
|
94
|
-
] }, customer.id);
|
|
95
|
-
}) })
|
|
96
|
-
] }) }),
|
|
97
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
98
|
-
] });
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
] }),
|
|
103
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
104
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
105
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
106
|
-
] }) })
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
) });
|
|
110
|
-
};
|
|
111
|
-
const schema = z.object({
|
|
112
|
-
customer_id: z.string()
|
|
113
|
-
});
|
|
114
|
-
export {
|
|
115
|
-
Note as default
|
|
116
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Container, Text } from "@medusajs/ui";
|
|
3
|
-
import { formatAmount } from "../../../../utils/format-amount.js";
|
|
4
|
-
const GiftCardBalanceSection = ({
|
|
5
|
-
storeCreditAccount,
|
|
6
|
-
giftCard
|
|
7
|
-
}) => {
|
|
8
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
return /* @__PURE__ */ jsxs(Container, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: [
|
|
12
|
-
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
|
|
13
|
-
/* @__PURE__ */ jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
14
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
15
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
16
|
-
/* @__PURE__ */ jsx(
|
|
17
|
-
Text,
|
|
18
|
-
{
|
|
19
|
-
weight: "plus",
|
|
20
|
-
size: "xlarge",
|
|
21
|
-
className: "tabular-nums text-ui-fg-base",
|
|
22
|
-
children: formatAmount(
|
|
23
|
-
storeCreditAccount.balance,
|
|
24
|
-
giftCard.currency_code
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
] })
|
|
29
|
-
] }),
|
|
30
|
-
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
|
|
31
|
-
/* @__PURE__ */ jsx("div", { className: "bg-ui-tag-neutral-icon h-8 w-1 rounded-full" }),
|
|
32
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
33
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Initial Balance" }),
|
|
34
|
-
/* @__PURE__ */ jsx(
|
|
35
|
-
Text,
|
|
36
|
-
{
|
|
37
|
-
weight: "plus",
|
|
38
|
-
size: "xlarge",
|
|
39
|
-
className: "tabular-nums text-ui-fg-base",
|
|
40
|
-
children: formatAmount(giftCard.value, giftCard.currency_code)
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
] })
|
|
44
|
-
] })
|
|
45
|
-
] });
|
|
46
|
-
};
|
|
47
|
-
export {
|
|
48
|
-
GiftCardBalanceSection as default
|
|
49
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Gift, Calendar, Trash } from "@medusajs/icons";
|
|
3
|
-
import { usePrompt, Container, Heading, Copy, Text, StatusBadge, Badge, toast } from "@medusajs/ui";
|
|
4
|
-
import { useNavigate, Link } from "react-router-dom";
|
|
5
|
-
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
6
|
-
import { SectionRow } from "../../../../components/section-row.js";
|
|
7
|
-
import { Thumbnail } from "../../../../components/thumbnail.js";
|
|
8
|
-
import { useRedeemGiftCard, useDeleteGiftCard } from "../../../../hooks/api/gift-cards.js";
|
|
9
|
-
import { getFullDate } from "../../../../utils/date-utils.js";
|
|
10
|
-
import { formatAmount } from "../../../../utils/format-amount.js";
|
|
11
|
-
import { formatDate, getRelativeDate } from "../../../../utils/format-date.js";
|
|
12
|
-
import { getGiftCardStatus, getGiftCardStatusColor } from "../../../../utils/statuses.js";
|
|
13
|
-
const GiftCardGeneralSection = ({ giftCard }) => {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
15
|
-
const prompt = usePrompt();
|
|
16
|
-
const navigate = useNavigate();
|
|
17
|
-
const { mutateAsync: redeemGiftCard, isPending } = useRedeemGiftCard(
|
|
18
|
-
giftCard.id
|
|
19
|
-
);
|
|
20
|
-
const { mutateAsync: deleteGiftCard, isPending: isDeleting } = useDeleteGiftCard(giftCard.id);
|
|
21
|
-
const handleRedeem = async () => {
|
|
22
|
-
const res = await prompt({
|
|
23
|
-
title: "Redeem gift card",
|
|
24
|
-
description: `Are you sure? This cannot be undone. Once you confirm the gift card value will be added to the customers store credit account.`,
|
|
25
|
-
confirmText: "Redeem",
|
|
26
|
-
cancelText: "Cancel"
|
|
27
|
-
});
|
|
28
|
-
if (!res) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
await redeemGiftCard(
|
|
32
|
-
{ customer_id: giftCard == null ? void 0 : giftCard.customer_id },
|
|
33
|
-
{
|
|
34
|
-
onSuccess: () => {
|
|
35
|
-
toast.success("Successfully redeemed gift card");
|
|
36
|
-
navigate("..", { replace: true });
|
|
37
|
-
},
|
|
38
|
-
onError: (err) => {
|
|
39
|
-
toast.error(err.message);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
const handleDelete = async () => {
|
|
45
|
-
const res = await prompt({
|
|
46
|
-
title: "Delete gift card",
|
|
47
|
-
description: "Are you sure? This cannot be undone.",
|
|
48
|
-
verificationText: giftCard.value.toString(),
|
|
49
|
-
verificationInstruction: "Confirmation",
|
|
50
|
-
confirmText: "Delete",
|
|
51
|
-
cancelText: "Cancel"
|
|
52
|
-
});
|
|
53
|
-
if (!res) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
await deleteGiftCard(void 0, {
|
|
57
|
-
onSuccess: () => toast.success("Gift card deleted successfully"),
|
|
58
|
-
onError: (error) => toast.error(error.message)
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const status = getGiftCardStatus(giftCard);
|
|
62
|
-
const statusColor = getGiftCardStatusColor(status);
|
|
63
|
-
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
64
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
65
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
66
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
67
|
-
/* @__PURE__ */ jsxs(Heading, { children: [
|
|
68
|
-
"#",
|
|
69
|
-
giftCard.code
|
|
70
|
-
] }),
|
|
71
|
-
/* @__PURE__ */ jsx(Copy, { content: `${giftCard.code}`, className: "text-ui-fg-muted" })
|
|
72
|
-
] }),
|
|
73
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: getFullDate({
|
|
74
|
-
date: giftCard.created_at,
|
|
75
|
-
includeTime: true
|
|
76
|
-
}) })
|
|
77
|
-
] }),
|
|
78
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
79
|
-
/* @__PURE__ */ jsx(StatusBadge, { color: statusColor, children: status }),
|
|
80
|
-
/* @__PURE__ */ jsx(
|
|
81
|
-
ActionMenu,
|
|
82
|
-
{
|
|
83
|
-
groups: [
|
|
84
|
-
{
|
|
85
|
-
actions: [
|
|
86
|
-
{
|
|
87
|
-
icon: /* @__PURE__ */ jsx(Gift, {}),
|
|
88
|
-
label: "Redeem gift card",
|
|
89
|
-
onClick: () => handleRedeem(),
|
|
90
|
-
disabled: isPending
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
icon: /* @__PURE__ */ jsx(Calendar, {}),
|
|
94
|
-
label: "Edit expiration date",
|
|
95
|
-
to: "expiration",
|
|
96
|
-
disabled: isPending
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
actions: [
|
|
102
|
-
{
|
|
103
|
-
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
104
|
-
label: "Delete",
|
|
105
|
-
onClick: handleDelete,
|
|
106
|
-
disabled: isDeleting || true
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
] })
|
|
114
|
-
] }),
|
|
115
|
-
((_a = giftCard.line_item) == null ? void 0 : _a.product) && /* @__PURE__ */ jsx(
|
|
116
|
-
SectionRow,
|
|
117
|
-
{
|
|
118
|
-
title: "Gift card product",
|
|
119
|
-
value: /* @__PURE__ */ jsx(
|
|
120
|
-
Link,
|
|
121
|
-
{
|
|
122
|
-
to: `/products/${(_c = (_b = giftCard.line_item) == null ? void 0 : _b.product) == null ? void 0 : _c.id}`,
|
|
123
|
-
className: "text-ui-fg-base text-sm",
|
|
124
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full max-w-[250px] items-center gap-x-3 overflow-hidden", children: [
|
|
125
|
-
/* @__PURE__ */ jsx("div", { className: "w-fit flex-shrink-0", children: /* @__PURE__ */ jsx(
|
|
126
|
-
Thumbnail,
|
|
127
|
-
{
|
|
128
|
-
size: "small",
|
|
129
|
-
src: (_e = (_d = giftCard.line_item) == null ? void 0 : _d.product) == null ? void 0 : _e.thumbnail
|
|
130
|
-
}
|
|
131
|
-
) }),
|
|
132
|
-
/* @__PURE__ */ jsx(
|
|
133
|
-
"span",
|
|
134
|
-
{
|
|
135
|
-
title: (_g = (_f = giftCard.line_item) == null ? void 0 : _f.product) == null ? void 0 : _g.title,
|
|
136
|
-
className: "truncate",
|
|
137
|
-
children: (_i = (_h = giftCard.line_item) == null ? void 0 : _h.product) == null ? void 0 : _i.title
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
] })
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
),
|
|
145
|
-
/* @__PURE__ */ jsx(
|
|
146
|
-
SectionRow,
|
|
147
|
-
{
|
|
148
|
-
title: "Currency",
|
|
149
|
-
value: /* @__PURE__ */ jsx(Badge, { size: "xsmall", className: "text-ui-fg-base rounded-xl px-2", children: giftCard.currency_code.toUpperCase() })
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ jsx(
|
|
153
|
-
SectionRow,
|
|
154
|
-
{
|
|
155
|
-
title: "Value",
|
|
156
|
-
value: formatAmount(giftCard.value, giftCard.currency_code)
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
/* @__PURE__ */ jsx(
|
|
160
|
-
SectionRow,
|
|
161
|
-
{
|
|
162
|
-
title: "Expiration Date",
|
|
163
|
-
value: formatDate(giftCard.expires_at)
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
/* @__PURE__ */ jsx(
|
|
167
|
-
SectionRow,
|
|
168
|
-
{
|
|
169
|
-
title: "Creation Date",
|
|
170
|
-
value: getRelativeDate(giftCard.created_at)
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
] });
|
|
174
|
-
};
|
|
175
|
-
export {
|
|
176
|
-
GiftCardGeneralSection as default
|
|
177
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Container, Text } from "@medusajs/ui";
|
|
3
|
-
import { Link } from "react-router-dom";
|
|
4
|
-
import { Header } from "../../../../components/header.js";
|
|
5
|
-
const GiftCardNoteSection = ({ giftCard }) => {
|
|
6
|
-
if (!giftCard) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
10
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
11
|
-
/* @__PURE__ */ jsx(Header, { title: "Note" }),
|
|
12
|
-
/* @__PURE__ */ jsx(Link, { to: "note", className: "text-ui-fg-muted text-sm px-6", children: "Edit note" })
|
|
13
|
-
] }),
|
|
14
|
-
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(
|
|
15
|
-
Text,
|
|
16
|
-
{
|
|
17
|
-
size: "small",
|
|
18
|
-
leading: "compact",
|
|
19
|
-
className: "text-ui-fg-subtle",
|
|
20
|
-
children: giftCard.note ?? ""
|
|
21
|
-
}
|
|
22
|
-
) }) }) }) })
|
|
23
|
-
] });
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
GiftCardNoteSection as default
|
|
27
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ShoppingCart } from "@medusajs/icons";
|
|
3
|
-
import { Container } from "@medusajs/ui";
|
|
4
|
-
import { Header } from "../../../../components/header.js";
|
|
5
|
-
import { SidebarLink } from "../../../../components/sidebar-link.js";
|
|
6
|
-
import { useOrder } from "../../../../hooks/api/order.js";
|
|
7
|
-
const GiftCardOrderSection = ({ giftCard }) => {
|
|
8
|
-
if (!giftCard || giftCard.reference !== "order") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const { order, isLoading, isError, error } = useOrder(giftCard.reference_id);
|
|
12
|
-
if (isError) {
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
if (isLoading) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
19
|
-
/* @__PURE__ */ jsx(Header, { title: "Order" }),
|
|
20
|
-
/* @__PURE__ */ jsx(
|
|
21
|
-
SidebarLink,
|
|
22
|
-
{
|
|
23
|
-
to: `/orders/${order.id}`,
|
|
24
|
-
labelKey: `#${order.display_id}`,
|
|
25
|
-
icon: /* @__PURE__ */ jsx(ShoppingCart, {}),
|
|
26
|
-
descriptionKey: `Order #${order.display_id}`
|
|
27
|
-
}
|
|
28
|
-
)
|
|
29
|
-
] });
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
GiftCardOrderSection as default
|
|
33
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { UserMini } from "@medusajs/icons";
|
|
3
|
-
import { Container } from "@medusajs/ui";
|
|
4
|
-
import { Link } from "react-router-dom";
|
|
5
|
-
import { GiftCardStatus } from "../../../../../../types/loyalty/module.js";
|
|
6
|
-
import { Header } from "../../../../components/header.js";
|
|
7
|
-
import { SidebarLink } from "../../../../components/sidebar-link.js";
|
|
8
|
-
const GiftCardOwnerSection = ({ giftCard }) => {
|
|
9
|
-
if (!giftCard) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
13
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
14
|
-
/* @__PURE__ */ jsx(Header, { title: "Owner" }),
|
|
15
|
-
giftCard.status !== GiftCardStatus.REDEEMED && /* @__PURE__ */ jsx(Link, { to: `owner`, className: "text-ui-fg-muted text-sm px-6", children: "Transfer ownership" })
|
|
16
|
-
] }),
|
|
17
|
-
/* @__PURE__ */ jsx(
|
|
18
|
-
SidebarLink,
|
|
19
|
-
{
|
|
20
|
-
to: `/customers/${giftCard.customer.id}`,
|
|
21
|
-
labelKey: `${[
|
|
22
|
-
giftCard.customer.first_name,
|
|
23
|
-
giftCard.customer.last_name
|
|
24
|
-
].join(" ")}`,
|
|
25
|
-
descriptionKey: giftCard.customer.email,
|
|
26
|
-
icon: /* @__PURE__ */ jsx(UserMini, {})
|
|
27
|
-
}
|
|
28
|
-
)
|
|
29
|
-
] });
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
GiftCardOwnerSection as default
|
|
33
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Container } from "@medusajs/ui";
|
|
3
|
-
import { TransactionsTable } from "../../../store-credit-accounts/_id_/components/transactions-table/table.js";
|
|
4
|
-
const GiftCardTransactionsSection = ({
|
|
5
|
-
storeCreditAccount,
|
|
6
|
-
transactionGroup
|
|
7
|
-
}) => {
|
|
8
|
-
return /* @__PURE__ */ jsx(Container, { className: "divide-y p-0", children: /* @__PURE__ */ jsx(
|
|
9
|
-
TransactionsTable,
|
|
10
|
-
{
|
|
11
|
-
id: storeCreditAccount.id,
|
|
12
|
-
transactionGroup
|
|
13
|
-
}
|
|
14
|
-
) }, storeCreditAccount.id);
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
GiftCardTransactionsSection as default
|
|
18
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createDataTableColumnHelper, Badge } from "@medusajs/ui";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { getRelativeDate } from "../../../../../utils/date-utils.js";
|
|
5
|
-
import { formatAmount } from "../../../../../utils/format-amount.js";
|
|
6
|
-
const columnHelper = createDataTableColumnHelper();
|
|
7
|
-
const useTransactionColumns = () => {
|
|
8
|
-
return useMemo(() => {
|
|
9
|
-
return [
|
|
10
|
-
columnHelper.accessor("type", {
|
|
11
|
-
header: "Type",
|
|
12
|
-
cell: ({ row }) => {
|
|
13
|
-
return /* @__PURE__ */ jsx(
|
|
14
|
-
Badge,
|
|
15
|
-
{
|
|
16
|
-
size: "2xsmall",
|
|
17
|
-
color: row.original.type === "debit" ? "orange" : "green",
|
|
18
|
-
children: row.original.type
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
}),
|
|
23
|
-
columnHelper.accessor("amount", {
|
|
24
|
-
header: "Amount",
|
|
25
|
-
cell: ({ row }) => {
|
|
26
|
-
return row.original.account.currency_code && formatAmount(
|
|
27
|
-
row.original.amount,
|
|
28
|
-
row.original.account.currency_code
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
}),
|
|
32
|
-
columnHelper.accessor("reference", {
|
|
33
|
-
header: "Reference",
|
|
34
|
-
cell: ({ row }) => {
|
|
35
|
-
return /* @__PURE__ */ jsx(Badge, { size: "2xsmall", children: row.original.reference });
|
|
36
|
-
}
|
|
37
|
-
}),
|
|
38
|
-
columnHelper.accessor("reference_id", {
|
|
39
|
-
header: "Reference ID"
|
|
40
|
-
}),
|
|
41
|
-
columnHelper.accessor("created_at", {
|
|
42
|
-
header: "Created At",
|
|
43
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
44
|
-
})
|
|
45
|
-
];
|
|
46
|
-
}, []);
|
|
47
|
-
};
|
|
48
|
-
export {
|
|
49
|
-
useTransactionColumns
|
|
50
|
-
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useQueryParams } from "../../../../../hooks/common/use-query-params.js";
|
|
2
|
-
const useTransactionTableQuery = ({
|
|
3
|
-
prefix,
|
|
4
|
-
pageSize = 10
|
|
5
|
-
}) => {
|
|
6
|
-
const queryObject = useQueryParams(
|
|
7
|
-
["offset", "transaction_group_id", "created_at", "updated_at"],
|
|
8
|
-
prefix
|
|
9
|
-
);
|
|
10
|
-
const { offset, created_at, updated_at, transaction_group_id, ...rest } = queryObject;
|
|
11
|
-
const searchParams = {
|
|
12
|
-
limit: pageSize,
|
|
13
|
-
offset: offset ? Number(offset) : 0,
|
|
14
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
15
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
16
|
-
transaction_group_id: transaction_group_id ? JSON.parse(transaction_group_id) : void 0,
|
|
17
|
-
...rest
|
|
18
|
-
};
|
|
19
|
-
return searchParams;
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
useTransactionTableQuery
|
|
23
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useParams, Outlet } from "react-router-dom";
|
|
3
|
-
import { JsonViewSection } from "../../../components/json-view-section.js";
|
|
4
|
-
import { TwoColumnLayout } from "../../../components/layouts/two-column.js";
|
|
5
|
-
import { useGiftCard } from "../../../hooks/api/gift-cards.js";
|
|
6
|
-
import { useStoreCreditAccounts, useStoreCreditAccount } from "../../../hooks/api/store-credit-accounts.js";
|
|
7
|
-
import { useTransactionGroups } from "../../../hooks/api/transaction-groups.js";
|
|
8
|
-
import GiftCardBalanceSection from "./components/gift-card-balance-section.js";
|
|
9
|
-
import GiftCardGeneralSection from "./components/gift-card-general-section.js";
|
|
10
|
-
import GiftCardNoteSection from "./components/gift-card-note-section.js";
|
|
11
|
-
import GiftCardOrderSection from "./components/gift-card-order-section.js";
|
|
12
|
-
import GiftCardOwnerSection from "./components/gift-card-owner-section.js";
|
|
13
|
-
import GiftCardTransactionsSection from "./components/gift-card-transactions-section.js";
|
|
14
|
-
const GiftCardDetailsPage = () => {
|
|
15
|
-
var _a;
|
|
16
|
-
const { id } = useParams();
|
|
17
|
-
const { gift_card: giftCard, isLoading } = useGiftCard(id, {
|
|
18
|
-
fields: "*line_item.product"
|
|
19
|
-
});
|
|
20
|
-
const { store_credit_accounts: storeCreditAccounts } = useStoreCreditAccounts(
|
|
21
|
-
{
|
|
22
|
-
customer_id: giftCard == null ? void 0 : giftCard.customer_id,
|
|
23
|
-
currency_code: giftCard == null ? void 0 : giftCard.currency_code
|
|
24
|
-
},
|
|
25
|
-
{ enabled: !isLoading && !!(giftCard == null ? void 0 : giftCard.customer_id) }
|
|
26
|
-
);
|
|
27
|
-
const { transaction_groups: transactionGroups } = useTransactionGroups(
|
|
28
|
-
{ code: giftCard == null ? void 0 : giftCard.code },
|
|
29
|
-
{ enabled: !isLoading && !!(giftCard == null ? void 0 : giftCard.code) }
|
|
30
|
-
);
|
|
31
|
-
const transactionGroup = transactionGroups == null ? void 0 : transactionGroups[0];
|
|
32
|
-
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
33
|
-
(_a = storeCreditAccounts == null ? void 0 : storeCreditAccounts[0]) == null ? void 0 : _a.id,
|
|
34
|
-
{
|
|
35
|
-
transaction_group_id: transactionGroup == null ? void 0 : transactionGroup.id
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
enabled: !isLoading && !!(giftCard == null ? void 0 : giftCard.customer_id) && !!(transactionGroup == null ? void 0 : transactionGroup.id) && !!(storeCreditAccounts == null ? void 0 : storeCreditAccounts.length)
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
if (!giftCard) {
|
|
42
|
-
return /* @__PURE__ */ jsx(Fragment, { children: "Loading" });
|
|
43
|
-
}
|
|
44
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
-
/* @__PURE__ */ jsx(
|
|
46
|
-
TwoColumnLayout,
|
|
47
|
-
{
|
|
48
|
-
firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
49
|
-
/* @__PURE__ */ jsx(GiftCardGeneralSection, { giftCard }),
|
|
50
|
-
storeCreditAccount && transactionGroup && /* @__PURE__ */ jsx(
|
|
51
|
-
GiftCardTransactionsSection,
|
|
52
|
-
{
|
|
53
|
-
storeCreditAccount,
|
|
54
|
-
transactionGroup
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
/* @__PURE__ */ jsx(JsonViewSection, { data: giftCard })
|
|
58
|
-
] }),
|
|
59
|
-
secondCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
-
storeCreditAccount && /* @__PURE__ */ jsx(
|
|
61
|
-
GiftCardBalanceSection,
|
|
62
|
-
{
|
|
63
|
-
storeCreditAccount,
|
|
64
|
-
giftCard
|
|
65
|
-
}
|
|
66
|
-
),
|
|
67
|
-
/* @__PURE__ */ jsx(GiftCardOwnerSection, { giftCard }),
|
|
68
|
-
/* @__PURE__ */ jsx(GiftCardNoteSection, { giftCard }),
|
|
69
|
-
/* @__PURE__ */ jsx(GiftCardOrderSection, { giftCard })
|
|
70
|
-
] })
|
|
71
|
-
}
|
|
72
|
-
),
|
|
73
|
-
/* @__PURE__ */ jsx(Outlet, {})
|
|
74
|
-
] });
|
|
75
|
-
};
|
|
76
|
-
export {
|
|
77
|
-
GiftCardDetailsPage as default
|
|
78
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Tag } from "@medusajs/icons";
|
|
3
|
-
import { Container } from "@medusajs/ui";
|
|
4
|
-
import { Link } from "react-router-dom";
|
|
5
|
-
import { Header } from "../../../components/header.js";
|
|
6
|
-
import { SidebarLink } from "../../../components/sidebar-link.js";
|
|
7
|
-
import { useProducts } from "../../../hooks/api/products.js";
|
|
8
|
-
const GiftCardProductsSection = () => {
|
|
9
|
-
const { products: giftCardProducts } = useProducts({
|
|
10
|
-
is_giftcard: true
|
|
11
|
-
});
|
|
12
|
-
if (!(giftCardProducts == null ? void 0 : giftCardProducts.length)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
16
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
17
|
-
/* @__PURE__ */ jsx(Header, { title: "Gift Card Products" }),
|
|
18
|
-
/* @__PURE__ */ jsx(
|
|
19
|
-
Link,
|
|
20
|
-
{
|
|
21
|
-
to: `/gift-card-products/create`,
|
|
22
|
-
className: "text-ui-fg-muted text-sm px-6",
|
|
23
|
-
children: "Create gift card product"
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
] }),
|
|
27
|
-
giftCardProducts.map((giftCardProduct) => /* @__PURE__ */ jsx(
|
|
28
|
-
SidebarLink,
|
|
29
|
-
{
|
|
30
|
-
to: `/gift-card-products/${giftCardProduct.id}`,
|
|
31
|
-
labelKey: giftCardProduct.title,
|
|
32
|
-
descriptionKey: giftCardProduct.title,
|
|
33
|
-
icon: /* @__PURE__ */ jsx(Tag, {})
|
|
34
|
-
}
|
|
35
|
-
))
|
|
36
|
-
] });
|
|
37
|
-
};
|
|
38
|
-
export {
|
|
39
|
-
GiftCardProductsSection as default
|
|
40
|
-
};
|