@vicacha-devs/medusa-plugin-barcode 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.medusa/server/src/admin/index.cjs +3960 -0
  2. package/.medusa/server/src/admin/index.js +3938 -0
  3. package/.medusa/server/src/api/admin/barcodes/[barcode]/route.js +43 -0
  4. package/.medusa/server/src/api/admin/barcodes/batch/route.js +9 -0
  5. package/.medusa/server/src/api/admin/barcodes/bulk-generate/route.js +9 -0
  6. package/.medusa/server/src/api/admin/barcodes/cache/route.js +25 -0
  7. package/.medusa/server/src/api/admin/barcodes/count-sessions/[id]/apply/route.js +13 -0
  8. package/.medusa/server/src/api/admin/barcodes/count-sessions/[id]/scan/route.js +13 -0
  9. package/.medusa/server/src/api/admin/barcodes/count-sessions/route.js +27 -0
  10. package/.medusa/server/src/api/admin/barcodes/create-from-barcode/route.js +9 -0
  11. package/.medusa/server/src/api/admin/barcodes/lookup/route.js +12 -0
  12. package/.medusa/server/src/api/admin/barcodes/print/route.js +11 -0
  13. package/.medusa/server/src/api/admin/barcodes/route.js +27 -0
  14. package/.medusa/server/src/api/admin/barcodes/scan/route.js +23 -0
  15. package/.medusa/server/src/api/admin/barcodes/tags/[id]/route.js +28 -0
  16. package/.medusa/server/src/api/admin/barcodes/tags/route.js +25 -0
  17. package/.medusa/server/src/api/admin/barcodes/templates/route.js +40 -0
  18. package/.medusa/server/src/api/admin/plugin/route.js +4 -0
  19. package/.medusa/server/src/api/admin/variants/barcode/[code]/route.js +28 -0
  20. package/.medusa/server/src/api/middlewares.js +73 -0
  21. package/.medusa/server/src/api/store/barcodes/[code]/route.js +28 -0
  22. package/.medusa/server/src/api/store/barcodes/[code]/verify/route.js +20 -0
  23. package/.medusa/server/src/api/store/plugin/route.js +4 -0
  24. package/.medusa/server/src/api/store/variants/barcode/[code]/route.js +28 -0
  25. package/.medusa/server/src/api/validators.js +173 -0
  26. package/.medusa/server/src/hooks/index.js +202 -0
  27. package/.medusa/server/src/index.js +5 -0
  28. package/.medusa/server/src/jobs/purge-expired-barcode-cache.js +10 -0
  29. package/.medusa/server/src/modules/barcode/index.js +16 -0
  30. package/.medusa/server/src/modules/barcode/migrations/Migration20260522000000.js +165 -0
  31. package/.medusa/server/src/modules/barcode/models/index.js +162 -0
  32. package/.medusa/server/src/modules/barcode/operations/context.js +2 -0
  33. package/.medusa/server/src/modules/barcode/operations/data-service.js +10 -0
  34. package/.medusa/server/src/modules/barcode/operations/generation.js +33 -0
  35. package/.medusa/server/src/modules/barcode/operations/index.js +9 -0
  36. package/.medusa/server/src/modules/barcode/operations/labels.js +57 -0
  37. package/.medusa/server/src/modules/barcode/operations/lookup.js +135 -0
  38. package/.medusa/server/src/modules/barcode/operations/maintenance.js +37 -0
  39. package/.medusa/server/src/modules/barcode/operations/stock-count.js +129 -0
  40. package/.medusa/server/src/modules/barcode/operations/tags.js +298 -0
  41. package/.medusa/server/src/modules/barcode/providers/index.js +721 -0
  42. package/.medusa/server/src/modules/barcode/service.js +161 -0
  43. package/.medusa/server/src/modules/barcode/types.js +21 -0
  44. package/.medusa/server/src/modules/barcode/utils/barcode-parser.js +399 -0
  45. package/.medusa/server/src/modules/barcode/utils/label-printer.js +533 -0
  46. package/.medusa/server/src/modules/barcode/utils/normalize-product.js +443 -0
  47. package/.medusa/server/src/modules/barcode/utils/security.js +114 -0
  48. package/.medusa/server/src/modules/barcode/utils/svg-renderer.js +492 -0
  49. package/.medusa/server/src/rbac.js +130 -0
  50. package/.medusa/server/src/sdk/index.js +164 -0
  51. package/.medusa/server/src/subscribers/product-created.js +34 -0
  52. package/.medusa/server/src/types/index.js +2 -0
  53. package/.medusa/server/src/ui/index.js +138 -0
  54. package/.medusa/server/src/workflows/apply-inventory-count.js +68 -0
  55. package/.medusa/server/src/workflows/batch-barcode-import.js +153 -0
  56. package/.medusa/server/src/workflows/bulk-generate-variant-barcodes.js +143 -0
  57. package/.medusa/server/src/workflows/generate-barcode-tag.js +44 -0
  58. package/.medusa/server/src/workflows/helpers.js +15 -0
  59. package/.medusa/server/src/workflows/index.js +7 -0
  60. package/.medusa/server/src/workflows/lookup-and-create-product.js +215 -0
  61. package/.medusa/server/src/workflows/scan-inventory-count.js +15 -0
  62. package/LICENSE +21 -0
  63. package/README.md +844 -2
  64. package/package.json +134 -3
  65. package/src/__tests__/barcode.spec.ts +836 -0
  66. package/src/__tests__/medusa-shim.mjs +331 -0
  67. package/src/__tests__/register-ts-resolver.mjs +135 -0
  68. package/src/admin/README.md +134 -0
  69. package/src/admin/components/barcode-studio-header.tsx +73 -0
  70. package/src/admin/components/batch-import-section.tsx +99 -0
  71. package/src/admin/components/dynamic-qr-tag-drawer-form.tsx +230 -0
  72. package/src/admin/components/dynamic-qr-tag-form.tsx +129 -0
  73. package/src/admin/components/dynamic-qr-tags-table.tsx +136 -0
  74. package/src/admin/components/gtin-lookup-section.tsx +155 -0
  75. package/src/admin/components/index.tsx +14 -0
  76. package/src/admin/components/label-designer-section.tsx +151 -0
  77. package/src/admin/components/label-output-section.tsx +63 -0
  78. package/src/admin/components/overview-cards.tsx +98 -0
  79. package/src/admin/components/product-barcode-card.tsx +127 -0
  80. package/src/admin/components/providers-cache-table.tsx +61 -0
  81. package/src/admin/components/providers-overview-section.tsx +49 -0
  82. package/src/admin/components/rbac-guard.tsx +153 -0
  83. package/src/admin/components/stock-take-scanner-section.tsx +116 -0
  84. package/src/admin/components/stock-take-sessions-section.tsx +109 -0
  85. package/src/admin/hooks/use-barcode-studio.ts +466 -0
  86. package/src/admin/hooks/use-product-barcodes.ts +139 -0
  87. package/src/admin/i18n/README.md +130 -0
  88. package/src/admin/i18n/index.ts +36 -0
  89. package/src/admin/i18n/json/ar.json +157 -0
  90. package/src/admin/i18n/json/de.json +157 -0
  91. package/src/admin/i18n/json/en.json +157 -0
  92. package/src/admin/i18n/json/es.json +157 -0
  93. package/src/admin/i18n/json/fr.json +157 -0
  94. package/src/admin/i18n/json/it.json +157 -0
  95. package/src/admin/i18n/json/nl.json +157 -0
  96. package/src/admin/i18n/json/pl.json +157 -0
  97. package/src/admin/i18n/json/pt.json +157 -0
  98. package/src/admin/i18n/json/tr.json +157 -0
  99. package/src/admin/routes/barcodes/lookup/page.tsx +75 -0
  100. package/src/admin/routes/barcodes/page.tsx +212 -0
  101. package/src/admin/routes/barcodes/print/page.tsx +67 -0
  102. package/src/admin/routes/barcodes/providers/page.tsx +66 -0
  103. package/src/admin/routes/barcodes/stock-take/page.tsx +74 -0
  104. package/src/admin/routes/barcodes/tags/@create/page.tsx +56 -0
  105. package/src/admin/routes/barcodes/tags/page.tsx +72 -0
  106. package/src/admin/tsconfig.json +20 -0
  107. package/src/admin/vite-env.d.ts +1 -0
  108. package/src/admin/widgets/product-barcode-widget.tsx +43 -0
  109. package/src/api/README.md +117 -0
  110. package/src/api/admin/barcodes/[barcode]/route.ts +64 -0
  111. package/src/api/admin/barcodes/batch/route.ts +12 -0
  112. package/src/api/admin/barcodes/bulk-generate/route.ts +12 -0
  113. package/src/api/admin/barcodes/cache/route.ts +35 -0
  114. package/src/api/admin/barcodes/count-sessions/[id]/apply/route.ts +17 -0
  115. package/src/api/admin/barcodes/count-sessions/[id]/scan/route.ts +17 -0
  116. package/src/api/admin/barcodes/count-sessions/route.ts +43 -0
  117. package/src/api/admin/barcodes/create-from-barcode/route.ts +16 -0
  118. package/src/api/admin/barcodes/lookup/route.ts +19 -0
  119. package/src/api/admin/barcodes/print/route.ts +18 -0
  120. package/src/api/admin/barcodes/route.ts +36 -0
  121. package/src/api/admin/barcodes/scan/route.ts +32 -0
  122. package/src/api/admin/barcodes/tags/[id]/route.ts +41 -0
  123. package/src/api/admin/barcodes/tags/route.ts +36 -0
  124. package/src/api/admin/barcodes/templates/route.ts +51 -0
  125. package/src/api/admin/plugin/route.ts +5 -0
  126. package/src/api/admin/variants/barcode/[code]/route.ts +36 -0
  127. package/src/api/middlewares.ts +91 -0
  128. package/src/api/store/barcodes/[code]/route.ts +43 -0
  129. package/src/api/store/barcodes/[code]/verify/route.ts +35 -0
  130. package/src/api/store/plugin/route.ts +5 -0
  131. package/src/api/store/variants/barcode/[code]/route.ts +36 -0
  132. package/src/api/validators.ts +217 -0
  133. package/src/hooks/index.ts +270 -0
  134. package/src/index.ts +4 -0
  135. package/src/jobs/README.md +54 -0
  136. package/src/jobs/purge-expired-barcode-cache.ts +18 -0
  137. package/src/links/README.md +44 -0
  138. package/src/modules/README.md +85 -0
  139. package/src/modules/barcode/index.ts +18 -0
  140. package/src/modules/barcode/migrations/Migration20260522000000.ts +225 -0
  141. package/src/modules/barcode/models/index.ts +168 -0
  142. package/src/modules/barcode/operations/context.ts +14 -0
  143. package/src/modules/barcode/operations/data-service.ts +10 -0
  144. package/src/modules/barcode/operations/generation.ts +57 -0
  145. package/src/modules/barcode/operations/index.ts +8 -0
  146. package/src/modules/barcode/operations/labels.ts +90 -0
  147. package/src/modules/barcode/operations/lookup.ts +202 -0
  148. package/src/modules/barcode/operations/maintenance.ts +53 -0
  149. package/src/modules/barcode/operations/stock-count.ts +217 -0
  150. package/src/modules/barcode/operations/tags.ts +425 -0
  151. package/src/modules/barcode/providers/index.ts +958 -0
  152. package/src/modules/barcode/service.ts +243 -0
  153. package/src/modules/barcode/types.ts +297 -0
  154. package/src/modules/barcode/utils/barcode-parser.ts +453 -0
  155. package/src/modules/barcode/utils/label-printer.ts +641 -0
  156. package/src/modules/barcode/utils/normalize-product.ts +524 -0
  157. package/src/modules/barcode/utils/security.ts +136 -0
  158. package/src/modules/barcode/utils/svg-renderer.ts +574 -0
  159. package/src/providers/README.md +105 -0
  160. package/src/rbac.ts +144 -0
  161. package/src/sdk/index.ts +253 -0
  162. package/src/subscribers/README.md +73 -0
  163. package/src/subscribers/product-created.ts +45 -0
  164. package/src/types/index.ts +1 -0
  165. package/src/types/medusa-ui.d.ts +118 -0
  166. package/src/ui/index.tsx +311 -0
  167. package/src/workflows/README.md +56 -0
  168. package/src/workflows/apply-inventory-count.ts +115 -0
  169. package/src/workflows/batch-barcode-import.ts +218 -0
  170. package/src/workflows/bulk-generate-variant-barcodes.ts +214 -0
  171. package/src/workflows/generate-barcode-tag.ts +85 -0
  172. package/src/workflows/helpers.ts +21 -0
  173. package/src/workflows/index.ts +6 -0
  174. package/src/workflows/lookup-and-create-product.ts +298 -0
  175. package/src/workflows/scan-inventory-count.ts +45 -0
  176. package/tsconfig.json +40 -0
