@base44/app-plugin-commerce 0.7.1 → 0.8.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.
- package/README.md +4 -10
- package/base44/entities/commerce.ProductReview.jsonc +2 -2
- package/base44/functions/commerce/storefront-catalog/entry.ts +7 -3
- package/package.json +1 -1
- package/scripts/install.js +2 -4
- package/skills/commerce/SKILL.md +9 -3
- package/skills/commerce/docs/api-storefront.md +3 -3
- package/skills/commerce/install/01-install.md +8 -24
- package/skills/commerce/install/02-storefront.md +21 -9
- package/skills/commerce/references/admin-localization.md +95 -0
- package/skills/commerce/references/reviews.md +7 -6
- package/src/commerce/admin/README.md +36 -14
- package/src/commerce/admin/bot/StoreAdminBot.jsx +12 -11
- package/src/commerce/admin/components/AddressForm.jsx +13 -12
- package/src/commerce/admin/components/ConfirmDialog.jsx +5 -4
- package/src/commerce/admin/components/CountrySelect.jsx +12 -8
- package/src/commerce/admin/components/DataTable.jsx +3 -2
- package/src/commerce/admin/components/DateRangePicker.jsx +11 -10
- package/src/commerce/admin/components/EmptyState.jsx +2 -1
- package/src/commerce/admin/components/MediaUploader.jsx +3 -2
- package/src/commerce/admin/components/MetaDataEditor.jsx +4 -3
- package/src/commerce/admin/components/SearchSelect.jsx +4 -3
- package/src/commerce/admin/context/SettingsContext.jsx +12 -25
- package/src/commerce/admin/hooks/useMoney.js +3 -2
- package/src/commerce/admin/i18n/index.js +54 -0
- package/src/commerce/admin/i18n/locales/de.js +896 -0
- package/src/commerce/admin/i18n/locales/en.js +900 -0
- package/src/commerce/admin/i18n/locales/es.js +896 -0
- package/src/commerce/admin/i18n/locales/fr.js +896 -0
- package/src/commerce/admin/i18n/locales/ja.js +896 -0
- package/src/commerce/admin/i18n/locales/pt.js +896 -0
- package/src/commerce/admin/index.jsx +6 -30
- package/src/commerce/admin/layout/AccessDenied.jsx +8 -9
- package/src/commerce/admin/layout/AuthGuard.jsx +2 -1
- package/src/commerce/admin/layout/Sidebar.jsx +29 -18
- package/src/commerce/admin/layout/Topbar.jsx +4 -3
- package/src/commerce/admin/lib/api.js +3 -2
- package/src/commerce/admin/lib/constants.js +44 -43
- package/src/commerce/admin/lib/format.js +4 -3
- package/src/commerce/admin/lib/paths.js +2 -3
- package/src/commerce/admin/pages/Dashboard.jsx +25 -24
- package/src/commerce/admin/pages/coupons/CouponEditor.jsx +55 -57
- package/src/commerce/admin/pages/coupons/CouponsList.jsx +22 -21
- package/src/commerce/admin/pages/customers/CustomerEditor.jsx +31 -30
- package/src/commerce/admin/pages/customers/CustomersList.jsx +19 -18
- package/src/commerce/admin/pages/orders/OrderEditor.jsx +75 -71
- package/src/commerce/admin/pages/orders/OrdersList.jsx +16 -15
- package/src/commerce/admin/pages/orders/components/AddProductDialog.jsx +12 -11
- package/src/commerce/admin/pages/orders/components/DownloadPermissionsPanel.jsx +14 -13
- package/src/commerce/admin/pages/orders/components/LineItemsTable.jsx +12 -11
- package/src/commerce/admin/pages/orders/components/OrderNotesPanel.jsx +11 -10
- package/src/commerce/admin/pages/orders/components/PaymentPanel.jsx +22 -22
- package/src/commerce/admin/pages/orders/components/RefundPanel.jsx +18 -17
- package/src/commerce/admin/pages/orders/components/TotalsBox.jsx +18 -17
- package/src/commerce/admin/pages/products/Categories.jsx +14 -13
- package/src/commerce/admin/pages/products/ProductEditor.jsx +16 -15
- package/src/commerce/admin/pages/products/ProductsList.jsx +41 -36
- package/src/commerce/admin/pages/products/Reviews.jsx +54 -46
- package/src/commerce/admin/pages/products/components/AttributesSection.jsx +45 -39
- package/src/commerce/admin/pages/products/components/ProductDataPanel.jsx +8 -7
- package/src/commerce/admin/pages/products/components/PublishBox.jsx +10 -9
- package/src/commerce/admin/pages/products/components/TaxonomyPanel.jsx +18 -17
- package/src/commerce/admin/pages/products/components/tabs/DownloadsTab.jsx +11 -10
- package/src/commerce/admin/pages/products/components/tabs/LinkedTab.jsx +9 -10
- package/src/commerce/admin/pages/products/components/tabs/ModifiersTab.jsx +3 -9
- package/src/commerce/admin/pages/products/components/tabs/PriceInventoryTab.jsx +76 -78
- package/src/commerce/admin/pages/reports/Reports.jsx +33 -32
- package/src/commerce/admin/pages/settings/EmailsSettings.jsx +36 -39
- package/src/commerce/admin/pages/settings/GeneralSettings.jsx +13 -14
- package/src/commerce/admin/pages/settings/InventorySettings.jsx +12 -13
- package/src/commerce/admin/pages/settings/LocationEditor.jsx +48 -47
- package/src/commerce/admin/pages/settings/PaymentsSettings.jsx +32 -33
- package/src/commerce/admin/pages/settings/SettingsLayout.jsx +13 -12
- package/src/commerce/admin/pages/settings/ShippingTaxSettings.jsx +31 -31
- package/src/commerce/admin/pages/settings/useGroupForm.jsx +4 -3
- package/src/commerce/admin/pages/status/WebhookEditor.jsx +34 -31
- package/src/commerce/admin/pages/status/Webhooks.jsx +11 -10
- package/src/commerce/admin/routes.jsx +31 -43
- package/src/commerce/storefront/pickers.jsx +19 -5
- package/src/commerce/storefront/useCheckout.jsx +28 -3
- package/src/commerce/utils/storefront.js +49 -2
|
@@ -15,11 +15,12 @@ import DataTable from "../../components/DataTable";
|
|
|
15
15
|
import ConfirmDialog from "../../components/ConfirmDialog";
|
|
16
16
|
import useMoney from "../../hooks/useMoney";
|
|
17
17
|
import { COUNTRIES, CONTINENTS } from "../../lib/geo-data";
|
|
18
|
+
import { t, countryName } from "../../i18n";
|
|
18
19
|
|
|
19
20
|
function regionLabel(region) {
|
|
20
21
|
if (region.type === "continent") return CONTINENTS.find((c) => c.code === region.code)?.name || region.code;
|
|
21
22
|
if (region.type === "state") return region.code;
|
|
22
|
-
return COUNTRIES.find((c) => c.code === region.code)?.name || region.code;
|
|
23
|
+
return countryName(region.code, COUNTRIES.find((c) => c.code === region.code)?.name || region.code);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -43,9 +44,9 @@ export default function ShippingTaxSettings() {
|
|
|
43
44
|
const setShippingEnabled = async (v) => {
|
|
44
45
|
try {
|
|
45
46
|
await settings.saveGroup("shipping", { ...(settings.settings?.shipping || {}), enable_shipping: v });
|
|
46
|
-
toast.success(v ? "
|
|
47
|
+
toast.success(v ? t("settings.shipping.enabled_toast") : t("settings.shipping.disabled_toast"));
|
|
47
48
|
} catch (e) {
|
|
48
|
-
toast.error(e.message || "
|
|
49
|
+
toast.error(e.message || t("settings.save_failed"));
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
52
|
|
|
@@ -54,14 +55,14 @@ export default function ShippingTaxSettings() {
|
|
|
54
55
|
const { id: _id, created_date: _cd, updated_date: _ud, created_by: _cb, ...fields } = row;
|
|
55
56
|
await base44.entities["commerce.ShippingTaxLocation"].create({
|
|
56
57
|
...fields,
|
|
57
|
-
name:
|
|
58
|
+
name: t("settings.shipping.copy_name", { name: row.name }),
|
|
58
59
|
// fresh rate ids — carts/orders reference rates by id, so a clone must not share them
|
|
59
60
|
shipping_rates: (row.shipping_rates || []).map((r) => ({ ...r, id: crypto.randomUUID() })),
|
|
60
61
|
});
|
|
61
|
-
toast.success("
|
|
62
|
+
toast.success(t("settings.shipping.location_cloned"));
|
|
62
63
|
refetch();
|
|
63
64
|
} catch (e) {
|
|
64
|
-
toast.error(e.message || "
|
|
65
|
+
toast.error(e.message || t("settings.shipping.clone_failed"));
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
68
|
|
|
@@ -69,11 +70,11 @@ export default function ShippingTaxSettings() {
|
|
|
69
70
|
setDeleting(true);
|
|
70
71
|
try {
|
|
71
72
|
await base44.entities["commerce.ShippingTaxLocation"].delete(confirmDelete.id);
|
|
72
|
-
toast.success("
|
|
73
|
+
toast.success(t("settings.shipping.location_deleted"));
|
|
73
74
|
setConfirmDelete(null);
|
|
74
75
|
refetch();
|
|
75
76
|
} catch (e) {
|
|
76
|
-
toast.error(e.message || "
|
|
77
|
+
toast.error(e.message || t("settings.shipping.delete_failed"));
|
|
77
78
|
} finally {
|
|
78
79
|
setDeleting(false);
|
|
79
80
|
}
|
|
@@ -82,7 +83,7 @@ export default function ShippingTaxSettings() {
|
|
|
82
83
|
const columns = [
|
|
83
84
|
{
|
|
84
85
|
key: "name",
|
|
85
|
-
label: "
|
|
86
|
+
label: t("settings.shipping.location"),
|
|
86
87
|
render: (row) => (
|
|
87
88
|
<div className="flex items-center gap-2">
|
|
88
89
|
{(row.regions || []).length ? (
|
|
@@ -96,28 +97,28 @@ export default function ShippingTaxSettings() {
|
|
|
96
97
|
},
|
|
97
98
|
{
|
|
98
99
|
key: "regions",
|
|
99
|
-
label: "
|
|
100
|
+
label: t("settings.shipping.regions"),
|
|
100
101
|
className: "hidden md:table-cell text-muted-foreground",
|
|
101
102
|
render: (row) => {
|
|
102
103
|
const regions = row.regions || [];
|
|
103
|
-
if (!regions.length) return "
|
|
104
|
+
if (!regions.length) return t("settings.shipping.everywhere_else");
|
|
104
105
|
const names = regions.slice(0, 3).map(regionLabel).join(", ");
|
|
105
106
|
return regions.length > 3 ? `${names} +${regions.length - 3}` : names;
|
|
106
107
|
},
|
|
107
108
|
},
|
|
108
109
|
{
|
|
109
110
|
key: "shipping",
|
|
110
|
-
label: "
|
|
111
|
+
label: t("settings.shipping.shipping_rates"),
|
|
111
112
|
className: "hidden lg:table-cell text-muted-foreground",
|
|
112
113
|
render: (row) => {
|
|
113
114
|
const rates = row.shipping_rates || [];
|
|
114
|
-
if (!rates.length) return "
|
|
115
|
-
return rates.map((r) => `${r.name || "
|
|
115
|
+
if (!rates.length) return t("settings.shipping.no_rates");
|
|
116
|
+
return rates.map((r) => `${r.name || t("settings.shipping.rate_fallback")} ${money.format(r.cost || 0)}`).join(" · ");
|
|
116
117
|
},
|
|
117
118
|
},
|
|
118
119
|
{
|
|
119
120
|
key: "tax",
|
|
120
|
-
label: "
|
|
121
|
+
label: t("settings.shipping.tax"),
|
|
121
122
|
className: "hidden lg:table-cell text-muted-foreground",
|
|
122
123
|
render: (row) => {
|
|
123
124
|
const groups = (row.tax_groups || []).filter((g) => (g.rates || []).some((r) => Number(r.rate) > 0));
|
|
@@ -127,11 +128,11 @@ export default function ShippingTaxSettings() {
|
|
|
127
128
|
if (row.shipping_tax?.value > 0) {
|
|
128
129
|
parts.push(
|
|
129
130
|
row.shipping_tax.type === "fixed"
|
|
130
|
-
?
|
|
131
|
-
:
|
|
131
|
+
? t("settings.shipping.shipping_amount", { amount: money.format(row.shipping_tax.value) })
|
|
132
|
+
: t("settings.shipping.shipping_amount", { amount: `${row.shipping_tax.value}%` })
|
|
132
133
|
);
|
|
133
134
|
}
|
|
134
|
-
return parts.length ? parts.join(" · ") : "
|
|
135
|
+
return parts.length ? parts.join(" · ") : t("settings.shipping.no_tax");
|
|
135
136
|
},
|
|
136
137
|
},
|
|
137
138
|
];
|
|
@@ -141,9 +142,9 @@ export default function ShippingTaxSettings() {
|
|
|
141
142
|
<Card>
|
|
142
143
|
<CardContent className="flex items-center justify-between gap-4 py-4">
|
|
143
144
|
<div>
|
|
144
|
-
<Label>
|
|
145
|
+
<Label>{t("settings.shipping.charge_shipping")}</Label>
|
|
145
146
|
<p className="text-xs text-muted-foreground">
|
|
146
|
-
|
|
147
|
+
{t("settings.shipping.charge_shipping_hint")}
|
|
147
148
|
</p>
|
|
148
149
|
</div>
|
|
149
150
|
<Switch checked={shippingEnabled} onCheckedChange={setShippingEnabled} />
|
|
@@ -152,12 +153,11 @@ export default function ShippingTaxSettings() {
|
|
|
152
153
|
|
|
153
154
|
<div className="flex items-center justify-between">
|
|
154
155
|
<p className="text-sm text-muted-foreground">
|
|
155
|
-
|
|
156
|
-
Each carries its own shipping rates and tax.
|
|
156
|
+
{t("settings.shipping.locations_intro")}
|
|
157
157
|
</p>
|
|
158
158
|
<Button onClick={() => navigate(href("settings/shipping-tax/new"))}>
|
|
159
159
|
<Plus className="mr-2 h-4 w-4" />
|
|
160
|
-
|
|
160
|
+
{t("settings.shipping.add_location")}
|
|
161
161
|
</Button>
|
|
162
162
|
</div>
|
|
163
163
|
|
|
@@ -166,23 +166,23 @@ export default function ShippingTaxSettings() {
|
|
|
166
166
|
rows={locations || []}
|
|
167
167
|
loading={loading}
|
|
168
168
|
rowActions={(row) => [
|
|
169
|
-
{ label: "
|
|
170
|
-
{ label: "
|
|
171
|
-
{ label: "
|
|
169
|
+
{ label: t("common.edit"), icon: Pencil, onClick: () => navigate(href(`settings/shipping-tax/${row.id}`)) },
|
|
170
|
+
{ label: t("settings.shipping.clone"), icon: Copy, onClick: () => clone(row) },
|
|
171
|
+
{ label: t("common.delete"), icon: Trash2, destructive: true, onClick: () => setConfirmDelete(row) },
|
|
172
172
|
]}
|
|
173
173
|
empty={{
|
|
174
174
|
icon: Globe,
|
|
175
|
-
title: "
|
|
176
|
-
description: "
|
|
175
|
+
title: t("settings.shipping.empty_title"),
|
|
176
|
+
description: t("settings.shipping.empty_description"),
|
|
177
177
|
}}
|
|
178
178
|
/>
|
|
179
179
|
|
|
180
180
|
<ConfirmDialog
|
|
181
181
|
open={Boolean(confirmDelete)}
|
|
182
182
|
onOpenChange={(o) => !o && setConfirmDelete(null)}
|
|
183
|
-
title={
|
|
184
|
-
description="
|
|
185
|
-
confirmLabel="
|
|
183
|
+
title={t("settings.shipping.delete_confirm_title", { name: confirmDelete?.name })}
|
|
184
|
+
description={t("settings.shipping.delete_confirm_description")}
|
|
185
|
+
confirmLabel={t("common.delete")}
|
|
186
186
|
onConfirm={doDelete}
|
|
187
187
|
loading={deleting}
|
|
188
188
|
/>
|
|
@@ -3,6 +3,7 @@ import { toast } from "sonner";
|
|
|
3
3
|
import { Button } from "@/components/ui/button";
|
|
4
4
|
import { Loader2 } from "lucide-react";
|
|
5
5
|
import { useSettings } from "../../context/SettingsContext";
|
|
6
|
+
import { t } from "../../i18n";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Standard form state for a StoreSettings group page.
|
|
@@ -46,10 +47,10 @@ export default function useGroupForm(group, defaults) {
|
|
|
46
47
|
setSaving(true);
|
|
47
48
|
try {
|
|
48
49
|
await saveGroup(group, override || form);
|
|
49
|
-
toast.success("
|
|
50
|
+
toast.success(t("settings.saved"));
|
|
50
51
|
setDirty(false);
|
|
51
52
|
} catch (err) {
|
|
52
|
-
toast.error(err.message || "
|
|
53
|
+
toast.error(err.message || t("settings.save_settings_failed"));
|
|
53
54
|
} finally {
|
|
54
55
|
setSaving(false);
|
|
55
56
|
}
|
|
@@ -65,7 +66,7 @@ export default function useGroupForm(group, defaults) {
|
|
|
65
66
|
return (
|
|
66
67
|
<Button size="sm" onClick={() => doSave()} disabled={!d || s}>
|
|
67
68
|
{s && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
68
|
-
|
|
69
|
+
{t("settings.save_changes")}
|
|
69
70
|
</Button>
|
|
70
71
|
);
|
|
71
72
|
},
|
|
@@ -21,6 +21,7 @@ import useAsync from "../../hooks/useAsync";
|
|
|
21
21
|
import { useAdminHref } from "../../context/BasePathContext";
|
|
22
22
|
import { WEBHOOK_STATUSES, WEBHOOK_TOPICS } from "../../lib/constants";
|
|
23
23
|
import { formatDateTime } from "../../lib/format";
|
|
24
|
+
import { t } from "../../i18n";
|
|
24
25
|
|
|
25
26
|
const blank = {
|
|
26
27
|
name: "",
|
|
@@ -56,7 +57,7 @@ export default function WebhookEditor() {
|
|
|
56
57
|
setLoading(true);
|
|
57
58
|
base44.entities["commerce.Webhook"].get(id)
|
|
58
59
|
.then((w) => !cancelled && w && setForm({ ...blank, ...w }))
|
|
59
|
-
.catch((err) => toast.error(err.message || "
|
|
60
|
+
.catch((err) => toast.error(err.message || t("webhooks.load_failed")))
|
|
60
61
|
.finally(() => !cancelled && setLoading(false));
|
|
61
62
|
return () => {
|
|
62
63
|
cancelled = true;
|
|
@@ -67,7 +68,7 @@ export default function WebhookEditor() {
|
|
|
67
68
|
|
|
68
69
|
const save = async () => {
|
|
69
70
|
if (!form.name.trim() || !form.delivery_url.trim()) {
|
|
70
|
-
toast.error("
|
|
71
|
+
toast.error(t("webhooks.name_url_required"));
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
setSaving(true);
|
|
@@ -85,14 +86,14 @@ export default function WebhookEditor() {
|
|
|
85
86
|
};
|
|
86
87
|
if (isNew) {
|
|
87
88
|
const created = await base44.entities["commerce.Webhook"].create(payload);
|
|
88
|
-
toast.success("
|
|
89
|
+
toast.success(t("webhooks.created_toast"));
|
|
89
90
|
navigate(href(`settings/webhooks/${created.id}`));
|
|
90
91
|
} else {
|
|
91
92
|
await base44.entities["commerce.Webhook"].update(id, payload);
|
|
92
|
-
toast.success("
|
|
93
|
+
toast.success(t("webhooks.saved"));
|
|
93
94
|
}
|
|
94
95
|
} catch (err) {
|
|
95
|
-
toast.error(err.message || "
|
|
96
|
+
toast.error(err.message || t("webhooks.save_failed"));
|
|
96
97
|
} finally {
|
|
97
98
|
setSaving(false);
|
|
98
99
|
}
|
|
@@ -102,10 +103,10 @@ export default function WebhookEditor() {
|
|
|
102
103
|
setDeleting(true);
|
|
103
104
|
try {
|
|
104
105
|
await base44.entities["commerce.Webhook"].delete(id);
|
|
105
|
-
toast.success("
|
|
106
|
+
toast.success(t("webhooks.deleted"));
|
|
106
107
|
navigate(href("settings/webhooks"));
|
|
107
108
|
} catch (err) {
|
|
108
|
-
toast.error(err.message || "
|
|
109
|
+
toast.error(err.message || t("webhooks.delete_failed"));
|
|
109
110
|
setDeleting(false);
|
|
110
111
|
}
|
|
111
112
|
};
|
|
@@ -115,7 +116,7 @@ export default function WebhookEditor() {
|
|
|
115
116
|
try {
|
|
116
117
|
const res = await call("admin-webhooks", "test", { webhook_id: id });
|
|
117
118
|
const code = res?.response_code ?? res?.delivery?.response_code;
|
|
118
|
-
toast.success(code ?
|
|
119
|
+
toast.success(code ? t("webhooks.test_delivered_code", { code }) : t("webhooks.test_delivered"));
|
|
119
120
|
} catch {
|
|
120
121
|
/* call() already toasts */
|
|
121
122
|
} finally {
|
|
@@ -134,17 +135,17 @@ export default function WebhookEditor() {
|
|
|
134
135
|
return (
|
|
135
136
|
<div className="max-w-3xl space-y-4">
|
|
136
137
|
<PageHeader
|
|
137
|
-
title={isNew ? "
|
|
138
|
+
title={isNew ? t("routes.webhooks_new") : t("webhooks.edit_title")}
|
|
138
139
|
backHref={href("settings/webhooks")}
|
|
139
140
|
actions={
|
|
140
141
|
!isNew && (
|
|
141
142
|
<>
|
|
142
143
|
<Button variant="outline" onClick={sendTest} disabled={testing}>
|
|
143
144
|
{testing ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : <Send className="mr-2 h-4 w-4" />}
|
|
144
|
-
|
|
145
|
+
{t("webhooks.send_test")}
|
|
145
146
|
</Button>
|
|
146
147
|
<Button variant="outline" className="text-destructive" onClick={() => setConfirmDelete(true)}>
|
|
147
|
-
|
|
148
|
+
{t("common.delete")}
|
|
148
149
|
</Button>
|
|
149
150
|
</>
|
|
150
151
|
)
|
|
@@ -153,15 +154,15 @@ export default function WebhookEditor() {
|
|
|
153
154
|
|
|
154
155
|
<Card>
|
|
155
156
|
<CardHeader>
|
|
156
|
-
<CardTitle>
|
|
157
|
+
<CardTitle>{t("webhooks.details")}</CardTitle>
|
|
157
158
|
</CardHeader>
|
|
158
159
|
<CardContent className="grid gap-4 sm:grid-cols-2">
|
|
159
160
|
<div className="space-y-1.5 sm:col-span-2">
|
|
160
|
-
<Label>
|
|
161
|
+
<Label>{t("common.name")}</Label>
|
|
161
162
|
<Input value={form.name} onChange={(e) => set("name", e.target.value)} />
|
|
162
163
|
</div>
|
|
163
164
|
<div className="space-y-1.5">
|
|
164
|
-
<Label>
|
|
165
|
+
<Label>{t("common.status")}</Label>
|
|
165
166
|
<Select value={form.status} onValueChange={(v) => set("status", v)}>
|
|
166
167
|
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
167
168
|
<SelectContent>
|
|
@@ -172,29 +173,31 @@ export default function WebhookEditor() {
|
|
|
172
173
|
</Select>
|
|
173
174
|
</div>
|
|
174
175
|
<div className="space-y-1.5">
|
|
175
|
-
<Label>
|
|
176
|
+
<Label>{t("webhooks.topic")}</Label>
|
|
176
177
|
<Select value={form.topic} onValueChange={(v) => set("topic", v)}>
|
|
177
178
|
<SelectTrigger><SelectValue /></SelectTrigger>
|
|
178
179
|
<SelectContent>
|
|
179
|
-
{WEBHOOK_TOPICS.map((
|
|
180
|
-
<SelectItem key={
|
|
180
|
+
{WEBHOOK_TOPICS.map((topic) => (
|
|
181
|
+
<SelectItem key={topic} value={topic}>{topic}</SelectItem>
|
|
181
182
|
))}
|
|
182
183
|
</SelectContent>
|
|
183
184
|
</Select>
|
|
184
185
|
</div>
|
|
185
186
|
<div className="space-y-1.5 sm:col-span-2">
|
|
186
|
-
<Label>
|
|
187
|
+
<Label>{t("webhooks.delivery_url")}</Label>
|
|
187
188
|
<Input placeholder="https://example.com/webhooks/incoming" value={form.delivery_url} onChange={(e) => set("delivery_url", e.target.value)} />
|
|
188
189
|
</div>
|
|
189
190
|
<div className="space-y-1.5 sm:col-span-2">
|
|
190
|
-
<Label>
|
|
191
|
+
<Label>{t("webhooks.secret")}</Label>
|
|
191
192
|
<div className="flex gap-2">
|
|
192
|
-
<Input value={form.secret} onChange={(e) => set("secret", e.target.value)} placeholder="
|
|
193
|
-
<Button variant="outline" type="button" onClick={() => set("secret", genSecret())}>
|
|
193
|
+
<Input value={form.secret} onChange={(e) => set("secret", e.target.value)} placeholder={t("webhooks.secret_placeholder")} />
|
|
194
|
+
<Button variant="outline" type="button" onClick={() => set("secret", genSecret())}>
|
|
195
|
+
{t("webhooks.generate")}
|
|
196
|
+
</Button>
|
|
194
197
|
</div>
|
|
195
198
|
</div>
|
|
196
199
|
<div className="space-y-1.5">
|
|
197
|
-
<Label>
|
|
200
|
+
<Label>{t("webhooks.api_version")}</Label>
|
|
198
201
|
<Input value={form.api_version} disabled />
|
|
199
202
|
</div>
|
|
200
203
|
</CardContent>
|
|
@@ -203,7 +206,7 @@ export default function WebhookEditor() {
|
|
|
203
206
|
<div>
|
|
204
207
|
<Button onClick={save} disabled={saving}>
|
|
205
208
|
{saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
206
|
-
{isNew ? "
|
|
209
|
+
{isNew ? t("webhooks.create") : t("settings.save_changes")}
|
|
207
210
|
</Button>
|
|
208
211
|
</div>
|
|
209
212
|
|
|
@@ -212,8 +215,8 @@ export default function WebhookEditor() {
|
|
|
212
215
|
<ConfirmDialog
|
|
213
216
|
open={confirmDelete}
|
|
214
217
|
onOpenChange={setConfirmDelete}
|
|
215
|
-
title="
|
|
216
|
-
confirmLabel="
|
|
218
|
+
title={t("webhooks.delete_confirm")}
|
|
219
|
+
confirmLabel={t("common.delete")}
|
|
217
220
|
loading={deleting}
|
|
218
221
|
onConfirm={remove}
|
|
219
222
|
/>
|
|
@@ -233,7 +236,7 @@ function DeliveriesCard({ webhookId }) {
|
|
|
233
236
|
setRedelivering(deliveryId);
|
|
234
237
|
try {
|
|
235
238
|
await call("admin-webhooks", "redeliver", { delivery_id: deliveryId });
|
|
236
|
-
toast.success("
|
|
239
|
+
toast.success(t("webhooks.redelivered"));
|
|
237
240
|
deliveries.refetch();
|
|
238
241
|
} catch {
|
|
239
242
|
/* toasted */
|
|
@@ -245,12 +248,12 @@ function DeliveriesCard({ webhookId }) {
|
|
|
245
248
|
return (
|
|
246
249
|
<Card>
|
|
247
250
|
<CardHeader>
|
|
248
|
-
<CardTitle>
|
|
251
|
+
<CardTitle>{t("webhooks.recent_deliveries")}</CardTitle>
|
|
249
252
|
</CardHeader>
|
|
250
253
|
<CardContent className="space-y-2">
|
|
251
254
|
{deliveries.loading && <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />}
|
|
252
255
|
{!deliveries.loading && (deliveries.data || []).length === 0 && (
|
|
253
|
-
<p className="text-sm text-muted-foreground">
|
|
256
|
+
<p className="text-sm text-muted-foreground">{t("webhooks.no_deliveries")}</p>
|
|
254
257
|
)}
|
|
255
258
|
{(deliveries.data || []).map((d) => {
|
|
256
259
|
const open = expanded === d.id;
|
|
@@ -274,16 +277,16 @@ function DeliveriesCard({ webhookId }) {
|
|
|
274
277
|
{open && (
|
|
275
278
|
<div className="space-y-2 border-t px-3 py-2 text-xs">
|
|
276
279
|
<div>
|
|
277
|
-
<div className="mb-1 font-medium">
|
|
280
|
+
<div className="mb-1 font-medium">{t("webhooks.request")}</div>
|
|
278
281
|
<pre className="max-h-48 overflow-auto rounded bg-muted p-2">{d.request_body || "—"}</pre>
|
|
279
282
|
</div>
|
|
280
283
|
<div>
|
|
281
|
-
<div className="mb-1 font-medium">
|
|
284
|
+
<div className="mb-1 font-medium">{t("webhooks.response")}</div>
|
|
282
285
|
<pre className="max-h-48 overflow-auto rounded bg-muted p-2">{d.response_body || "—"}</pre>
|
|
283
286
|
</div>
|
|
284
287
|
<Button size="sm" variant="outline" disabled={redelivering === d.id} onClick={() => redeliver(d.id)}>
|
|
285
288
|
{redelivering === d.id && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
286
|
-
|
|
289
|
+
{t("webhooks.redeliver")}
|
|
287
290
|
</Button>
|
|
288
291
|
</div>
|
|
289
292
|
)}
|
|
@@ -10,6 +10,7 @@ import useAsync from "../../hooks/useAsync";
|
|
|
10
10
|
import { useAdminHref } from "../../context/BasePathContext";
|
|
11
11
|
import { WEBHOOK_STATUSES } from "../../lib/constants";
|
|
12
12
|
import { formatDate } from "../../lib/format";
|
|
13
|
+
import { t } from "../../i18n";
|
|
13
14
|
|
|
14
15
|
export default function Webhooks() {
|
|
15
16
|
const navigate = useNavigate();
|
|
@@ -17,27 +18,27 @@ export default function Webhooks() {
|
|
|
17
18
|
const hooks = useAsync(() => base44.entities["commerce.Webhook"].list("-created_date", 200), []);
|
|
18
19
|
|
|
19
20
|
const columns = [
|
|
20
|
-
{ key: "name", label: "
|
|
21
|
-
{ key: "status", label: "
|
|
22
|
-
{ key: "topic", label: "
|
|
21
|
+
{ key: "name", label: t("common.name"), render: (w) => <span className="font-medium">{w.name}</span> },
|
|
22
|
+
{ key: "status", label: t("common.status"), render: (w) => <StatusBadge status={w.status} map={WEBHOOK_STATUSES} /> },
|
|
23
|
+
{ key: "topic", label: t("webhooks.topic"), render: (w) => <code className="text-xs">{w.topic}</code> },
|
|
23
24
|
{
|
|
24
25
|
key: "delivery_url",
|
|
25
|
-
label: "
|
|
26
|
+
label: t("webhooks.delivery_url"),
|
|
26
27
|
render: (w) => <span className="block max-w-xs truncate text-sm text-muted-foreground">{w.delivery_url}</span>,
|
|
27
28
|
},
|
|
28
|
-
{ key: "failure_count", label: "
|
|
29
|
-
{ key: "created_date", label: "
|
|
29
|
+
{ key: "failure_count", label: t("webhooks.failures"), render: (w) => w.failure_count ?? 0 },
|
|
30
|
+
{ key: "created_date", label: t("webhooks.created"), render: (w) => formatDate(w.created_date) },
|
|
30
31
|
];
|
|
31
32
|
|
|
32
33
|
return (
|
|
33
34
|
<div className="space-y-4">
|
|
34
35
|
<PageHeader
|
|
35
|
-
title="
|
|
36
|
-
description="
|
|
36
|
+
title={t("routes.settings_webhooks")}
|
|
37
|
+
description={t("webhooks.description")}
|
|
37
38
|
actions={
|
|
38
39
|
<Button onClick={() => navigate(href("settings/webhooks/new"))}>
|
|
39
40
|
<Plus className="mr-2 h-4 w-4" />
|
|
40
|
-
|
|
41
|
+
{t("routes.webhooks_new")}
|
|
41
42
|
</Button>
|
|
42
43
|
}
|
|
43
44
|
/>
|
|
@@ -46,7 +47,7 @@ export default function Webhooks() {
|
|
|
46
47
|
rows={hooks.data || []}
|
|
47
48
|
loading={hooks.loading}
|
|
48
49
|
onRowClick={(w) => navigate(href(`settings/webhooks/${w.id}`))}
|
|
49
|
-
empty={{ icon: WebhookIcon, title: "
|
|
50
|
+
empty={{ icon: WebhookIcon, title: t("webhooks.empty_title"), description: t("webhooks.empty_description") }}
|
|
50
51
|
/>
|
|
51
52
|
</div>
|
|
52
53
|
);
|
|
@@ -4,6 +4,7 @@ import { PackageX } from "lucide-react";
|
|
|
4
4
|
|
|
5
5
|
import { useAdminHref } from "./context/BasePathContext";
|
|
6
6
|
import { isMountPatternPath } from "./lib/paths";
|
|
7
|
+
import { t } from "./i18n";
|
|
7
8
|
|
|
8
9
|
import Dashboard from "./pages/Dashboard";
|
|
9
10
|
import OrdersList from "./pages/orders/OrdersList";
|
|
@@ -32,32 +33,32 @@ import WebhookEditor from "./pages/status/WebhookEditor";
|
|
|
32
33
|
* Used by the router below and by Topbar breadcrumbs.
|
|
33
34
|
*/
|
|
34
35
|
export const ADMIN_ROUTES = [
|
|
35
|
-
{ path: "", label: "
|
|
36
|
-
{ path: "orders", label: "
|
|
37
|
-
{ path: "orders/new", label: "
|
|
38
|
-
{ path: "orders/:id", label: "
|
|
39
|
-
{ path: "products", label: "
|
|
40
|
-
{ path: "products/new", label: "
|
|
41
|
-
{ path: "products/categories", label: "
|
|
42
|
-
{ path: "products/reviews", label: "
|
|
43
|
-
{ path: "products/:id", label: "
|
|
44
|
-
{ path: "coupons", label: "
|
|
45
|
-
{ path: "coupons/new", label: "
|
|
46
|
-
{ path: "coupons/:id", label: "
|
|
47
|
-
{ path: "customers", label: "
|
|
48
|
-
{ path: "customers/new", label: "
|
|
49
|
-
{ path: "customers/:id", label: "
|
|
50
|
-
{ path: "reports", label: "
|
|
51
|
-
{ path: "settings", label: "
|
|
52
|
-
{ path: "settings/general", label: "
|
|
53
|
-
{ path: "settings/inventory", label: "
|
|
54
|
-
{ path: "settings/shipping-tax", label: "
|
|
55
|
-
{ path: "settings/shipping-tax/:locationId", label: "
|
|
56
|
-
{ path: "settings/payments", label: "
|
|
57
|
-
{ path: "settings/emails", label: "
|
|
58
|
-
{ path: "settings/webhooks", label: "
|
|
59
|
-
{ path: "settings/webhooks/new", label: "
|
|
60
|
-
{ path: "settings/webhooks/:id", label: "
|
|
36
|
+
{ path: "", label: t("routes.dashboard") },
|
|
37
|
+
{ path: "orders", label: t("routes.orders") },
|
|
38
|
+
{ path: "orders/new", label: t("routes.orders_new") },
|
|
39
|
+
{ path: "orders/:id", label: t("routes.order") },
|
|
40
|
+
{ path: "products", label: t("routes.products") },
|
|
41
|
+
{ path: "products/new", label: t("routes.products_new") },
|
|
42
|
+
{ path: "products/categories", label: t("routes.categories") },
|
|
43
|
+
{ path: "products/reviews", label: t("routes.reviews") },
|
|
44
|
+
{ path: "products/:id", label: t("routes.products_edit") },
|
|
45
|
+
{ path: "coupons", label: t("routes.coupons") },
|
|
46
|
+
{ path: "coupons/new", label: t("routes.coupons_new") },
|
|
47
|
+
{ path: "coupons/:id", label: t("routes.coupons_edit") },
|
|
48
|
+
{ path: "customers", label: t("routes.customers") },
|
|
49
|
+
{ path: "customers/new", label: t("routes.customers_new") },
|
|
50
|
+
{ path: "customers/:id", label: t("routes.customer") },
|
|
51
|
+
{ path: "reports", label: t("routes.reports") },
|
|
52
|
+
{ path: "settings", label: t("routes.settings") },
|
|
53
|
+
{ path: "settings/general", label: t("routes.settings_general") },
|
|
54
|
+
{ path: "settings/inventory", label: t("routes.settings_inventory") },
|
|
55
|
+
{ path: "settings/shipping-tax", label: t("routes.settings_shipping_tax") },
|
|
56
|
+
{ path: "settings/shipping-tax/:locationId", label: t("routes.settings_location") },
|
|
57
|
+
{ path: "settings/payments", label: t("routes.settings_payments") },
|
|
58
|
+
{ path: "settings/emails", label: t("routes.settings_emails") },
|
|
59
|
+
{ path: "settings/webhooks", label: t("routes.settings_webhooks") },
|
|
60
|
+
{ path: "settings/webhooks/new", label: t("routes.webhooks_new") },
|
|
61
|
+
{ path: "settings/webhooks/:id", label: t("routes.webhook") },
|
|
61
62
|
];
|
|
62
63
|
|
|
63
64
|
function NotFound() {
|
|
@@ -66,12 +67,12 @@ function NotFound() {
|
|
|
66
67
|
return (
|
|
67
68
|
<div className="flex flex-col items-center justify-center py-24 text-center">
|
|
68
69
|
<PackageX className="mb-3 h-10 w-10 text-muted-foreground/50" />
|
|
69
|
-
<h2 className="text-lg font-semibold">
|
|
70
|
+
<h2 className="text-lg font-semibold">{t("notfound.title")}</h2>
|
|
70
71
|
<p className="text-sm text-muted-foreground">
|
|
71
|
-
<span className="font-mono">{pathname}</span>
|
|
72
|
+
<span className="font-mono">{pathname}</span> — {t("notfound.description")}
|
|
72
73
|
</p>
|
|
73
74
|
<Link to={href()} className="mt-4 text-sm font-medium underline">
|
|
74
|
-
|
|
75
|
+
{t("notfound.back")}
|
|
75
76
|
</Link>
|
|
76
77
|
</div>
|
|
77
78
|
);
|
|
@@ -91,20 +92,7 @@ function UnmatchedRoute() {
|
|
|
91
92
|
return isMountPatternPath(params["*"]) ? <Navigate to={href()} replace /> : <NotFound />;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
/**
|
|
95
|
-
* Every admin route, matched relative to the mount point.
|
|
96
|
-
*
|
|
97
|
-
* The app's `src/App.jsx` declares the handful of screens that should be listed
|
|
98
|
-
* among the app's pages — discovery only sees literal `<Route>` JSX in that file —
|
|
99
|
-
* and sends the rest here on a splat: `<Route path="*" element={<AdminRoutes />} />`.
|
|
100
|
-
* A descendant `<Routes>` needs exactly that trailing splat to resolve against.
|
|
101
|
-
* The overlap is deliberate: a path declared in App.jsx wins there, and the same
|
|
102
|
-
* entry here keeps this table complete for anything App.jsx does not name —
|
|
103
|
-
* `orders/:id` and the settings tabs among them.
|
|
104
|
-
*
|
|
105
|
-
* With no splat and no children at all — an install predating the move into
|
|
106
|
-
* App.jsx — `index.jsx` renders this component directly instead.
|
|
107
|
-
*/
|
|
95
|
+
/** All admin routes. Rendered inside AdminLayout; mount AdminApp at `/store-admin/*`. */
|
|
108
96
|
export default function AdminRoutes() {
|
|
109
97
|
return (
|
|
110
98
|
<Routes>
|
|
@@ -50,12 +50,20 @@ function resolveCheckout(name, prop, ctx) {
|
|
|
50
50
|
* chosen the chosen/auto-selected entry, or null
|
|
51
51
|
* selected alias of `chosen` (the name the payment picker uses)
|
|
52
52
|
* choose (id) => Promise
|
|
53
|
-
* mustChoose
|
|
53
|
+
* mustChoose more than one method → render methods as a picker
|
|
54
54
|
* single exactly one method offered — already chosen
|
|
55
|
+
* choosing a pick is in flight — `selected` already reflects it
|
|
55
56
|
* syncing an address edit is being repriced
|
|
56
57
|
* hint { code, severity, serverMessage } | null (see above)
|
|
57
58
|
* addressError { code, message } | null — the server's own words
|
|
58
59
|
*
|
|
60
|
+
* `mustChoose` stays true after a choice is made — with several methods the
|
|
61
|
+
* radios keep rendering, the chosen one checked, so the customer can change
|
|
62
|
+
* their mind; collapsing a made choice to static text strands it. A pick
|
|
63
|
+
* reflects in `selected` from the click (optimistically, while the priced view
|
|
64
|
+
* catches up), so never disable the options while `choosing`/`syncing` — the
|
|
65
|
+
* hint line is the affordance for that, not a locked control.
|
|
66
|
+
*
|
|
59
67
|
* `single` and `mustChoose` are never both true, and `single` guarantees
|
|
60
68
|
* `chosen` — a single option still *shows* what it is (title + `costLabel`),
|
|
61
69
|
* never a picker of one. Never render `cart.chosen_shipping_method` directly:
|
|
@@ -70,6 +78,7 @@ export function ShippingMethodPicker({ checkout: checkoutProp, children }) {
|
|
|
70
78
|
chosenShippingMethod: chosen,
|
|
71
79
|
singleShippingMethod: single,
|
|
72
80
|
chooseShippingMethod: choose,
|
|
81
|
+
shippingChoicePending: choosing,
|
|
73
82
|
shippingSyncing: syncing,
|
|
74
83
|
addressError,
|
|
75
84
|
} = checkout;
|
|
@@ -96,8 +105,11 @@ export function ShippingMethodPicker({ checkout: checkoutProp, children }) {
|
|
|
96
105
|
chosen: decoratedChosen,
|
|
97
106
|
selected: decoratedChosen,
|
|
98
107
|
choose,
|
|
99
|
-
|
|
108
|
+
// True whenever there is a real choice — including after one is made, so a
|
|
109
|
+
// made choice stays changeable instead of collapsing to static text.
|
|
110
|
+
mustChoose: status === "choice_required" || methods.length > 1,
|
|
100
111
|
single: single ?? (methods.length === 1), // fallback: a hand-built checkout object
|
|
112
|
+
choosing: choosing ?? false,
|
|
101
113
|
syncing,
|
|
102
114
|
hint,
|
|
103
115
|
addressError,
|
|
@@ -119,9 +131,11 @@ export function ShippingMethodPicker({ checkout: checkoutProp, children }) {
|
|
|
119
131
|
*
|
|
120
132
|
* `single` guarantees `value` and `selected` — never render the one-gateway
|
|
121
133
|
* branch as "nothing selected yet" — and both re-resolve when store info
|
|
122
|
-
* changes. A
|
|
123
|
-
*
|
|
124
|
-
*
|
|
134
|
+
* changes. A pick is plain local state: it reflects the instant it is clicked,
|
|
135
|
+
* with no server round trip — so never disable these options while the cart is
|
|
136
|
+
* repricing elsewhere. A default-seeded store offers `offline` only, so never
|
|
137
|
+
* hardcode a card option. Titles and descriptions are the admin's copy: render
|
|
138
|
+
* them, don't invent your own.
|
|
125
139
|
*/
|
|
126
140
|
export function PaymentMethodPicker({ checkout: checkoutProp, children }) {
|
|
127
141
|
const checkout = resolveCheckout("PaymentMethodPicker", checkoutProp, useCheckoutContextOptional());
|