@vicacha-devs/medusa-plugin-barcode 0.0.0-stage → 0.0.1
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.cjs +3960 -0
- package/.medusa/server/src/admin/index.js +3938 -0
- package/.medusa/server/src/api/admin/barcodes/[barcode]/route.js +43 -0
- package/.medusa/server/src/api/admin/barcodes/batch/route.js +9 -0
- package/.medusa/server/src/api/admin/barcodes/bulk-generate/route.js +9 -0
- package/.medusa/server/src/api/admin/barcodes/cache/route.js +25 -0
- package/.medusa/server/src/api/admin/barcodes/count-sessions/[id]/apply/route.js +13 -0
- package/.medusa/server/src/api/admin/barcodes/count-sessions/[id]/scan/route.js +13 -0
- package/.medusa/server/src/api/admin/barcodes/count-sessions/route.js +27 -0
- package/.medusa/server/src/api/admin/barcodes/create-from-barcode/route.js +9 -0
- package/.medusa/server/src/api/admin/barcodes/lookup/route.js +12 -0
- package/.medusa/server/src/api/admin/barcodes/print/route.js +11 -0
- package/.medusa/server/src/api/admin/barcodes/route.js +27 -0
- package/.medusa/server/src/api/admin/barcodes/scan/route.js +23 -0
- package/.medusa/server/src/api/admin/barcodes/tags/[id]/route.js +28 -0
- package/.medusa/server/src/api/admin/barcodes/tags/route.js +25 -0
- package/.medusa/server/src/api/admin/barcodes/templates/route.js +40 -0
- package/.medusa/server/src/api/admin/plugin/route.js +4 -0
- package/.medusa/server/src/api/admin/variants/barcode/[code]/route.js +28 -0
- package/.medusa/server/src/api/middlewares.js +73 -0
- package/.medusa/server/src/api/store/barcodes/[code]/route.js +28 -0
- package/.medusa/server/src/api/store/barcodes/[code]/verify/route.js +20 -0
- package/.medusa/server/src/api/store/plugin/route.js +4 -0
- package/.medusa/server/src/api/store/variants/barcode/[code]/route.js +28 -0
- package/.medusa/server/src/api/validators.js +173 -0
- package/.medusa/server/src/hooks/index.js +202 -0
- package/.medusa/server/src/index.js +5 -0
- package/.medusa/server/src/jobs/purge-expired-barcode-cache.js +10 -0
- package/.medusa/server/src/modules/barcode/index.js +16 -0
- package/.medusa/server/src/modules/barcode/migrations/Migration20260522000000.js +165 -0
- package/.medusa/server/src/modules/barcode/models/index.js +162 -0
- package/.medusa/server/src/modules/barcode/operations/context.js +2 -0
- package/.medusa/server/src/modules/barcode/operations/data-service.js +10 -0
- package/.medusa/server/src/modules/barcode/operations/generation.js +33 -0
- package/.medusa/server/src/modules/barcode/operations/index.js +9 -0
- package/.medusa/server/src/modules/barcode/operations/labels.js +57 -0
- package/.medusa/server/src/modules/barcode/operations/lookup.js +135 -0
- package/.medusa/server/src/modules/barcode/operations/maintenance.js +37 -0
- package/.medusa/server/src/modules/barcode/operations/stock-count.js +129 -0
- package/.medusa/server/src/modules/barcode/operations/tags.js +298 -0
- package/.medusa/server/src/modules/barcode/providers/index.js +721 -0
- package/.medusa/server/src/modules/barcode/service.js +161 -0
- package/.medusa/server/src/modules/barcode/types.js +21 -0
- package/.medusa/server/src/modules/barcode/utils/barcode-parser.js +399 -0
- package/.medusa/server/src/modules/barcode/utils/label-printer.js +533 -0
- package/.medusa/server/src/modules/barcode/utils/normalize-product.js +443 -0
- package/.medusa/server/src/modules/barcode/utils/security.js +114 -0
- package/.medusa/server/src/modules/barcode/utils/svg-renderer.js +492 -0
- package/.medusa/server/src/rbac.js +130 -0
- package/.medusa/server/src/sdk/index.js +164 -0
- package/.medusa/server/src/subscribers/product-created.js +34 -0
- package/.medusa/server/src/types/index.js +2 -0
- package/.medusa/server/src/ui/index.js +138 -0
- package/.medusa/server/src/workflows/apply-inventory-count.js +68 -0
- package/.medusa/server/src/workflows/batch-barcode-import.js +153 -0
- package/.medusa/server/src/workflows/bulk-generate-variant-barcodes.js +143 -0
- package/.medusa/server/src/workflows/generate-barcode-tag.js +44 -0
- package/.medusa/server/src/workflows/helpers.js +15 -0
- package/.medusa/server/src/workflows/index.js +7 -0
- package/.medusa/server/src/workflows/lookup-and-create-product.js +215 -0
- package/.medusa/server/src/workflows/scan-inventory-count.js +15 -0
- package/LICENSE +21 -0
- package/README.md +844 -2
- package/package.json +129 -3
- package/src/__tests__/barcode.spec.ts +836 -0
- package/src/__tests__/medusa-shim.mjs +331 -0
- package/src/__tests__/register-ts-resolver.mjs +135 -0
- package/src/admin/README.md +134 -0
- package/src/admin/components/barcode-studio-header.tsx +73 -0
- package/src/admin/components/batch-import-section.tsx +99 -0
- package/src/admin/components/dynamic-qr-tag-drawer-form.tsx +230 -0
- package/src/admin/components/dynamic-qr-tag-form.tsx +129 -0
- package/src/admin/components/dynamic-qr-tags-table.tsx +136 -0
- package/src/admin/components/gtin-lookup-section.tsx +155 -0
- package/src/admin/components/index.tsx +14 -0
- package/src/admin/components/label-designer-section.tsx +151 -0
- package/src/admin/components/label-output-section.tsx +63 -0
- package/src/admin/components/overview-cards.tsx +98 -0
- package/src/admin/components/product-barcode-card.tsx +127 -0
- package/src/admin/components/providers-cache-table.tsx +61 -0
- package/src/admin/components/providers-overview-section.tsx +49 -0
- package/src/admin/components/rbac-guard.tsx +153 -0
- package/src/admin/components/stock-take-scanner-section.tsx +116 -0
- package/src/admin/components/stock-take-sessions-section.tsx +109 -0
- package/src/admin/hooks/use-barcode-studio.ts +466 -0
- package/src/admin/hooks/use-product-barcodes.ts +139 -0
- package/src/admin/i18n/README.md +130 -0
- package/src/admin/i18n/index.ts +36 -0
- package/src/admin/i18n/json/ar.json +157 -0
- package/src/admin/i18n/json/de.json +157 -0
- package/src/admin/i18n/json/en.json +157 -0
- package/src/admin/i18n/json/es.json +157 -0
- package/src/admin/i18n/json/fr.json +157 -0
- package/src/admin/i18n/json/it.json +157 -0
- package/src/admin/i18n/json/nl.json +157 -0
- package/src/admin/i18n/json/pl.json +157 -0
- package/src/admin/i18n/json/pt.json +157 -0
- package/src/admin/i18n/json/tr.json +157 -0
- package/src/admin/routes/barcodes/lookup/page.tsx +75 -0
- package/src/admin/routes/barcodes/page.tsx +212 -0
- package/src/admin/routes/barcodes/print/page.tsx +67 -0
- package/src/admin/routes/barcodes/providers/page.tsx +66 -0
- package/src/admin/routes/barcodes/stock-take/page.tsx +74 -0
- package/src/admin/routes/barcodes/tags/@create/page.tsx +56 -0
- package/src/admin/routes/barcodes/tags/page.tsx +72 -0
- package/src/admin/tsconfig.json +20 -0
- package/src/admin/vite-env.d.ts +1 -0
- package/src/admin/widgets/product-barcode-widget.tsx +43 -0
- package/src/api/README.md +117 -0
- package/src/api/admin/barcodes/[barcode]/route.ts +64 -0
- package/src/api/admin/barcodes/batch/route.ts +12 -0
- package/src/api/admin/barcodes/bulk-generate/route.ts +12 -0
- package/src/api/admin/barcodes/cache/route.ts +35 -0
- package/src/api/admin/barcodes/count-sessions/[id]/apply/route.ts +17 -0
- package/src/api/admin/barcodes/count-sessions/[id]/scan/route.ts +17 -0
- package/src/api/admin/barcodes/count-sessions/route.ts +43 -0
- package/src/api/admin/barcodes/create-from-barcode/route.ts +16 -0
- package/src/api/admin/barcodes/lookup/route.ts +19 -0
- package/src/api/admin/barcodes/print/route.ts +18 -0
- package/src/api/admin/barcodes/route.ts +36 -0
- package/src/api/admin/barcodes/scan/route.ts +32 -0
- package/src/api/admin/barcodes/tags/[id]/route.ts +41 -0
- package/src/api/admin/barcodes/tags/route.ts +36 -0
- package/src/api/admin/barcodes/templates/route.ts +51 -0
- package/src/api/admin/plugin/route.ts +5 -0
- package/src/api/admin/variants/barcode/[code]/route.ts +36 -0
- package/src/api/middlewares.ts +91 -0
- package/src/api/store/barcodes/[code]/route.ts +43 -0
- package/src/api/store/barcodes/[code]/verify/route.ts +35 -0
- package/src/api/store/plugin/route.ts +5 -0
- package/src/api/store/variants/barcode/[code]/route.ts +36 -0
- package/src/api/validators.ts +217 -0
- package/src/hooks/index.ts +270 -0
- package/src/index.ts +4 -0
- package/src/jobs/README.md +54 -0
- package/src/jobs/purge-expired-barcode-cache.ts +18 -0
- package/src/links/README.md +44 -0
- package/src/modules/README.md +85 -0
- package/src/modules/barcode/index.ts +18 -0
- package/src/modules/barcode/migrations/Migration20260522000000.ts +225 -0
- package/src/modules/barcode/models/index.ts +168 -0
- package/src/modules/barcode/operations/context.ts +14 -0
- package/src/modules/barcode/operations/data-service.ts +10 -0
- package/src/modules/barcode/operations/generation.ts +57 -0
- package/src/modules/barcode/operations/index.ts +8 -0
- package/src/modules/barcode/operations/labels.ts +90 -0
- package/src/modules/barcode/operations/lookup.ts +202 -0
- package/src/modules/barcode/operations/maintenance.ts +53 -0
- package/src/modules/barcode/operations/stock-count.ts +217 -0
- package/src/modules/barcode/operations/tags.ts +425 -0
- package/src/modules/barcode/providers/index.ts +958 -0
- package/src/modules/barcode/service.ts +243 -0
- package/src/modules/barcode/types.ts +297 -0
- package/src/modules/barcode/utils/barcode-parser.ts +453 -0
- package/src/modules/barcode/utils/label-printer.ts +641 -0
- package/src/modules/barcode/utils/normalize-product.ts +524 -0
- package/src/modules/barcode/utils/security.ts +136 -0
- package/src/modules/barcode/utils/svg-renderer.ts +574 -0
- package/src/providers/README.md +105 -0
- package/src/rbac.ts +144 -0
- package/src/sdk/index.ts +253 -0
- package/src/subscribers/README.md +73 -0
- package/src/subscribers/product-created.ts +45 -0
- package/src/types/index.ts +1 -0
- package/src/types/medusa-ui.d.ts +118 -0
- package/src/ui/index.tsx +311 -0
- package/src/workflows/README.md +56 -0
- package/src/workflows/apply-inventory-count.ts +115 -0
- package/src/workflows/batch-barcode-import.ts +218 -0
- package/src/workflows/bulk-generate-variant-barcodes.ts +214 -0
- package/src/workflows/generate-barcode-tag.ts +85 -0
- package/src/workflows/helpers.ts +21 -0
- package/src/workflows/index.ts +6 -0
- package/src/workflows/lookup-and-create-product.ts +298 -0
- package/src/workflows/scan-inventory-count.ts +45 -0
- package/tsconfig.json +40 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Container,
|
|
5
|
+
Heading,
|
|
6
|
+
Input,
|
|
7
|
+
Select,
|
|
8
|
+
StatusBadge,
|
|
9
|
+
Text,
|
|
10
|
+
} from "@medusajs/ui"
|
|
11
|
+
import { useTranslation } from "react-i18next"
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BarcodeLookupChainResult,
|
|
15
|
+
EnrichmentStrategy,
|
|
16
|
+
} from "../../modules/barcode/types"
|
|
17
|
+
import { BarcodeImage } from "../../ui"
|
|
18
|
+
import type { LookupFormState } from "../hooks/use-barcode-studio"
|
|
19
|
+
import { GtinLookupBatchSection } from "./batch-import-section"
|
|
20
|
+
|
|
21
|
+
export interface GtinLookupTabProps {
|
|
22
|
+
form: LookupFormState
|
|
23
|
+
onFormChange: React.Dispatch<React.SetStateAction<LookupFormState>>
|
|
24
|
+
lookupResult: BarcodeLookupChainResult | null
|
|
25
|
+
barcodes: Array<Record<string, unknown>>
|
|
26
|
+
onLookup: () => void
|
|
27
|
+
onCreateProduct: () => void
|
|
28
|
+
onBatchImport: () => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const GtinLookupLookupSection = ({
|
|
32
|
+
form,
|
|
33
|
+
onFormChange,
|
|
34
|
+
lookupResult,
|
|
35
|
+
onLookup,
|
|
36
|
+
onCreateProduct,
|
|
37
|
+
}: Pick<
|
|
38
|
+
GtinLookupTabProps,
|
|
39
|
+
"form" | "onFormChange" | "lookupResult" | "onLookup" | "onCreateProduct"
|
|
40
|
+
>) => {
|
|
41
|
+
const { t } = useTranslation()
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Container className="divide-y p-0">
|
|
45
|
+
<div className="px-6 py-4">
|
|
46
|
+
<Heading level="h2">{t("lookupTab.lookupTitle")}</Heading>
|
|
47
|
+
<Text size="small" className="text-ui-fg-subtle mt-1">
|
|
48
|
+
{t("lookupTab.lookupSubtitle")}
|
|
49
|
+
</Text>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div className="flex flex-col gap-3 px-6 py-4">
|
|
53
|
+
<div className="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
|
54
|
+
<div className="sm:col-span-2">
|
|
55
|
+
<Input
|
|
56
|
+
value={form.barcode}
|
|
57
|
+
onChange={(e) =>
|
|
58
|
+
onFormChange((prev) => ({ ...prev, barcode: e.target.value }))
|
|
59
|
+
}
|
|
60
|
+
placeholder={t("lookupTab.barcodePlaceholder")}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
<Select
|
|
64
|
+
value={form.strategy}
|
|
65
|
+
onValueChange={(val) =>
|
|
66
|
+
onFormChange((prev) => ({
|
|
67
|
+
...prev,
|
|
68
|
+
strategy: val as EnrichmentStrategy,
|
|
69
|
+
}))
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
<Select.Trigger>
|
|
73
|
+
<Select.Value />
|
|
74
|
+
</Select.Trigger>
|
|
75
|
+
<Select.Content>
|
|
76
|
+
<Select.Item value="first-hit">
|
|
77
|
+
{t("lookupTab.strategyFirstHit")}
|
|
78
|
+
</Select.Item>
|
|
79
|
+
<Select.Item value="deep-merge">
|
|
80
|
+
{t("lookupTab.strategyDeepMerge")}
|
|
81
|
+
</Select.Item>
|
|
82
|
+
</Select.Content>
|
|
83
|
+
</Select>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div className="flex flex-wrap gap-2">
|
|
87
|
+
<Button variant="secondary" size="small" onClick={onLookup}>
|
|
88
|
+
{t("lookupTab.lookupOnlyButton")}
|
|
89
|
+
</Button>
|
|
90
|
+
<Button variant="primary" size="small" onClick={onCreateProduct}>
|
|
91
|
+
{t("lookupTab.lookupAndCreateButton", { status: form.status })}
|
|
92
|
+
</Button>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
{lookupResult ? (
|
|
97
|
+
<>
|
|
98
|
+
<SectionRow
|
|
99
|
+
title={
|
|
100
|
+
lookupResult.product?.name ||
|
|
101
|
+
t("lookupTab.normalizedFallback", {
|
|
102
|
+
barcode: lookupResult.barcode,
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
value={
|
|
106
|
+
<StatusBadge color={lookupResult.found ? "green" : "orange"}>
|
|
107
|
+
{lookupResult.found
|
|
108
|
+
? t("lookupTab.matchedVia", {
|
|
109
|
+
provider: lookupResult.product?.provider ?? "",
|
|
110
|
+
})
|
|
111
|
+
: t("lookupTab.notFound")}
|
|
112
|
+
</StatusBadge>
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
<SectionRow
|
|
116
|
+
title={lookupResult.parsed.type.toUpperCase()}
|
|
117
|
+
value={t("lookupTab.resultDetails", {
|
|
118
|
+
symbology: lookupResult.parsed.type.toUpperCase(),
|
|
119
|
+
valid: lookupResult.parsed.isValid
|
|
120
|
+
? t("lookupTab.yes")
|
|
121
|
+
: t("lookupTab.no"),
|
|
122
|
+
brand: lookupResult.product?.brand || t("lookupTab.na"),
|
|
123
|
+
})}
|
|
124
|
+
/>
|
|
125
|
+
<div className="px-6 py-4">
|
|
126
|
+
<BarcodeImage
|
|
127
|
+
code={lookupResult.barcode}
|
|
128
|
+
symbology={lookupResult.parsed.type}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
</>
|
|
132
|
+
) : null}
|
|
133
|
+
</Container>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const GtinLookupTab = (props: GtinLookupTabProps) => {
|
|
138
|
+
return (
|
|
139
|
+
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
|
140
|
+
<GtinLookupLookupSection
|
|
141
|
+
form={props.form}
|
|
142
|
+
onFormChange={props.onFormChange}
|
|
143
|
+
lookupResult={props.lookupResult}
|
|
144
|
+
onLookup={props.onLookup}
|
|
145
|
+
onCreateProduct={props.onCreateProduct}
|
|
146
|
+
/>
|
|
147
|
+
<GtinLookupBatchSection
|
|
148
|
+
form={props.form}
|
|
149
|
+
onFormChange={props.onFormChange}
|
|
150
|
+
barcodes={props.barcodes}
|
|
151
|
+
onBatchImport={props.onBatchImport}
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./overview-cards"
|
|
2
|
+
export * from "./barcode-studio-header"
|
|
3
|
+
export * from "./gtin-lookup-section"
|
|
4
|
+
export * from "./batch-import-section"
|
|
5
|
+
export * from "./dynamic-qr-tag-drawer-form"
|
|
6
|
+
export * from "./dynamic-qr-tag-form"
|
|
7
|
+
export * from "./dynamic-qr-tags-table"
|
|
8
|
+
export * from "./label-designer-section"
|
|
9
|
+
export * from "./label-output-section"
|
|
10
|
+
export * from "./stock-take-scanner-section"
|
|
11
|
+
export * from "./stock-take-sessions-section"
|
|
12
|
+
export * from "./providers-overview-section"
|
|
13
|
+
export * from "./providers-cache-table"
|
|
14
|
+
export * from "./product-barcode-card"
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Button, Container, Heading, Input, Select } from "@medusajs/ui"
|
|
2
|
+
import { useTranslation } from "react-i18next"
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LabelPrintOutput,
|
|
6
|
+
LabelTemplateSpec,
|
|
7
|
+
} from "../../modules/barcode/types"
|
|
8
|
+
import type { PrintFormState } from "../hooks/use-barcode-studio"
|
|
9
|
+
import { LabelPrintOutputSection } from "./label-output-section"
|
|
10
|
+
|
|
11
|
+
export interface LabelPrintCenterTabProps {
|
|
12
|
+
form: PrintFormState
|
|
13
|
+
onFormChange: React.Dispatch<React.SetStateAction<PrintFormState>>
|
|
14
|
+
templates: LabelTemplateSpec[]
|
|
15
|
+
output: LabelPrintOutput | null
|
|
16
|
+
onRenderLabels: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const LabelPrintDesignerSection = ({
|
|
20
|
+
form,
|
|
21
|
+
onFormChange,
|
|
22
|
+
templates,
|
|
23
|
+
onRenderLabels,
|
|
24
|
+
}: Pick<
|
|
25
|
+
LabelPrintCenterTabProps,
|
|
26
|
+
"form" | "onFormChange" | "templates" | "onRenderLabels"
|
|
27
|
+
>) => {
|
|
28
|
+
const { t } = useTranslation()
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Container className="divide-y p-0">
|
|
32
|
+
<div className="px-6 py-4">
|
|
33
|
+
<Heading level="h2">{t("printTab.designerTitle")}</Heading>
|
|
34
|
+
</div>
|
|
35
|
+
<div className="grid grid-cols-1 gap-3 px-6 py-4 sm:grid-cols-2">
|
|
36
|
+
<div className="sm:col-span-2">
|
|
37
|
+
<Select
|
|
38
|
+
value={form.template_id}
|
|
39
|
+
onValueChange={(val) =>
|
|
40
|
+
onFormChange((prev) => ({ ...prev, template_id: val }))
|
|
41
|
+
}
|
|
42
|
+
>
|
|
43
|
+
<Select.Trigger>
|
|
44
|
+
<Select.Value />
|
|
45
|
+
</Select.Trigger>
|
|
46
|
+
<Select.Content>
|
|
47
|
+
{templates.map((tpl) => (
|
|
48
|
+
<Select.Item key={tpl.id} value={tpl.id}>
|
|
49
|
+
{tpl.name} ({tpl.width_mm}×{tpl.height_mm}mm)
|
|
50
|
+
</Select.Item>
|
|
51
|
+
))}
|
|
52
|
+
</Select.Content>
|
|
53
|
+
</Select>
|
|
54
|
+
</div>
|
|
55
|
+
<Input
|
|
56
|
+
value={form.title}
|
|
57
|
+
onChange={(e) =>
|
|
58
|
+
onFormChange((prev) => ({ ...prev, title: e.target.value }))
|
|
59
|
+
}
|
|
60
|
+
placeholder={t("printTab.productTitlePlaceholder")}
|
|
61
|
+
/>
|
|
62
|
+
<Input
|
|
63
|
+
value={form.variant_title}
|
|
64
|
+
onChange={(e) =>
|
|
65
|
+
onFormChange((prev) => ({
|
|
66
|
+
...prev,
|
|
67
|
+
variant_title: e.target.value,
|
|
68
|
+
}))
|
|
69
|
+
}
|
|
70
|
+
placeholder={t("printTab.variantTitlePlaceholder")}
|
|
71
|
+
/>
|
|
72
|
+
<Input
|
|
73
|
+
value={form.barcode}
|
|
74
|
+
onChange={(e) =>
|
|
75
|
+
onFormChange((prev) => ({ ...prev, barcode: e.target.value }))
|
|
76
|
+
}
|
|
77
|
+
placeholder={t("printTab.barcodePlaceholder")}
|
|
78
|
+
/>
|
|
79
|
+
<Input
|
|
80
|
+
value={form.sku}
|
|
81
|
+
onChange={(e) =>
|
|
82
|
+
onFormChange((prev) => ({ ...prev, sku: e.target.value }))
|
|
83
|
+
}
|
|
84
|
+
placeholder={t("printTab.skuPlaceholder")}
|
|
85
|
+
/>
|
|
86
|
+
<Input
|
|
87
|
+
type="number"
|
|
88
|
+
value={String(form.price)}
|
|
89
|
+
onChange={(e) =>
|
|
90
|
+
onFormChange((prev) => ({
|
|
91
|
+
...prev,
|
|
92
|
+
price: Number(e.target.value || 0),
|
|
93
|
+
}))
|
|
94
|
+
}
|
|
95
|
+
placeholder={t("printTab.salePricePlaceholder")}
|
|
96
|
+
/>
|
|
97
|
+
<Input
|
|
98
|
+
type="number"
|
|
99
|
+
value={String(form.compare_at_price)}
|
|
100
|
+
onChange={(e) =>
|
|
101
|
+
onFormChange((prev) => ({
|
|
102
|
+
...prev,
|
|
103
|
+
compare_at_price: Number(e.target.value || 0),
|
|
104
|
+
}))
|
|
105
|
+
}
|
|
106
|
+
placeholder={t("printTab.compareAtPricePlaceholder")}
|
|
107
|
+
/>
|
|
108
|
+
<Input
|
|
109
|
+
value={form.currency_code}
|
|
110
|
+
onChange={(e) =>
|
|
111
|
+
onFormChange((prev) => ({
|
|
112
|
+
...prev,
|
|
113
|
+
currency_code: e.target.value.toUpperCase(),
|
|
114
|
+
}))
|
|
115
|
+
}
|
|
116
|
+
placeholder={t("printTab.currencyPlaceholder")}
|
|
117
|
+
/>
|
|
118
|
+
<Input
|
|
119
|
+
type="number"
|
|
120
|
+
value={String(form.quantity)}
|
|
121
|
+
onChange={(e) =>
|
|
122
|
+
onFormChange((prev) => ({
|
|
123
|
+
...prev,
|
|
124
|
+
quantity: Number(e.target.value || 1),
|
|
125
|
+
}))
|
|
126
|
+
}
|
|
127
|
+
placeholder={t("printTab.quantityPlaceholder")}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
<div className="px-6 py-4">
|
|
131
|
+
<Button variant="primary" size="small" onClick={onRenderLabels}>
|
|
132
|
+
{t("printTab.renderButton")}
|
|
133
|
+
</Button>
|
|
134
|
+
</div>
|
|
135
|
+
</Container>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const LabelPrintCenterTab = (props: LabelPrintCenterTabProps) => {
|
|
140
|
+
return (
|
|
141
|
+
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
|
142
|
+
<LabelPrintDesignerSection
|
|
143
|
+
form={props.form}
|
|
144
|
+
onFormChange={props.onFormChange}
|
|
145
|
+
templates={props.templates}
|
|
146
|
+
onRenderLabels={props.onRenderLabels}
|
|
147
|
+
/>
|
|
148
|
+
<LabelPrintOutputSection output={props.output} />
|
|
149
|
+
</div>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Container, Heading, StatusBadge, Text, Textarea } from "@medusajs/ui"
|
|
2
|
+
import { useTranslation } from "react-i18next"
|
|
3
|
+
|
|
4
|
+
import type { LabelPrintOutput } from "../../modules/barcode/types"
|
|
5
|
+
|
|
6
|
+
export interface LabelPrintOutputSectionProps {
|
|
7
|
+
output: LabelPrintOutput | null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const LabelPrintOutputSection = ({
|
|
11
|
+
output,
|
|
12
|
+
}: LabelPrintOutputSectionProps) => {
|
|
13
|
+
const { t } = useTranslation()
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Container className="divide-y p-0">
|
|
17
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
18
|
+
<Heading level="h2">{t("printTab.outputTitle")}</Heading>
|
|
19
|
+
{output ? (
|
|
20
|
+
<StatusBadge color="green">
|
|
21
|
+
{t("printTab.labelsReadyBadge", {
|
|
22
|
+
count: output.total_labels,
|
|
23
|
+
name: output.template.name,
|
|
24
|
+
})}
|
|
25
|
+
</StatusBadge>
|
|
26
|
+
) : null}
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
{output ? (
|
|
30
|
+
<div className="flex flex-col gap-4 px-6 py-4">
|
|
31
|
+
<div>
|
|
32
|
+
<Text size="xsmall" weight="plus" className="mb-1">
|
|
33
|
+
{t("printTab.zplHeading")}
|
|
34
|
+
</Text>
|
|
35
|
+
<Textarea
|
|
36
|
+
readOnly
|
|
37
|
+
rows={7}
|
|
38
|
+
value={output.zpl}
|
|
39
|
+
className="font-mono text-xs"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
<div>
|
|
43
|
+
<Text size="xsmall" weight="plus" className="mb-1">
|
|
44
|
+
{t("printTab.htmlHeading")}
|
|
45
|
+
</Text>
|
|
46
|
+
<Textarea
|
|
47
|
+
readOnly
|
|
48
|
+
rows={5}
|
|
49
|
+
value={output.html}
|
|
50
|
+
className="font-mono text-xs"
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
) : (
|
|
55
|
+
<div className="px-6 py-4">
|
|
56
|
+
<Text size="small" className="text-ui-fg-subtle">
|
|
57
|
+
{t("printTab.emptyState")}
|
|
58
|
+
</Text>
|
|
59
|
+
</div>
|
|
60
|
+
)}
|
|
61
|
+
</Container>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Button, clx, Container, Heading, Skeleton, Text } from "@medusajs/ui"
|
|
2
|
+
|
|
3
|
+
export interface StatCardProps {
|
|
4
|
+
title: string
|
|
5
|
+
value: string | number
|
|
6
|
+
icon: React.ReactNode
|
|
7
|
+
loading?: boolean
|
|
8
|
+
onClick?: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const StatCard = ({
|
|
12
|
+
title,
|
|
13
|
+
value,
|
|
14
|
+
icon,
|
|
15
|
+
loading = false,
|
|
16
|
+
onClick,
|
|
17
|
+
}: StatCardProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<Container
|
|
20
|
+
className={clx(
|
|
21
|
+
"p-0",
|
|
22
|
+
onClick
|
|
23
|
+
? "cursor-pointer hover:bg-ui-bg-subtle-hover transition-colors"
|
|
24
|
+
: ""
|
|
25
|
+
)}
|
|
26
|
+
onClick={onClick}
|
|
27
|
+
>
|
|
28
|
+
<div className="p-5">
|
|
29
|
+
<div className="flex items-center justify-between">
|
|
30
|
+
<Text className="text-ui-fg-subtle">{title}</Text>
|
|
31
|
+
<div className="flex items-center justify-center w-8 h-8 rounded-md bg-ui-bg-subtle">
|
|
32
|
+
{icon}
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div className="mt-3">
|
|
36
|
+
{loading ? (
|
|
37
|
+
<Skeleton className="h-8 w-16" />
|
|
38
|
+
) : (
|
|
39
|
+
<Heading level="h2">{value}</Heading>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</Container>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type NavigationCardPosition =
|
|
48
|
+
| "top-left"
|
|
49
|
+
| "top-right"
|
|
50
|
+
| "middle-left"
|
|
51
|
+
| "middle-right"
|
|
52
|
+
| "bottom-left"
|
|
53
|
+
| "bottom-right"
|
|
54
|
+
|
|
55
|
+
export interface NavigationCardProps {
|
|
56
|
+
icon: React.ReactNode
|
|
57
|
+
title: string
|
|
58
|
+
description: string
|
|
59
|
+
onClick: () => void
|
|
60
|
+
position: NavigationCardPosition
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const NavigationCard = ({
|
|
64
|
+
icon,
|
|
65
|
+
title,
|
|
66
|
+
description,
|
|
67
|
+
onClick,
|
|
68
|
+
position,
|
|
69
|
+
}: NavigationCardProps) => {
|
|
70
|
+
const isBottom = position === "bottom-left" || position === "bottom-right"
|
|
71
|
+
const isLeft =
|
|
72
|
+
position === "top-left" ||
|
|
73
|
+
position === "middle-left" ||
|
|
74
|
+
position === "bottom-left"
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Button
|
|
78
|
+
type="button"
|
|
79
|
+
variant="transparent"
|
|
80
|
+
className={clx(
|
|
81
|
+
"h-auto w-full justify-start rounded-none text-left p-6 hover:bg-ui-bg-subtle-hover transition-colors",
|
|
82
|
+
!isBottom ? "border-b border-ui-border-base" : "",
|
|
83
|
+
isLeft ? "md:border-r md:border-ui-border-base" : ""
|
|
84
|
+
)}
|
|
85
|
+
onClick={onClick}
|
|
86
|
+
>
|
|
87
|
+
<div className="flex items-start gap-x-3">
|
|
88
|
+
<div className="flex items-center justify-center w-8 h-8 rounded-md bg-ui-bg-subtle shrink-0">
|
|
89
|
+
{icon}
|
|
90
|
+
</div>
|
|
91
|
+
<div>
|
|
92
|
+
<Heading level="h3">{title}</Heading>
|
|
93
|
+
<Text className="text-ui-fg-subtle mt-1">{description}</Text>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</Button>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Button,
|
|
5
|
+
Container,
|
|
6
|
+
Heading,
|
|
7
|
+
StatusBadge,
|
|
8
|
+
Text,
|
|
9
|
+
Textarea,
|
|
10
|
+
} from "@medusajs/ui"
|
|
11
|
+
import { useTranslation } from "react-i18next"
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BarcodeSymbology,
|
|
15
|
+
LabelPrintOutput,
|
|
16
|
+
} from "../../modules/barcode/types"
|
|
17
|
+
import { BarcodeImage } from "../../ui"
|
|
18
|
+
|
|
19
|
+
export interface ProductBarcodeCardProps {
|
|
20
|
+
productTitle?: string
|
|
21
|
+
tags: Array<Record<string, unknown>>
|
|
22
|
+
linkedBarcodes: Array<Record<string, unknown>>
|
|
23
|
+
printPreview: LabelPrintOutput | null
|
|
24
|
+
isBusy: boolean
|
|
25
|
+
feedback: string | null
|
|
26
|
+
onGenerateBarcodes: () => void
|
|
27
|
+
onQuickPrintLabels: () => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ProductBarcodeCard = ({
|
|
31
|
+
productTitle,
|
|
32
|
+
tags,
|
|
33
|
+
linkedBarcodes,
|
|
34
|
+
printPreview,
|
|
35
|
+
isBusy,
|
|
36
|
+
onGenerateBarcodes,
|
|
37
|
+
onQuickPrintLabels,
|
|
38
|
+
}: ProductBarcodeCardProps) => {
|
|
39
|
+
const { t, i18n } = useTranslation()
|
|
40
|
+
const isRtl = (i18n.resolvedLanguage || i18n.language || "").startsWith("ar")
|
|
41
|
+
const primaryTag = tags[0]
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Container className="divide-y p-0" dir={isRtl ? "rtl" : "ltr"}>
|
|
45
|
+
<div className="flex flex-wrap items-center justify-between gap-3 px-6 py-4">
|
|
46
|
+
<div>
|
|
47
|
+
<Heading level="h2">{t("widget.title")}</Heading>
|
|
48
|
+
<Text size="small" className="text-ui-fg-subtle">
|
|
49
|
+
{t("widget.subtitle", {
|
|
50
|
+
productTitle: productTitle || t("widget.defaultProductTitle"),
|
|
51
|
+
tagsCount: tags.length,
|
|
52
|
+
barcodesCount: linkedBarcodes.length,
|
|
53
|
+
})}
|
|
54
|
+
</Text>
|
|
55
|
+
</div>
|
|
56
|
+
<div className="flex gap-2">
|
|
57
|
+
<Button
|
|
58
|
+
variant="secondary"
|
|
59
|
+
size="small"
|
|
60
|
+
isLoading={isBusy}
|
|
61
|
+
onClick={onGenerateBarcodes}
|
|
62
|
+
>
|
|
63
|
+
{t("widget.generateButton")}
|
|
64
|
+
</Button>
|
|
65
|
+
<Button
|
|
66
|
+
variant="primary"
|
|
67
|
+
size="small"
|
|
68
|
+
isLoading={isBusy}
|
|
69
|
+
onClick={onQuickPrintLabels}
|
|
70
|
+
>
|
|
71
|
+
{t("widget.printButton")}
|
|
72
|
+
</Button>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
{primaryTag ? (
|
|
77
|
+
<>
|
|
78
|
+
<SectionRow
|
|
79
|
+
title={t("widget.codeLabel")}
|
|
80
|
+
value={
|
|
81
|
+
<Badge size="xsmall" color="grey">
|
|
82
|
+
{String(primaryTag.code)}
|
|
83
|
+
</Badge>
|
|
84
|
+
}
|
|
85
|
+
/>
|
|
86
|
+
<SectionRow
|
|
87
|
+
title={t("widget.actionLabel")}
|
|
88
|
+
value={
|
|
89
|
+
<StatusBadge color="green">
|
|
90
|
+
{String(primaryTag.scan_action)}
|
|
91
|
+
</StatusBadge>
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
<SectionRow
|
|
95
|
+
title={t("widget.scansLabel")}
|
|
96
|
+
value={String(primaryTag.scan_count ?? 0)}
|
|
97
|
+
/>
|
|
98
|
+
<div className="px-6 py-4">
|
|
99
|
+
<BarcodeImage
|
|
100
|
+
code={String(primaryTag.code)}
|
|
101
|
+
symbology={(primaryTag.symbology as BarcodeSymbology) || "ean13"}
|
|
102
|
+
svgMarkup={
|
|
103
|
+
typeof primaryTag.svg_markup === "string"
|
|
104
|
+
? primaryTag.svg_markup
|
|
105
|
+
: undefined
|
|
106
|
+
}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</>
|
|
110
|
+
) : null}
|
|
111
|
+
|
|
112
|
+
{printPreview ? (
|
|
113
|
+
<div className="px-6 py-4">
|
|
114
|
+
<Text size="xsmall" weight="plus" className="mb-1">
|
|
115
|
+
{t("widget.zplOutputLabel", { name: printPreview.template.name })}
|
|
116
|
+
</Text>
|
|
117
|
+
<Textarea
|
|
118
|
+
readOnly
|
|
119
|
+
rows={4}
|
|
120
|
+
value={printPreview.zpl}
|
|
121
|
+
className="font-mono text-xs"
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
) : null}
|
|
125
|
+
</Container>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Button, Container, Heading, StatusBadge, Table } from "@medusajs/ui"
|
|
2
|
+
import { useTranslation } from "react-i18next"
|
|
3
|
+
|
|
4
|
+
export interface ProvidersCacheSectionProps {
|
|
5
|
+
cacheEntries: Array<Record<string, unknown>>
|
|
6
|
+
onPurgeExpired: () => void
|
|
7
|
+
onClearAllCache: () => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ProvidersCacheSection = ({
|
|
11
|
+
cacheEntries,
|
|
12
|
+
onPurgeExpired,
|
|
13
|
+
onClearAllCache,
|
|
14
|
+
}: ProvidersCacheSectionProps) => {
|
|
15
|
+
const { t } = useTranslation()
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Container className="divide-y p-0">
|
|
19
|
+
<div className="flex flex-wrap items-center justify-between gap-2 px-6 py-4">
|
|
20
|
+
<Heading level="h2">
|
|
21
|
+
{t("providersTab.cacheTitle", { count: cacheEntries.length })}
|
|
22
|
+
</Heading>
|
|
23
|
+
<div className="flex gap-2">
|
|
24
|
+
<Button variant="secondary" size="small" onClick={onPurgeExpired}>
|
|
25
|
+
{t("providersTab.purgeExpiredButton")}
|
|
26
|
+
</Button>
|
|
27
|
+
<Button variant="secondary" size="small" onClick={onClearAllCache}>
|
|
28
|
+
{t("providersTab.clearAllButton")}
|
|
29
|
+
</Button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<Table>
|
|
34
|
+
<Table.Header>
|
|
35
|
+
<Table.Row>
|
|
36
|
+
<Table.HeaderCell>Barcode</Table.HeaderCell>
|
|
37
|
+
<Table.HeaderCell>Provider</Table.HeaderCell>
|
|
38
|
+
<Table.HeaderCell>Hits</Table.HeaderCell>
|
|
39
|
+
</Table.Row>
|
|
40
|
+
</Table.Header>
|
|
41
|
+
<Table.Body>
|
|
42
|
+
{cacheEntries.map((entry) => (
|
|
43
|
+
<Table.Row key={String(entry.id)}>
|
|
44
|
+
<Table.Cell className="font-mono font-bold">
|
|
45
|
+
{String(entry.barcode)}
|
|
46
|
+
</Table.Cell>
|
|
47
|
+
<Table.Cell>{String(entry.provider)}</Table.Cell>
|
|
48
|
+
<Table.Cell>
|
|
49
|
+
<StatusBadge color={entry.found ? "green" : "orange"}>
|
|
50
|
+
{t("providersTab.hitsBadge", {
|
|
51
|
+
count: String(entry.hit_count ?? 1),
|
|
52
|
+
})}
|
|
53
|
+
</StatusBadge>
|
|
54
|
+
</Table.Cell>
|
|
55
|
+
</Table.Row>
|
|
56
|
+
))}
|
|
57
|
+
</Table.Body>
|
|
58
|
+
</Table>
|
|
59
|
+
</Container>
|
|
60
|
+
)
|
|
61
|
+
}
|