@@ -0,0 +1,212 @@
1
+ import { defineRouteConfig } from "@medusajs/admin-sdk"
2
+ import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
3
+ import { LayoutComposer } from "@medusajs/dashboard/components"
4
+ import {
5
+ Buildings,
6
+ BuildingStorefront,
7
+ CheckCircle,
8
+ DocumentText,
9
+ MagnifyingGlass,
10
+ Tag,
11
+ } from "@medusajs/icons"
12
+ import {
13
+ Badge,
14
+ Button,
15
+ Container,
16
+ Heading,
17
+ StatusBadge,
18
+ Text,
19
+ } from "@medusajs/ui"
20
+ import { useTranslation } from "react-i18next"
21
+ import { useNavigate } from "react-router-dom"
22
+
23
+ import { NavigationCard, StatCard } from "../../components"
24
+ import { useBarcodeStudio } from "../../hooks/use-barcode-studio"
25
+ import { RbacGuard } from "../../components/rbac-guard"
26
+
27
+ const BarcodesOverviewPage = () => {
28
+ const { t, i18n } = useTranslation()
29
+ const navigate = useNavigate()
30
+ const studio = useBarcodeStudio()
31
+
32
+ const isRtl = (i18n.resolvedLanguage || i18n.language || "").startsWith("ar")
33
+ const providers = Array.isArray(studio.overview.active_providers)
34
+ ? (studio.overview.active_providers as string[])
35
+ : []
36
+
37
+ return (
38
+ <LayoutComposer
39
+ widgetsZonePrefix="barcodes.overview"
40
+ preferredLayoutId={CORE_LAYOUT_IDS.SINGLE_COLUMN}
41
+ sections={{
42
+ main: (
43
+ <LayoutComposer.Entry id="BarcodesOverviewMain">
44
+ <div className="flex flex-col gap-y-4" dir={isRtl ? "rtl" : "ltr"}>
45
+ <div className="flex flex-wrap items-center justify-between gap-4">
46
+ <div>
47
+ <div className="flex flex-wrap items-center gap-2">
48
+ <Heading className="font-sans font-medium h1-core">
49
+ {t("header.title")}
50
+ </Heading>
51
+ <StatusBadge color="green">
52
+ {t("header.providersBadge")}
53
+ </StatusBadge>
54
+ {studio.lastScanned ? (
55
+ <Badge color="blue">
56
+ {t("header.lastHidScan", {
57
+ code: studio.lastScanned,
58
+ })}
59
+ </Badge>
60
+ ) : null}
61
+ </div>
62
+ <Text className="text-ui-fg-subtle mt-1">
63
+ {t("header.subtitle")}
64
+ </Text>
65
+ </div>
66
+
67
+ <div className="flex items-center gap-2">
68
+ <Button
69
+ variant="secondary"
70
+ size="small"
71
+ onClick={() => void studio.handleBulkGenerateBarcodes()}
72
+ >
73
+ {t("header.bulkGenerateButton")}
74
+ </Button>
75
+ <Button
76
+ variant="secondary"
77
+ size="small"
78
+ onClick={studio.onRefresh}
79
+ >
80
+ {t("header.refreshButton")}
81
+ </Button>
82
+ </div>
83
+ </div>
84
+
85
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-5">
86
+ <StatCard
87
+ title={t("header.linkedProductsStat")}
88
+ value={Number(studio.overview.total_barcode_products ?? 0)}
89
+ icon={<MagnifyingGlass />}
90
+ loading={studio.isLoading}
91
+ onClick={() => navigate("/barcodes/lookup")}
92
+ />
93
+
94
+ <StatCard
95
+ title={t("header.dynamicTagsStat")}
96
+ value={Number(studio.overview.total_barcode_tags ?? 0)}
97
+ icon={<Tag />}
98
+ loading={studio.isLoading}
99
+ onClick={() => navigate("/barcodes/tags")}
100
+ />
101
+
102
+ <StatCard
103
+ title={t("header.totalScansStat")}
104
+ value={Number(studio.overview.total_tag_scans ?? 0)}
105
+ icon={<CheckCircle />}
106
+ loading={studio.isLoading}
107
+ onClick={() => navigate("/barcodes/tags")}
108
+ />
109
+
110
+ <StatCard
111
+ title={t("header.cachedLookupsStat")}
112
+ value={`${String(studio.overview.total_cached_lookups ?? 0)} (${String(studio.overview.total_cache_hits ?? 0)})`}
113
+ icon={<DocumentText />}
114
+ loading={studio.isLoading}
115
+ onClick={() => navigate("/barcodes/providers")}
116
+ />
117
+
118
+ <StatCard
119
+ title={t("header.activeProvidersStat")}
120
+ value={providers.length}
121
+ icon={<BuildingStorefront />}
122
+ loading={studio.isLoading}
123
+ onClick={() => navigate("/barcodes/providers")}
124
+ />
125
+ </div>
126
+
127
+ <Container className="p-0 overflow-hidden">
128
+ <div className="px-6 py-5 border-b border-ui-border-base">
129
+ <Heading level="h2">{t("nav.label")}</Heading>
130
+ <Text className="text-ui-fg-subtle mt-1">
131
+ {t("header.subtitle")}
132
+ </Text>
133
+ </div>
134
+
135
+ <div className="grid grid-cols-1 md:grid-cols-2">
136
+ <NavigationCard
137
+ icon={<MagnifyingGlass />}
138
+ title={t("tabs.lookup", {
139
+ count: studio.barcodes.length,
140
+ })}
141
+ description={t("lookupTab.lookupSubtitle")}
142
+ onClick={() => navigate("/barcodes/lookup")}
143
+ position="top-left"
144
+ />
145
+
146
+ <NavigationCard
147
+ icon={<Tag />}
148
+ title={t("tabs.tags", { count: studio.tags.length })}
149
+ description={t("tagsTab.createTitle")}
150
+ onClick={() => navigate("/barcodes/tags")}
151
+ position="top-right"
152
+ />
153
+
154
+ <NavigationCard
155
+ icon={<DocumentText />}
156
+ title={t("tabs.print")}
157
+ description={t("printTab.designerTitle")}
158
+ onClick={() => navigate("/barcodes/print")}
159
+ position="middle-left"
160
+ />
161
+
162
+ <NavigationCard
163
+ icon={<Buildings />}
164
+ title={t("tabs.stockTake", {
165
+ count: studio.sessions.length,
166
+ })}
167
+ description={t("stockTakeTab.createTitle")}
168
+ onClick={() => navigate("/barcodes/stock-take")}
169
+ position="middle-right"
170
+ />
171
+
172
+ <NavigationCard
173
+ icon={<CheckCircle />}
174
+ title={t("tabs.providers", {
175
+ count: studio.cacheEntries.length,
176
+ })}
177
+ description={t("providersTab.providersTitle")}
178
+ onClick={() => navigate("/barcodes/providers")}
179
+ position="bottom-left"
180
+ />
181
+ </div>
182
+ </Container>
183
+ </div>
184
+ </LayoutComposer.Entry>
185
+ ),
186
+ }}
187
+ />
188
+ )
189
+ }
190
+
191
+ const Breadcrumb = () => {
192
+ const { t } = useTranslation()
193
+ return t("nav.label")
194
+ }
195
+
196
+ export const config = defineRouteConfig({
197
+ label: "nav.label",
198
+ translationNs: "barcodes",
199
+ icon: Tag,
200
+ })
201
+
202
+ export const handle = {
203
+ breadcrumb: () => <Breadcrumb />,
204
+ }
205
+
206
+ const GuardedBarcodesOverviewPage = () => (
207
+ <RbacGuard permission="barcodes.read">
208
+ <BarcodesOverviewPage />
209
+ </RbacGuard>
210
+ )
211
+
212
+ export default GuardedBarcodesOverviewPage
@@ -0,0 +1,67 @@
1
+ import { defineRouteConfig } from "@medusajs/admin-sdk"
2
+ import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
3
+ import { LayoutComposer } from "@medusajs/dashboard/components"
4
+ import { DocumentText } from "@medusajs/icons"
5
+ import { Toaster } from "@medusajs/ui"
6
+ import { useTranslation } from "react-i18next"
7
+
8
+ import {
9
+ LabelPrintDesignerSection,
10
+ LabelPrintOutputSection,
11
+ } from "../../../components"
12
+ import { useBarcodeStudio } from "../../../hooks/use-barcode-studio"
13
+ import { RbacGuard } from "../../../components/rbac-guard"
14
+
15
+ const BarcodePrintCenterPage = () => {
16
+ const studio = useBarcodeStudio()
17
+
18
+ return (
19
+ <>
20
+ <Toaster />
21
+ <LayoutComposer
22
+ widgetsZonePrefix="barcodes.print.details"
23
+ preferredLayoutId={CORE_LAYOUT_IDS.TWO_COLUMN}
24
+ sections={{
25
+ main: (
26
+ <LayoutComposer.Entry id="BarcodePrintDesignerSection">
27
+ <LabelPrintDesignerSection
28
+ form={studio.printForm}
29
+ onFormChange={studio.setPrintForm}
30
+ templates={studio.templates}
31
+ onRenderLabels={() => void studio.handleRenderLabels()}
32
+ />
33
+ </LayoutComposer.Entry>
34
+ ),
35
+ side: (
36
+ <LayoutComposer.Entry id="BarcodePrintOutputSection">
37
+ <LabelPrintOutputSection output={studio.printOutput} />
38
+ </LayoutComposer.Entry>
39
+ ),
40
+ }}
41
+ />
42
+ </>
43
+ )
44
+ }
45
+
46
+ const Breadcrumb = () => {
47
+ const { t } = useTranslation()
48
+ return t("tabs.print")
49
+ }
50
+
51
+ export const config = defineRouteConfig({
52
+ label: "tabs.print",
53
+ translationNs: "barcodes",
54
+ icon: DocumentText,
55
+ })
56
+
57
+ export const handle = {
58
+ breadcrumb: () => <Breadcrumb />,
59
+ }
60
+
61
+ const GuardedBarcodePrintCenterPage = () => (
62
+ <RbacGuard permission="barcodes.read">
63
+ <BarcodePrintCenterPage />
64
+ </RbacGuard>
65
+ )
66
+
67
+ export default GuardedBarcodePrintCenterPage
@@ -0,0 +1,66 @@
1
+ import { defineRouteConfig } from "@medusajs/admin-sdk"
2
+ import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
3
+ import { LayoutComposer } from "@medusajs/dashboard/components"
4
+ import { CheckCircle } from "@medusajs/icons"
5
+ import { Toaster } from "@medusajs/ui"
6
+ import { useTranslation } from "react-i18next"
7
+
8
+ import {
9
+ ProvidersCacheSection,
10
+ ProvidersRegistrySection,
11
+ } from "../../../components"
12
+ import { useBarcodeStudio } from "../../../hooks/use-barcode-studio"
13
+ import { RbacGuard } from "../../../components/rbac-guard"
14
+
15
+ const BarcodeProvidersPage = () => {
16
+ const studio = useBarcodeStudio()
17
+
18
+ return (
19
+ <>
20
+ <Toaster />
21
+ <LayoutComposer
22
+ widgetsZonePrefix="barcodes.providers.details"
23
+ preferredLayoutId={CORE_LAYOUT_IDS.TWO_COLUMN}
24
+ sections={{
25
+ main: (
26
+ <LayoutComposer.Entry id="BarcodeProvidersCacheSection">
27
+ <ProvidersCacheSection
28
+ cacheEntries={studio.cacheEntries}
29
+ onPurgeExpired={() => void studio.handlePurgeCache(false)}
30
+ onClearAllCache={() => void studio.handlePurgeCache(true)}
31
+ />
32
+ </LayoutComposer.Entry>
33
+ ),
34
+ side: (
35
+ <LayoutComposer.Entry id="BarcodeProvidersRegistrySection">
36
+ <ProvidersRegistrySection overview={studio.overview} />
37
+ </LayoutComposer.Entry>
38
+ ),
39
+ }}
40
+ />
41
+ </>
42
+ )
43
+ }
44
+
45
+ const Breadcrumb = () => {
46
+ const { t } = useTranslation()
47
+ return t("providersTab.providersTitle")
48
+ }
49
+
50
+ export const config = defineRouteConfig({
51
+ label: "providersTab.providersTitle",
52
+ translationNs: "barcodes",
53
+ icon: CheckCircle,
54
+ })
55
+
56
+ export const handle = {
57
+ breadcrumb: () => <Breadcrumb />,
58
+ }
59
+
60
+ const GuardedBarcodeProvidersPage = () => (
61
+ <RbacGuard permission="barcodes.read">
62
+ <BarcodeProvidersPage />
63
+ </RbacGuard>
64
+ )
65
+
66
+ export default GuardedBarcodeProvidersPage
@@ -0,0 +1,74 @@
1
+ import { defineRouteConfig } from "@medusajs/admin-sdk"
2
+ import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
3
+ import { LayoutComposer } from "@medusajs/dashboard/components"
4
+ import { Buildings } from "@medusajs/icons"
5
+ import { Toaster } from "@medusajs/ui"
6
+ import { useTranslation } from "react-i18next"
7
+
8
+ import {
9
+ StockTakeControlsSection,
10
+ StockTakeSessionsSection,
11
+ } from "../../../components"
12
+ import { useBarcodeStudio } from "../../../hooks/use-barcode-studio"
13
+ import { RbacGuard } from "../../../components/rbac-guard"
14
+
15
+ const BarcodeStockTakePage = () => {
16
+ const studio = useBarcodeStudio()
17
+
18
+ return (
19
+ <>
20
+ <Toaster />
21
+ <LayoutComposer
22
+ widgetsZonePrefix="barcodes.stock_take.details"
23
+ preferredLayoutId={CORE_LAYOUT_IDS.TWO_COLUMN}
24
+ sections={{
25
+ main: (
26
+ <LayoutComposer.Entry id="StockTakeControlsSection">
27
+ <StockTakeControlsSection
28
+ form={studio.countForm}
29
+ onFormChange={studio.setCountForm}
30
+ onCreateSession={() => void studio.handleCreateCountSession()}
31
+ onScanDelta={(delta) =>
32
+ void studio.handleScanIntoSession(delta)
33
+ }
34
+ />
35
+ </LayoutComposer.Entry>
36
+ ),
37
+ side: (
38
+ <LayoutComposer.Entry id="StockTakeSessionsSection">
39
+ <StockTakeSessionsSection
40
+ sessions={studio.sessions}
41
+ selectedSessionId={studio.selectedSessionId}
42
+ onSelectSession={studio.setSelectedSessionId}
43
+ onApplySession={(id) => void studio.handleApplyCountSession(id)}
44
+ />
45
+ </LayoutComposer.Entry>
46
+ ),
47
+ }}
48
+ />
49
+ </>
50
+ )
51
+ }
52
+
53
+ const Breadcrumb = () => {
54
+ const { t } = useTranslation()
55
+ return t("stockTakeTab.createTitle")
56
+ }
57
+
58
+ export const config = defineRouteConfig({
59
+ label: "stockTakeTab.createTitle",
60
+ translationNs: "barcodes",
61
+ icon: Buildings,
62
+ })
63
+
64
+ export const handle = {
65
+ breadcrumb: () => <Breadcrumb />,
66
+ }
67
+
68
+ const GuardedBarcodeStockTakePage = () => (
69
+ <RbacGuard permission="barcodes.read">
70
+ <BarcodeStockTakePage />
71
+ </RbacGuard>
72
+ )
73
+
74
+ export default GuardedBarcodeStockTakePage
@@ -0,0 +1,56 @@
1
+ import { RouteDrawer, useRouteModal } from "@medusajs/dashboard/components"
2
+ import { Heading, toast } from "@medusajs/ui"
3
+ import { useTranslation } from "react-i18next"
4
+
5
+ import { DynamicQrTagDrawerForm } from "../../../../components"
6
+ import {
7
+ type TagFormState,
8
+ useBarcodeStudio,
9
+ } from "../../../../hooks/use-barcode-studio"
10
+ import { RbacGuard } from "../../../../components/rbac-guard"
11
+
12
+ const CreateTagDrawerContent = () => {
13
+ const { t } = useTranslation()
14
+ const { handleSuccess } = useRouteModal()
15
+ const studio = useBarcodeStudio()
16
+
17
+ const handleSubmit = async (values: TagFormState) => {
18
+ try {
19
+ await studio.handleCreateTag(values)
20
+ handleSuccess()
21
+ } catch (err) {
22
+ toast.error(
23
+ err instanceof Error ? err.message : t("messages.tagCreateError")
24
+ )
25
+ }
26
+ }
27
+
28
+ return (
29
+ <DynamicQrTagDrawerForm
30
+ defaultValues={studio.tagForm}
31
+ loading={studio.isLoading}
32
+ onSubmit={handleSubmit}
33
+ />
34
+ )
35
+ }
36
+
37
+ const BarcodeTagCreateModal = () => {
38
+ const { t } = useTranslation()
39
+
40
+ return (
41
+ <RouteDrawer>
42
+ <RouteDrawer.Header>
43
+ <Heading>{t("tagsTab.createTitle")}</Heading>
44
+ </RouteDrawer.Header>
45
+ <CreateTagDrawerContent />
46
+ </RouteDrawer>
47
+ )
48
+ }
49
+
50
+ const GuardedBarcodeTagCreateModal = () => (
51
+ <RbacGuard permission="barcodes.write">
52
+ <BarcodeTagCreateModal />
53
+ </RbacGuard>
54
+ )
55
+
56
+ export default GuardedBarcodeTagCreateModal
@@ -0,0 +1,72 @@
1
+ import { defineRouteConfig } from "@medusajs/admin-sdk"
2
+ import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
3
+ import { LayoutComposer } from "@medusajs/dashboard/components"
4
+ import { Tag } from "@medusajs/icons"
5
+ import { Toaster } from "@medusajs/ui"
6
+ import { useTranslation } from "react-i18next"
7
+ import { useNavigate } from "react-router-dom"
8
+
9
+ import {
10
+ DynamicQrTagCreateSection,
11
+ DynamicQrTagsTableSection,
12
+ } from "../../../components"
13
+ import { useBarcodeStudio } from "../../../hooks/use-barcode-studio"
14
+ import { RbacGuard } from "../../../components/rbac-guard"
15
+
16
+ const BarcodeTagsPage = () => {
17
+ const navigate = useNavigate()
18
+ const studio = useBarcodeStudio()
19
+
20
+ return (
21
+ <>
22
+ <Toaster />
23
+ <LayoutComposer
24
+ widgetsZonePrefix="barcodes.tags.list"
25
+ preferredLayoutId={CORE_LAYOUT_IDS.TWO_COLUMN}
26
+ sections={{
27
+ main: (
28
+ <LayoutComposer.Entry id="BarcodeTagsTableSection">
29
+ <DynamicQrTagsTableSection
30
+ tags={studio.tags}
31
+ onDeleteTag={(id) => void studio.handleDeleteTag(id)}
32
+ onOpenCreateDrawer={() => navigate("create")}
33
+ />
34
+ </LayoutComposer.Entry>
35
+ ),
36
+ side: (
37
+ <LayoutComposer.Entry id="BarcodeTagCreateSection">
38
+ <DynamicQrTagCreateSection
39
+ form={studio.tagForm}
40
+ onFormChange={studio.setTagForm}
41
+ onCreateTag={() => void studio.handleCreateTag()}
42
+ />
43
+ </LayoutComposer.Entry>
44
+ ),
45
+ }}
46
+ />
47
+ </>
48
+ )
49
+ }
50
+
51
+ const Breadcrumb = () => {
52
+ const { t } = useTranslation()
53
+ return t("tagsTab.createTitle")
54
+ }
55
+
56
+ export const config = defineRouteConfig({
57
+ label: "tagsTab.createTitle",
58
+ translationNs: "barcodes",
59
+ icon: Tag,
60
+ })
61
+
62
+ export const handle = {
63
+ breadcrumb: () => <Breadcrumb />,
64
+ }
65
+
66
+ const GuardedBarcodeTagsPage = () => (
67
+ <RbacGuard permission="barcodes.read">
68
+ <BarcodeTagsPage />
69
+ </RbacGuard>
70
+ )
71
+
72
+ export default GuardedBarcodeTagsPage
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2023",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react-jsx",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true
18
+ },
19
+ "include": ["."]
20
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,43 @@
1
+ import { defineWidgetConfig } from "@medusajs/admin-sdk"
2
+ import { useTranslation } from "react-i18next"
3
+ import { ProductBarcodeCard } from "../components"
4
+ import {
5
+ type ProductBarcodeWidgetEntity,
6
+ useProductBarcodes,
7
+ } from "../hooks/use-product-barcodes"
8
+
9
+ interface ProductBarcodeWidgetProps {
10
+ data?: ProductBarcodeWidgetEntity
11
+ }
12
+
13
+ const ProductBarcodeWidget = ({ data }: ProductBarcodeWidgetProps) => {
14
+ const { t } = useTranslation()
15
+ const {
16
+ tags,
17
+ linkedBarcodes,
18
+ printPreview,
19
+ isBusy,
20
+ feedback,
21
+ handleGenerateProductBarcodes,
22
+ handleQuickPrintProductLabels,
23
+ } = useProductBarcodes(data)
24
+
25
+ return (
26
+ <ProductBarcodeCard
27
+ productTitle={data?.title || t("widget.defaultProductTitle")}
28
+ tags={tags}
29
+ linkedBarcodes={linkedBarcodes}
30
+ printPreview={printPreview}
31
+ isBusy={isBusy}
32
+ feedback={feedback}
33
+ onGenerateBarcodes={() => void handleGenerateProductBarcodes()}
34
+ onQuickPrintLabels={() => void handleQuickPrintProductLabels()}
35
+ />
36
+ )
37
+ }
38
+
39
+ export const config = defineWidgetConfig({
40
+ zone: "product.details.after",
41
+ })
42
+
43
+ export default ProductBarcodeWidget