@vicacha-devs/medusa-plugin-stories 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/__tests__/stories-plugin.spec.js +358 -0
- package/.medusa/server/src/admin/i18n/index.js +35 -0
- package/.medusa/server/src/admin/i18n/json/ar.json +196 -0
- package/.medusa/server/src/admin/i18n/json/de.json +196 -0
- package/.medusa/server/src/admin/i18n/json/en.json +196 -0
- package/.medusa/server/src/admin/i18n/json/es.json +196 -0
- package/.medusa/server/src/admin/i18n/json/fr.json +196 -0
- package/.medusa/server/src/admin/i18n/json/it.json +196 -0
- package/.medusa/server/src/admin/i18n/json/nl.json +196 -0
- package/.medusa/server/src/admin/i18n/json/pl.json +196 -0
- package/.medusa/server/src/admin/i18n/json/pt.json +196 -0
- package/.medusa/server/src/admin/i18n/json/tr.json +196 -0
- package/.medusa/server/src/admin/index.cjs +4699 -0
- package/.medusa/server/src/admin/index.js +4699 -0
- package/.medusa/server/src/api/admin/plugin/route.js +4 -0
- package/.medusa/server/src/api/admin/stories/[id]/hotspots/route.js +14 -0
- package/.medusa/server/src/api/admin/stories/[id]/route.js +27 -0
- package/.medusa/server/src/api/admin/stories/[id]/stickers/route.js +14 -0
- package/.medusa/server/src/api/admin/stories/analytics/route.js +7 -0
- package/.medusa/server/src/api/admin/stories/groups/[id]/route.js +23 -0
- package/.medusa/server/src/api/admin/stories/groups/route.js +15 -0
- package/.medusa/server/src/api/admin/stories/route.js +21 -0
- package/.medusa/server/src/api/middlewares.js +58 -0
- package/.medusa/server/src/api/store/plugin/route.js +4 -0
- package/.medusa/server/src/api/store/stories/[id]/events/route.js +12 -0
- package/.medusa/server/src/api/store/stories/[id]/interact/route.js +14 -0
- package/.medusa/server/src/api/store/stories/route.js +33 -0
- package/.medusa/server/src/api/validators.js +136 -0
- package/.medusa/server/src/hooks/index.js +213 -0
- package/.medusa/server/src/hooks/use-sdk-primitives.js +93 -0
- package/.medusa/server/src/index.js +6 -0
- package/.medusa/server/src/jobs/expire-ephemeral-stories.js +10 -0
- package/.medusa/server/src/modules/index.js +7 -0
- package/.medusa/server/src/modules/stories/index.js +3 -0
- package/.medusa/server/src/modules/story/index.js +23 -0
- package/.medusa/server/src/modules/story/migrations/Migration20260514000000.js +181 -0
- package/.medusa/server/src/modules/story/models/index.js +141 -0
- package/.medusa/server/src/modules/story/service.js +673 -0
- package/.medusa/server/src/modules/story/types.js +3 -0
- package/.medusa/server/src/modules/story/utils/security.js +76 -0
- package/.medusa/server/src/rbac.js +75 -0
- package/.medusa/server/src/sdk/index.js +148 -0
- package/.medusa/server/src/subscribers/product-deleted.js +11 -0
- package/.medusa/server/src/types/index.js +2 -0
- package/.medusa/server/src/ui/index.js +5 -0
- package/.medusa/server/src/ui/story-hotspot-pin.js +43 -0
- package/.medusa/server/src/ui/story-player-modal.js +104 -0
- package/.medusa/server/src/ui/story-product-sheet.js +7 -0
- package/.medusa/server/src/ui/story-rings-bar.js +42 -0
- package/.medusa/server/src/workflows/index.js +50 -0
- package/LICENSE +21 -0
- package/README.md +246 -2
- package/package.json +127 -3
- package/src/__tests__/medusa-shim.mjs +533 -0
- package/src/__tests__/register-ts-resolver.mjs +141 -0
- package/src/__tests__/stories-plugin.spec.ts +526 -0
- package/src/admin/README.md +94 -0
- package/src/admin/components/analytics-tab.tsx +225 -0
- package/src/admin/components/canvas-editor-tab.tsx +77 -0
- package/src/admin/components/hotspot-form-section.tsx +155 -0
- package/src/admin/components/index.ts +15 -0
- package/src/admin/components/overview-cards.tsx +96 -0
- package/src/admin/components/product-stories-card.tsx +123 -0
- package/src/admin/components/rbac-guard.tsx +153 -0
- package/src/admin/components/slide-form-section.tsx +187 -0
- package/src/admin/components/slide-preview-canvas.tsx +166 -0
- package/src/admin/components/slide-timeline-section.tsx +126 -0
- package/src/admin/components/sticker-form-section.tsx +201 -0
- package/src/admin/components/sticker-list-section.tsx +113 -0
- package/src/admin/components/stickers-tab.tsx +34 -0
- package/src/admin/components/story-ring-form.tsx +241 -0
- package/src/admin/components/story-rings-tab.tsx +204 -0
- package/src/admin/components/story-rings-table.tsx +222 -0
- package/src/admin/components/studio-header.tsx +67 -0
- package/src/admin/hooks/use-product-stories.ts +71 -0
- package/src/admin/hooks/use-stories-studio.ts +439 -0
- package/src/admin/i18n/README.md +84 -0
- package/src/admin/i18n/index.ts +36 -0
- package/src/admin/i18n/json/ar.json +196 -0
- package/src/admin/i18n/json/de.json +196 -0
- package/src/admin/i18n/json/en.json +196 -0
- package/src/admin/i18n/json/es.json +196 -0
- package/src/admin/i18n/json/fr.json +196 -0
- package/src/admin/i18n/json/it.json +196 -0
- package/src/admin/i18n/json/nl.json +196 -0
- package/src/admin/i18n/json/pl.json +196 -0
- package/src/admin/i18n/json/pt.json +196 -0
- package/src/admin/i18n/json/tr.json +196 -0
- package/src/admin/routes/stories/analytics/page.tsx +66 -0
- package/src/admin/routes/stories/canvas/page.tsx +101 -0
- package/src/admin/routes/stories/page.tsx +164 -0
- package/src/admin/routes/stories/rings/@create/page.tsx +61 -0
- package/src/admin/routes/stories/rings/page.tsx +88 -0
- package/src/admin/routes/stories/stickers/page.tsx +74 -0
- package/src/admin/tsconfig.json +23 -0
- package/src/admin/utils/theme-presets.ts +94 -0
- package/src/admin/vite-env.d.ts +1 -0
- package/src/admin/widgets/product-stories-widget.tsx +32 -0
- package/src/api/README.md +61 -0
- package/src/api/admin/plugin/route.ts +5 -0
- package/src/api/admin/stories/[id]/hotspots/route.ts +17 -0
- package/src/api/admin/stories/[id]/route.ts +40 -0
- package/src/api/admin/stories/[id]/stickers/route.ts +20 -0
- package/src/api/admin/stories/analytics/route.ts +8 -0
- package/src/api/admin/stories/groups/[id]/route.ts +30 -0
- package/src/api/admin/stories/groups/route.ts +18 -0
- package/src/api/admin/stories/route.ts +31 -0
- package/src/api/middlewares.ts +73 -0
- package/src/api/store/plugin/route.ts +5 -0
- package/src/api/store/stories/[id]/events/route.ts +14 -0
- package/src/api/store/stories/[id]/interact/route.ts +18 -0
- package/src/api/store/stories/route.ts +44 -0
- package/src/api/validators.ts +166 -0
- package/src/hooks/index.ts +419 -0
- package/src/hooks/use-sdk-primitives.ts +114 -0
- package/src/index.ts +14 -0
- package/src/jobs/README.md +16 -0
- package/src/jobs/expire-ephemeral-stories.ts +14 -0
- package/src/links/README.md +18 -0
- package/src/modules/README.md +46 -0
- package/src/modules/index.ts +15 -0
- package/src/modules/stories/index.ts +11 -0
- package/src/modules/story/index.ts +34 -0
- package/src/modules/story/migrations/Migration20260514000000.ts +196 -0
- package/src/modules/story/models/index.ts +146 -0
- package/src/modules/story/service.ts +1052 -0
- package/src/modules/story/types.ts +190 -0
- package/src/modules/story/utils/security.ts +100 -0
- package/src/providers/README.md +14 -0
- package/src/rbac.ts +89 -0
- package/src/sdk/index.ts +233 -0
- package/src/subscribers/README.md +16 -0
- package/src/subscribers/product-deleted.ts +15 -0
- package/src/types/index.ts +1 -0
- package/src/types/medusa-ui.d.ts +451 -0
- package/src/ui/index.ts +4 -0
- package/src/ui/story-hotspot-pin.tsx +122 -0
- package/src/ui/story-player-modal.tsx +361 -0
- package/src/ui/story-product-sheet.tsx +85 -0
- package/src/ui/story-rings-bar.tsx +113 -0
- package/src/workflows/README.md +19 -0
- package/src/workflows/index.ts +217 -0
- package/tsconfig.json +39 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Container,
|
|
5
|
+
Heading,
|
|
6
|
+
StatusBadge,
|
|
7
|
+
Table,
|
|
8
|
+
Text,
|
|
9
|
+
} from "@medusajs/ui"
|
|
10
|
+
import { useTranslation } from "react-i18next"
|
|
11
|
+
import type { StoriesAnalyticsOverview } from "../../modules/story/types"
|
|
12
|
+
|
|
13
|
+
export interface AnalyticsTabProps {
|
|
14
|
+
analytics?: StoriesAnalyticsOverview
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const AnalyticsFunnelSection = ({ analytics }: AnalyticsTabProps) => {
|
|
18
|
+
const { t } = useTranslation()
|
|
19
|
+
|
|
20
|
+
const totalImpressions = analytics?.total_impressions ?? 0
|
|
21
|
+
const hotspotCtrPct =
|
|
22
|
+
totalImpressions > 0
|
|
23
|
+
? Math.round(
|
|
24
|
+
((analytics?.total_hotspot_clicks ?? 0) / totalImpressions) * 1000
|
|
25
|
+
) / 10
|
|
26
|
+
: 0
|
|
27
|
+
|
|
28
|
+
const funnelSteps = [
|
|
29
|
+
{
|
|
30
|
+
label: t("analyticsTab.stepImpressions"),
|
|
31
|
+
value: totalImpressions,
|
|
32
|
+
percent: 100,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: t("analyticsTab.stepCompletions"),
|
|
36
|
+
value: analytics?.total_completions ?? 0,
|
|
37
|
+
percent: analytics?.overall_completion_rate_pct ?? 0,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: t("analyticsTab.stepHotspotClicks"),
|
|
41
|
+
value: analytics?.total_hotspot_clicks ?? 0,
|
|
42
|
+
percent: hotspotCtrPct,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: t("analyticsTab.stepAddToCarts"),
|
|
46
|
+
value: analytics?.total_cart_conversions ?? 0,
|
|
47
|
+
percent: analytics?.overall_conversion_rate_pct ?? 0,
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Container className="divide-y p-0">
|
|
53
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
54
|
+
<div>
|
|
55
|
+
<Heading level="h2">{t("analyticsTab.funnelTitle")}</Heading>
|
|
56
|
+
<Text size="small" className="text-ui-fg-subtle mt-1">
|
|
57
|
+
{t("analyticsTab.funnelSubtitle")}
|
|
58
|
+
</Text>
|
|
59
|
+
</div>
|
|
60
|
+
<StatusBadge
|
|
61
|
+
color={
|
|
62
|
+
(analytics?.overall_conversion_rate_pct ?? 0) > 0 ? "green" : "grey"
|
|
63
|
+
}
|
|
64
|
+
>
|
|
65
|
+
{t("header.conversionBadge", {
|
|
66
|
+
rate: analytics?.overall_conversion_rate_pct ?? 0,
|
|
67
|
+
})}
|
|
68
|
+
</StatusBadge>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{funnelSteps.map((step) => (
|
|
72
|
+
<SectionRow
|
|
73
|
+
key={step.label}
|
|
74
|
+
title={step.label}
|
|
75
|
+
value={
|
|
76
|
+
<div className="flex items-center gap-x-2">
|
|
77
|
+
<Text size="small" weight="plus">
|
|
78
|
+
{step.value}
|
|
79
|
+
</Text>
|
|
80
|
+
<Badge size="xsmall" color="grey">
|
|
81
|
+
{t("analyticsTab.percentOfImpressions", {
|
|
82
|
+
percent: step.percent,
|
|
83
|
+
})}
|
|
84
|
+
</Badge>
|
|
85
|
+
</div>
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
))}
|
|
89
|
+
</Container>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const AnalyticsRingBreakdownSection = ({
|
|
94
|
+
analytics,
|
|
95
|
+
}: AnalyticsTabProps) => {
|
|
96
|
+
const { t } = useTranslation()
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Container className="divide-y p-0">
|
|
100
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
101
|
+
<Heading level="h2">{t("analyticsTab.ringBreakdownTitle")}</Heading>
|
|
102
|
+
<Badge size="xsmall" color="purple">
|
|
103
|
+
{(analytics?.by_group ?? []).length}
|
|
104
|
+
</Badge>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<Table>
|
|
108
|
+
<Table.Header>
|
|
109
|
+
<Table.Row>
|
|
110
|
+
<Table.HeaderCell>
|
|
111
|
+
{t("analyticsTab.colHighlightRing")}
|
|
112
|
+
</Table.HeaderCell>
|
|
113
|
+
<Table.HeaderCell>{t("analyticsTab.colSlides")}</Table.HeaderCell>
|
|
114
|
+
<Table.HeaderCell>
|
|
115
|
+
{t("analyticsTab.colImpressions")}
|
|
116
|
+
</Table.HeaderCell>
|
|
117
|
+
<Table.HeaderCell>
|
|
118
|
+
{t("analyticsTab.colCompletionRate")}
|
|
119
|
+
</Table.HeaderCell>
|
|
120
|
+
<Table.HeaderCell>
|
|
121
|
+
{t("analyticsTab.colHotspotClicks")}
|
|
122
|
+
</Table.HeaderCell>
|
|
123
|
+
<Table.HeaderCell>
|
|
124
|
+
{t("analyticsTab.colAddToCartRate")}
|
|
125
|
+
</Table.HeaderCell>
|
|
126
|
+
<Table.HeaderCell>
|
|
127
|
+
{t("analyticsTab.colStickerVotes")}
|
|
128
|
+
</Table.HeaderCell>
|
|
129
|
+
</Table.Row>
|
|
130
|
+
</Table.Header>
|
|
131
|
+
<Table.Body>
|
|
132
|
+
{(analytics?.by_group ?? []).map((grp) => (
|
|
133
|
+
<Table.Row key={grp.group_id}>
|
|
134
|
+
<Table.Cell className="font-medium">{grp.group_title}</Table.Cell>
|
|
135
|
+
<Table.Cell>{grp.slides_count}</Table.Cell>
|
|
136
|
+
<Table.Cell>{grp.impressions}</Table.Cell>
|
|
137
|
+
<Table.Cell>
|
|
138
|
+
<StatusBadge
|
|
139
|
+
color={grp.completion_rate_pct >= 50 ? "green" : "grey"}
|
|
140
|
+
>
|
|
141
|
+
{grp.completion_rate_pct}% ({grp.completions})
|
|
142
|
+
</StatusBadge>
|
|
143
|
+
</Table.Cell>
|
|
144
|
+
<Table.Cell>{grp.hotspot_clicks}</Table.Cell>
|
|
145
|
+
<Table.Cell>
|
|
146
|
+
<StatusBadge
|
|
147
|
+
color={grp.conversion_rate_pct > 0 ? "green" : "grey"}
|
|
148
|
+
>
|
|
149
|
+
{grp.conversion_rate_pct}% ({grp.cart_conversions})
|
|
150
|
+
</StatusBadge>
|
|
151
|
+
</Table.Cell>
|
|
152
|
+
<Table.Cell>{grp.sticker_interactions}</Table.Cell>
|
|
153
|
+
</Table.Row>
|
|
154
|
+
))}
|
|
155
|
+
</Table.Body>
|
|
156
|
+
</Table>
|
|
157
|
+
</Container>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const AnalyticsTopSlidesSection = ({ analytics }: AnalyticsTabProps) => {
|
|
162
|
+
const { t } = useTranslation()
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<Container className="divide-y p-0">
|
|
166
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
167
|
+
<Heading level="h2">{t("analyticsTab.topSlidesTitle")}</Heading>
|
|
168
|
+
<Badge size="xsmall" color="blue">
|
|
169
|
+
{(analytics?.top_slides ?? []).length}
|
|
170
|
+
</Badge>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<Table>
|
|
174
|
+
<Table.Header>
|
|
175
|
+
<Table.Row>
|
|
176
|
+
<Table.HeaderCell>
|
|
177
|
+
{t("analyticsTab.colSlideTitle")}
|
|
178
|
+
</Table.HeaderCell>
|
|
179
|
+
<Table.HeaderCell>
|
|
180
|
+
{t("analyticsTab.colHighlightRing")}
|
|
181
|
+
</Table.HeaderCell>
|
|
182
|
+
<Table.HeaderCell>
|
|
183
|
+
{t("analyticsTab.colImpressions")}
|
|
184
|
+
</Table.HeaderCell>
|
|
185
|
+
<Table.HeaderCell>
|
|
186
|
+
{t("analyticsTab.colCompletions")}
|
|
187
|
+
</Table.HeaderCell>
|
|
188
|
+
<Table.HeaderCell>
|
|
189
|
+
{t("analyticsTab.colHotspotClicks")}
|
|
190
|
+
</Table.HeaderCell>
|
|
191
|
+
<Table.HeaderCell>
|
|
192
|
+
{t("analyticsTab.colAddToCarts")}
|
|
193
|
+
</Table.HeaderCell>
|
|
194
|
+
</Table.Row>
|
|
195
|
+
</Table.Header>
|
|
196
|
+
<Table.Body>
|
|
197
|
+
{(analytics?.top_slides ?? []).map((slide) => (
|
|
198
|
+
<Table.Row key={slide.id}>
|
|
199
|
+
<Table.Cell className="font-medium">{slide.title}</Table.Cell>
|
|
200
|
+
<Table.Cell>
|
|
201
|
+
<Badge size="xsmall" color="grey">
|
|
202
|
+
{slide.group_title ?? t("analyticsTab.unassigned")}
|
|
203
|
+
</Badge>
|
|
204
|
+
</Table.Cell>
|
|
205
|
+
<Table.Cell>{slide.impressions}</Table.Cell>
|
|
206
|
+
<Table.Cell>{slide.completions}</Table.Cell>
|
|
207
|
+
<Table.Cell>{slide.hotspot_clicks}</Table.Cell>
|
|
208
|
+
<Table.Cell>{slide.cart_conversions}</Table.Cell>
|
|
209
|
+
</Table.Row>
|
|
210
|
+
))}
|
|
211
|
+
</Table.Body>
|
|
212
|
+
</Table>
|
|
213
|
+
</Container>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const AnalyticsTab = ({ analytics }: AnalyticsTabProps) => {
|
|
218
|
+
return (
|
|
219
|
+
<div className="flex flex-col gap-y-6">
|
|
220
|
+
<AnalyticsFunnelSection analytics={analytics} />
|
|
221
|
+
<AnalyticsRingBreakdownSection analytics={analytics} />
|
|
222
|
+
<AnalyticsTopSlidesSection analytics={analytics} />
|
|
223
|
+
</div>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import type { StoryGroupDTO, StorySlideDTO } from "../../modules/story/types"
|
|
3
|
+
import type {
|
|
4
|
+
NewHotspotFormState,
|
|
5
|
+
NewSlideFormState,
|
|
6
|
+
} from "../hooks/use-stories-studio"
|
|
7
|
+
import { CanvasHotspotPinnerSection } from "./hotspot-form-section"
|
|
8
|
+
import {
|
|
9
|
+
CanvasSlideBuilderSection,
|
|
10
|
+
CanvasTimelineSection,
|
|
11
|
+
} from "./slide-form-section"
|
|
12
|
+
import { CanvasPreviewSection } from "./slide-preview-canvas"
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
CanvasHotspotPinnerSection,
|
|
16
|
+
CanvasPreviewSection,
|
|
17
|
+
CanvasSlideBuilderSection,
|
|
18
|
+
CanvasTimelineSection,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CanvasEditorTabProps {
|
|
22
|
+
groups: StoryGroupDTO[]
|
|
23
|
+
slides: StorySlideDTO[]
|
|
24
|
+
selectedSlide: StorySlideDTO | null
|
|
25
|
+
onSelectSlide: (slideId: string) => void
|
|
26
|
+
slideForm: NewSlideFormState
|
|
27
|
+
onSlideFormChange: React.Dispatch<React.SetStateAction<NewSlideFormState>>
|
|
28
|
+
hotspotForm: NewHotspotFormState
|
|
29
|
+
onHotspotFormChange: React.Dispatch<React.SetStateAction<NewHotspotFormState>>
|
|
30
|
+
isSavingSlide: boolean
|
|
31
|
+
isSavingHotspot: boolean
|
|
32
|
+
onCreateSlide: () => void
|
|
33
|
+
onToggleSlideActive: (id: string, isActive: boolean) => void
|
|
34
|
+
onDeleteSlide: (id: string) => void
|
|
35
|
+
onCanvasCoordinateClick: (xPercent: number, yPercent: number) => void
|
|
36
|
+
onAddHotspot: () => void
|
|
37
|
+
onRemoveHotspot: (hotspotId: string) => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const CanvasEditorTab = (props: CanvasEditorTabProps) => {
|
|
41
|
+
return (
|
|
42
|
+
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
|
|
43
|
+
<div className="lg:col-span-5">
|
|
44
|
+
<CanvasPreviewSection
|
|
45
|
+
selectedSlide={props.selectedSlide}
|
|
46
|
+
slideForm={props.slideForm}
|
|
47
|
+
hotspotForm={props.hotspotForm}
|
|
48
|
+
onCanvasCoordinateClick={props.onCanvasCoordinateClick}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="lg:col-span-7 flex flex-col gap-y-6">
|
|
52
|
+
<CanvasSlideBuilderSection
|
|
53
|
+
groups={props.groups}
|
|
54
|
+
slideForm={props.slideForm}
|
|
55
|
+
onSlideFormChange={props.onSlideFormChange}
|
|
56
|
+
isSavingSlide={props.isSavingSlide}
|
|
57
|
+
onCreateSlide={props.onCreateSlide}
|
|
58
|
+
/>
|
|
59
|
+
<CanvasHotspotPinnerSection
|
|
60
|
+
selectedSlide={props.selectedSlide}
|
|
61
|
+
hotspotForm={props.hotspotForm}
|
|
62
|
+
onHotspotFormChange={props.onHotspotFormChange}
|
|
63
|
+
isSavingHotspot={props.isSavingHotspot}
|
|
64
|
+
onAddHotspot={props.onAddHotspot}
|
|
65
|
+
onRemoveHotspot={props.onRemoveHotspot}
|
|
66
|
+
/>
|
|
67
|
+
<CanvasTimelineSection
|
|
68
|
+
slides={props.slides}
|
|
69
|
+
selectedSlide={props.selectedSlide}
|
|
70
|
+
onSelectSlide={props.onSelectSlide}
|
|
71
|
+
onToggleSlideActive={props.onToggleSlideActive}
|
|
72
|
+
onDeleteSlide={props.onDeleteSlide}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
3
|
+
import {
|
|
4
|
+
Badge,
|
|
5
|
+
Button,
|
|
6
|
+
Container,
|
|
7
|
+
Heading,
|
|
8
|
+
Input,
|
|
9
|
+
Label,
|
|
10
|
+
Table,
|
|
11
|
+
} from "@medusajs/ui"
|
|
12
|
+
import { useTranslation } from "react-i18next"
|
|
13
|
+
import type { StorySlideDTO } from "../../modules/story/types"
|
|
14
|
+
import type { NewHotspotFormState } from "../hooks/use-stories-studio"
|
|
15
|
+
|
|
16
|
+
export interface CanvasHotspotPinnerSectionProps {
|
|
17
|
+
selectedSlide: StorySlideDTO | null
|
|
18
|
+
hotspotForm: NewHotspotFormState
|
|
19
|
+
onHotspotFormChange: React.Dispatch<React.SetStateAction<NewHotspotFormState>>
|
|
20
|
+
isSavingHotspot: boolean
|
|
21
|
+
onAddHotspot: () => void
|
|
22
|
+
onRemoveHotspot: (hotspotId: string) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const CanvasHotspotPinnerSection = ({
|
|
26
|
+
selectedSlide,
|
|
27
|
+
hotspotForm,
|
|
28
|
+
onHotspotFormChange,
|
|
29
|
+
isSavingHotspot,
|
|
30
|
+
onAddHotspot,
|
|
31
|
+
onRemoveHotspot,
|
|
32
|
+
}: CanvasHotspotPinnerSectionProps) => {
|
|
33
|
+
const { t } = useTranslation()
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Container className="divide-y p-0">
|
|
37
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
38
|
+
<Heading level="h2">
|
|
39
|
+
{t("canvasTab.pinHotspotTitle", {
|
|
40
|
+
slide: selectedSlide
|
|
41
|
+
? `"${selectedSlide.title}"`
|
|
42
|
+
: t("canvasTab.selectedSlideFallback"),
|
|
43
|
+
})}
|
|
44
|
+
</Heading>
|
|
45
|
+
<Button
|
|
46
|
+
size="small"
|
|
47
|
+
variant="primary"
|
|
48
|
+
isLoading={isSavingHotspot}
|
|
49
|
+
onClick={onAddHotspot}
|
|
50
|
+
>
|
|
51
|
+
{t("canvasTab.pinButton")}
|
|
52
|
+
</Button>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<SectionRow
|
|
56
|
+
title={t("canvasTab.pinCrosshair", {
|
|
57
|
+
x: hotspotForm.x_percent,
|
|
58
|
+
y: hotspotForm.y_percent,
|
|
59
|
+
})}
|
|
60
|
+
value={t("canvasTab.coordinatesHelp", {
|
|
61
|
+
x: hotspotForm.x_percent,
|
|
62
|
+
y: hotspotForm.y_percent,
|
|
63
|
+
})}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 px-6 py-4">
|
|
67
|
+
<div className="flex flex-col gap-y-1.5">
|
|
68
|
+
<Label htmlFor="hs-prod-id">{t("canvasTab.productIdField")}</Label>
|
|
69
|
+
<Input
|
|
70
|
+
id="hs-prod-id"
|
|
71
|
+
placeholder={t("canvasTab.productIdPlaceholder")}
|
|
72
|
+
value={hotspotForm.product_id}
|
|
73
|
+
onChange={(e) =>
|
|
74
|
+
onHotspotFormChange((prev) => ({
|
|
75
|
+
...prev,
|
|
76
|
+
product_id: e.target.value,
|
|
77
|
+
}))
|
|
78
|
+
}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<div className="flex flex-col gap-y-1.5">
|
|
82
|
+
<Label htmlFor="hs-prod-title">
|
|
83
|
+
{t("canvasTab.productTitleField")}
|
|
84
|
+
</Label>
|
|
85
|
+
<Input
|
|
86
|
+
id="hs-prod-title"
|
|
87
|
+
placeholder={t("canvasTab.productTitlePlaceholder")}
|
|
88
|
+
value={hotspotForm.product_title}
|
|
89
|
+
onChange={(e) =>
|
|
90
|
+
onHotspotFormChange((prev) => ({
|
|
91
|
+
...prev,
|
|
92
|
+
product_title: e.target.value,
|
|
93
|
+
}))
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
<div className="flex flex-col gap-y-1.5">
|
|
98
|
+
<Label htmlFor="hs-price">{t("canvasTab.priceBadgeField")}</Label>
|
|
99
|
+
<Input
|
|
100
|
+
id="hs-price"
|
|
101
|
+
placeholder={t("canvasTab.priceBadgePlaceholder")}
|
|
102
|
+
value={hotspotForm.price_formatted}
|
|
103
|
+
onChange={(e) =>
|
|
104
|
+
onHotspotFormChange((prev) => ({
|
|
105
|
+
...prev,
|
|
106
|
+
price_formatted: e.target.value,
|
|
107
|
+
}))
|
|
108
|
+
}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
{Boolean(selectedSlide?.hotspots?.length) && (
|
|
114
|
+
<Table>
|
|
115
|
+
<Table.Header>
|
|
116
|
+
<Table.Row>
|
|
117
|
+
<Table.HeaderCell>
|
|
118
|
+
{t("canvasTab.productTitleField")}
|
|
119
|
+
</Table.HeaderCell>
|
|
120
|
+
<Table.HeaderCell>
|
|
121
|
+
{t("canvasTab.priceBadgeField")}
|
|
122
|
+
</Table.HeaderCell>
|
|
123
|
+
<Table.HeaderCell>X / Y</Table.HeaderCell>
|
|
124
|
+
<Table.HeaderCell className="text-right" />
|
|
125
|
+
</Table.Row>
|
|
126
|
+
</Table.Header>
|
|
127
|
+
<Table.Body>
|
|
128
|
+
{(selectedSlide?.hotspots ?? []).map((hs) => (
|
|
129
|
+
<Table.Row key={hs.id}>
|
|
130
|
+
<Table.Cell className="font-medium">
|
|
131
|
+
{hs.product_title}
|
|
132
|
+
</Table.Cell>
|
|
133
|
+
<Table.Cell>{hs.price_formatted || "—"}</Table.Cell>
|
|
134
|
+
<Table.Cell>
|
|
135
|
+
<Badge size="xsmall" color="blue">
|
|
136
|
+
{hs.x_percent}%, {hs.y_percent}%
|
|
137
|
+
</Badge>
|
|
138
|
+
</Table.Cell>
|
|
139
|
+
<Table.Cell className="text-right">
|
|
140
|
+
<Button
|
|
141
|
+
size="small"
|
|
142
|
+
variant="secondary"
|
|
143
|
+
onClick={() => onRemoveHotspot(hs.id)}
|
|
144
|
+
>
|
|
145
|
+
{t("canvasTab.removeHotspotButton")}
|
|
146
|
+
</Button>
|
|
147
|
+
</Table.Cell>
|
|
148
|
+
</Table.Row>
|
|
149
|
+
))}
|
|
150
|
+
</Table.Body>
|
|
151
|
+
</Table>
|
|
152
|
+
)}
|
|
153
|
+
</Container>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./studio-header"
|
|
2
|
+
export * from "./overview-cards"
|
|
3
|
+
export * from "./story-ring-form"
|
|
4
|
+
export * from "./story-rings-table"
|
|
5
|
+
export * from "./story-rings-tab"
|
|
6
|
+
export * from "./slide-preview-canvas"
|
|
7
|
+
export * from "./slide-form-section"
|
|
8
|
+
export * from "./slide-timeline-section"
|
|
9
|
+
export * from "./hotspot-form-section"
|
|
10
|
+
export * from "./canvas-editor-tab"
|
|
11
|
+
export * from "./sticker-form-section"
|
|
12
|
+
export * from "./sticker-list-section"
|
|
13
|
+
export * from "./stickers-tab"
|
|
14
|
+
export * from "./analytics-tab"
|
|
15
|
+
export * from "./product-stories-card"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { Button, clx, Container, Heading, Skeleton, Text } from "@medusajs/ui"
|
|
3
|
+
|
|
4
|
+
export type StatCardProps = {
|
|
5
|
+
title: string
|
|
6
|
+
value: number | string
|
|
7
|
+
icon: React.ReactNode
|
|
8
|
+
loading?: boolean
|
|
9
|
+
onClick?: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const StatCard = ({
|
|
13
|
+
title,
|
|
14
|
+
value,
|
|
15
|
+
icon,
|
|
16
|
+
loading = false,
|
|
17
|
+
onClick,
|
|
18
|
+
}: StatCardProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<Container
|
|
21
|
+
className={clx(
|
|
22
|
+
"p-0",
|
|
23
|
+
onClick
|
|
24
|
+
? "cursor-pointer hover:bg-ui-bg-subtle-hover transition-colors"
|
|
25
|
+
: ""
|
|
26
|
+
)}
|
|
27
|
+
onClick={onClick}
|
|
28
|
+
>
|
|
29
|
+
<div className="p-5">
|
|
30
|
+
<div className="flex items-center justify-between">
|
|
31
|
+
<Text className="text-ui-fg-subtle">{title}</Text>
|
|
32
|
+
|
|
33
|
+
<div className="flex items-center justify-center w-8 h-8 rounded-md bg-ui-bg-subtle">
|
|
34
|
+
{icon}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div className="mt-3">
|
|
39
|
+
{loading ? (
|
|
40
|
+
<Skeleton className="h-8 w-16" />
|
|
41
|
+
) : (
|
|
42
|
+
<Heading level="h2">{value}</Heading>
|
|
43
|
+
)}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</Container>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type NavigationCardPosition =
|
|
51
|
+
| "top-left"
|
|
52
|
+
| "top-right"
|
|
53
|
+
| "bottom-left"
|
|
54
|
+
| "bottom-right"
|
|
55
|
+
|
|
56
|
+
export type NavigationCardProps = {
|
|
57
|
+
icon: React.ReactNode
|
|
58
|
+
title: string
|
|
59
|
+
description: string
|
|
60
|
+
onClick: () => void
|
|
61
|
+
position: NavigationCardPosition
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const NavigationCard = ({
|
|
65
|
+
icon,
|
|
66
|
+
title,
|
|
67
|
+
description,
|
|
68
|
+
onClick,
|
|
69
|
+
position,
|
|
70
|
+
}: NavigationCardProps) => {
|
|
71
|
+
const isBottom = position === "bottom-left" || position === "bottom-right"
|
|
72
|
+
const isLeft = position === "top-left" || position === "bottom-left"
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Button
|
|
76
|
+
type="button"
|
|
77
|
+
className={clx(
|
|
78
|
+
"text-left p-6 hover:bg-ui-bg-subtle-hover transition-colors",
|
|
79
|
+
!isBottom ? "border-b border-ui-border-base" : "",
|
|
80
|
+
isLeft ? "md:border-r md:border-ui-border-base" : ""
|
|
81
|
+
)}
|
|
82
|
+
onClick={onClick}
|
|
83
|
+
>
|
|
84
|
+
<div className="flex items-start gap-x-3">
|
|
85
|
+
<div className="flex items-center justify-center w-8 h-8 rounded-md bg-ui-bg-subtle shrink-0">
|
|
86
|
+
{icon}
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div>
|
|
90
|
+
<Heading level="h3">{title}</Heading>
|
|
91
|
+
<Text className="text-ui-fg-subtle mt-1">{description}</Text>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</Button>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Button,
|
|
5
|
+
Container,
|
|
6
|
+
Heading,
|
|
7
|
+
StatusBadge,
|
|
8
|
+
Table,
|
|
9
|
+
Text,
|
|
10
|
+
Toaster,
|
|
11
|
+
} from "@medusajs/ui"
|
|
12
|
+
import { useTranslation } from "react-i18next"
|
|
13
|
+
import type { StorySlideDTO } from "../../modules/story/types"
|
|
14
|
+
|
|
15
|
+
export interface ProductStoriesCardProps {
|
|
16
|
+
productTitle?: string
|
|
17
|
+
taggedSlides: StorySlideDTO[]
|
|
18
|
+
isCreating: boolean
|
|
19
|
+
onQuickCreateProductStory: () => Promise<void>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const ProductStoriesCard = ({
|
|
23
|
+
productTitle,
|
|
24
|
+
taggedSlides,
|
|
25
|
+
isCreating,
|
|
26
|
+
onQuickCreateProductStory,
|
|
27
|
+
}: ProductStoriesCardProps) => {
|
|
28
|
+
const { t, i18n } = useTranslation()
|
|
29
|
+
const isRtl = (i18n.resolvedLanguage || i18n.language || "").startsWith("ar")
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Container className="divide-y p-0" dir={isRtl ? "rtl" : "ltr"}>
|
|
33
|
+
<Toaster />
|
|
34
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
35
|
+
<div>
|
|
36
|
+
<Heading level="h2">{t("widget.title")}</Heading>
|
|
37
|
+
<Text size="small" className="text-ui-fg-subtle">
|
|
38
|
+
{t("widget.subtitle", {
|
|
39
|
+
product: productTitle || t("widget.thisProductFallback"),
|
|
40
|
+
})}
|
|
41
|
+
</Text>
|
|
42
|
+
</div>
|
|
43
|
+
<Button
|
|
44
|
+
variant="secondary"
|
|
45
|
+
size="small"
|
|
46
|
+
isLoading={isCreating}
|
|
47
|
+
onClick={() => void onQuickCreateProductStory()}
|
|
48
|
+
>
|
|
49
|
+
{t("widget.createButton")}
|
|
50
|
+
</Button>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<SectionRow
|
|
54
|
+
title={t("analyticsTab.colSlides")}
|
|
55
|
+
value={
|
|
56
|
+
<Badge size="xsmall" color="blue">
|
|
57
|
+
{taggedSlides.length}
|
|
58
|
+
</Badge>
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
{taggedSlides.length === 0 ? (
|
|
63
|
+
<div className="px-6 py-4">
|
|
64
|
+
<Text size="small" className="text-ui-fg-subtle">
|
|
65
|
+
{t("widget.emptyState")}
|
|
66
|
+
</Text>
|
|
67
|
+
</div>
|
|
68
|
+
) : (
|
|
69
|
+
<Table>
|
|
70
|
+
<Table.Header>
|
|
71
|
+
<Table.Row>
|
|
72
|
+
<Table.HeaderCell>
|
|
73
|
+
{t("analyticsTab.colSlideTitle")}
|
|
74
|
+
</Table.HeaderCell>
|
|
75
|
+
<Table.HeaderCell>
|
|
76
|
+
{t("analyticsTab.colImpressions")}
|
|
77
|
+
</Table.HeaderCell>
|
|
78
|
+
<Table.HeaderCell>
|
|
79
|
+
{t("analyticsTab.colHotspotClicks")}
|
|
80
|
+
</Table.HeaderCell>
|
|
81
|
+
<Table.HeaderCell>
|
|
82
|
+
{t("analyticsTab.colAddToCarts")}
|
|
83
|
+
</Table.HeaderCell>
|
|
84
|
+
<Table.HeaderCell className="text-right">
|
|
85
|
+
{t("widget.activeBadge")}
|
|
86
|
+
</Table.HeaderCell>
|
|
87
|
+
</Table.Row>
|
|
88
|
+
</Table.Header>
|
|
89
|
+
<Table.Body>
|
|
90
|
+
{taggedSlides.map((slide) => (
|
|
91
|
+
<Table.Row key={slide.id}>
|
|
92
|
+
<Table.Cell>
|
|
93
|
+
<div className="flex items-center gap-x-3">
|
|
94
|
+
<div className="h-9 w-6 overflow-hidden rounded bg-ui-bg-subtle shrink-0">
|
|
95
|
+
<img
|
|
96
|
+
src={slide.thumbnail_url || slide.media_url}
|
|
97
|
+
alt={slide.title}
|
|
98
|
+
className="h-full w-full object-cover"
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<Text size="small" weight="plus">
|
|
102
|
+
{slide.title}
|
|
103
|
+
</Text>
|
|
104
|
+
</div>
|
|
105
|
+
</Table.Cell>
|
|
106
|
+
<Table.Cell>{slide.views_count}</Table.Cell>
|
|
107
|
+
<Table.Cell>{slide.clicks_count}</Table.Cell>
|
|
108
|
+
<Table.Cell>{slide.cart_conversions_count}</Table.Cell>
|
|
109
|
+
<Table.Cell className="text-right">
|
|
110
|
+
<StatusBadge color={slide.is_active ? "green" : "grey"}>
|
|
111
|
+
{slide.is_active
|
|
112
|
+
? t("widget.activeBadge")
|
|
113
|
+
: t("widget.pausedBadge")}
|
|
114
|
+
</StatusBadge>
|
|
115
|
+
</Table.Cell>
|
|
116
|
+
</Table.Row>
|
|
117
|
+
))}
|
|
118
|
+
</Table.Body>
|
|
119
|
+
</Table>
|
|
120
|
+
)}
|
|
121
|
+
</Container>
|
|
122
|
+
)
|
|
123
|
+
}
|