@fluid-app/portal-sdk 0.1.154 → 0.1.156
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/dist/{ContactsScreen-Dy9coizh.cjs → ContactsScreen-BKQk5wU5.cjs} +2 -2
- package/dist/{ContactsScreen-Djvyn4Rq.cjs → ContactsScreen-Ck5NCh9d.cjs} +3 -3
- package/dist/{ContactsScreen-Djvyn4Rq.cjs.map → ContactsScreen-Ck5NCh9d.cjs.map} +1 -1
- package/dist/{ContactsScreen-BKT7Ohfe.mjs → ContactsScreen-CmnKU--w.mjs} +3 -3
- package/dist/{ContactsScreen-BKT7Ohfe.mjs.map → ContactsScreen-CmnKU--w.mjs.map} +1 -1
- package/dist/{FluidProvider-CRMe-Enf.cjs → FluidProvider-Bc-3uN7M.cjs} +151 -19
- package/dist/FluidProvider-Bc-3uN7M.cjs.map +1 -0
- package/dist/{FluidProvider-DpET43hN.mjs → FluidProvider-Cqf2kmUc.mjs} +137 -5
- package/dist/FluidProvider-Cqf2kmUc.mjs.map +1 -0
- package/dist/{MessagingScreen-DXgDrzlG.mjs → MessagingScreen-B1MbKdSO.mjs} +2 -2
- package/dist/{MessagingScreen-DXgDrzlG.mjs.map → MessagingScreen-B1MbKdSO.mjs.map} +1 -1
- package/dist/{MessagingScreen-cxQADd91.cjs → MessagingScreen-lAO4PVqi.cjs} +2 -2
- package/dist/{MessagingScreen-cxQADd91.cjs.map → MessagingScreen-lAO4PVqi.cjs.map} +1 -1
- package/dist/{MessagingScreen-ChCBVO4U.cjs → MessagingScreen-s9HaMQGR.cjs} +4 -3
- package/dist/{MySiteScreen-gl8KGOrU.mjs → MySiteScreen-BEbj9K8U.mjs} +262 -602
- package/dist/MySiteScreen-BEbj9K8U.mjs.map +1 -0
- package/dist/{MySiteScreen-CdsAyh7a.cjs → MySiteScreen-D8YvEYwH.cjs} +262 -611
- package/dist/MySiteScreen-D8YvEYwH.cjs.map +1 -0
- package/dist/{MySiteScreen-efkpTcUh.cjs → MySiteScreen-DIbwHNbV.cjs} +2 -1
- package/dist/{OrdersScreen-C0HGsjwv.mjs → OrdersScreen-CSbbQw2L.mjs} +2 -2
- package/dist/{OrdersScreen-C0HGsjwv.mjs.map → OrdersScreen-CSbbQw2L.mjs.map} +1 -1
- package/dist/{OrdersScreen-Dbmbf9g_.cjs → OrdersScreen-DLjDPnqI.cjs} +2 -2
- package/dist/{OrdersScreen-Dbmbf9g_.cjs.map → OrdersScreen-DLjDPnqI.cjs.map} +1 -1
- package/dist/{OrdersScreen-dNALJLm3.cjs → OrdersScreen-Dxv6ZQlu.cjs} +1 -1
- package/dist/{ProductsScreen-H-8HShV5.mjs → ProductsScreen-CcRQhx0c.mjs} +2 -2
- package/dist/{ProductsScreen-H-8HShV5.mjs.map → ProductsScreen-CcRQhx0c.mjs.map} +1 -1
- package/dist/{ProductsScreen-CfcVBUZ8.cjs → ProductsScreen-DTBg7Bm3.cjs} +2 -2
- package/dist/{ProductsScreen-CfcVBUZ8.cjs.map → ProductsScreen-DTBg7Bm3.cjs.map} +1 -1
- package/dist/{ProductsScreen-Dcnp0MG-.mjs → ProductsScreen-MADYD0MH.mjs} +5 -4
- package/dist/{ProductsScreen-BJ2ZUaPi.cjs → ProductsScreen-NmOdT82w.cjs} +5 -4
- package/dist/{ProfileScreen-CaNQYd_F.mjs → ProfileScreen-BcCYQt5U.mjs} +4 -4
- package/dist/{ProfileScreen-CaNQYd_F.mjs.map → ProfileScreen-BcCYQt5U.mjs.map} +1 -1
- package/dist/{ProfileScreen-BRPBvvI7.cjs → ProfileScreen-C01vRpm3.cjs} +4 -3
- package/dist/{ProfileScreen-D4OJk9F0.cjs → ProfileScreen-fmUckcMP.cjs} +4 -4
- package/dist/{ProfileScreen-D4OJk9F0.cjs.map → ProfileScreen-fmUckcMP.cjs.map} +1 -1
- package/dist/{ShareablesScreen-CL6A1m_P.cjs → ShareablesScreen-BMxugV_y.cjs} +5 -4
- package/dist/{ShareablesScreen-FDOtQ67f.mjs → ShareablesScreen-BkVWntLq.mjs} +5 -4
- package/dist/{ShareablesScreen-DLz5tvRS.cjs → ShareablesScreen-DmtFkpDO.cjs} +2 -2
- package/dist/{ShareablesScreen-DLz5tvRS.cjs.map → ShareablesScreen-DmtFkpDO.cjs.map} +1 -1
- package/dist/{ShareablesScreen-CtK4S7FT.mjs → ShareablesScreen-WW2uw8wV.mjs} +2 -2
- package/dist/{ShareablesScreen-CtK4S7FT.mjs.map → ShareablesScreen-WW2uw8wV.mjs.map} +1 -1
- package/dist/{ShopScreen-Bj3PjrVi.cjs → ShopScreen-BeBh8oUd.cjs} +3 -3
- package/dist/{ShopScreen-Bj3PjrVi.cjs.map → ShopScreen-BeBh8oUd.cjs.map} +1 -1
- package/dist/{ShopScreen-CKidhX9F.cjs → ShopScreen-D2DmHW7P.cjs} +4 -3
- package/dist/{ShopScreen-DDscuexZ.mjs → ShopScreen-DQDOi7Xn.mjs} +3 -3
- package/dist/{ShopScreen-DDscuexZ.mjs.map → ShopScreen-DQDOi7Xn.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-Cu9Fc98m.mjs → SubscriptionsScreen-3u1tEn1b.mjs} +2 -2
- package/dist/{SubscriptionsScreen-Cu9Fc98m.mjs.map → SubscriptionsScreen-3u1tEn1b.mjs.map} +1 -1
- package/dist/{SubscriptionsScreen-DHg2Y0Vk.cjs → SubscriptionsScreen-D0gK60uD.cjs} +1 -1
- package/dist/{SubscriptionsScreen-RaocKuQG.cjs → SubscriptionsScreen-DQt1YUAH.cjs} +2 -2
- package/dist/{SubscriptionsScreen-RaocKuQG.cjs.map → SubscriptionsScreen-DQt1YUAH.cjs.map} +1 -1
- package/dist/{countries-api-context-EEnpUpp2.cjs → countries-api-context-CwUkJTdy.cjs} +1 -1
- package/dist/{countries-api-context-EEnpUpp2.cjs.map → countries-api-context-CwUkJTdy.cjs.map} +1 -1
- package/dist/{countries-api-context-esV7AdsB.mjs → countries-api-context-D0dubtHy.mjs} +1 -1
- package/dist/{countries-api-context-esV7AdsB.mjs.map → countries-api-context-D0dubtHy.mjs.map} +1 -1
- package/dist/index.cjs +31 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -25
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -25
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -30
- package/dist/index.mjs.map +1 -1
- package/dist/mysite-api-context-BTt-_urb.cjs +25 -0
- package/dist/mysite-api-context-BTt-_urb.cjs.map +1 -0
- package/dist/mysite-api-context-C7eiw7TO.mjs +13 -0
- package/dist/mysite-api-context-C7eiw7TO.mjs.map +1 -0
- package/dist/{parse-api-errors-DLWVAkAd.mjs → parse-api-errors-D8PITFLg.mjs} +1 -1
- package/dist/{parse-api-errors-DLWVAkAd.mjs.map → parse-api-errors-D8PITFLg.mjs.map} +1 -1
- package/dist/{parse-api-errors-J6VflWm8.cjs → parse-api-errors-pw_TZf_b.cjs} +1 -1
- package/dist/{parse-api-errors-J6VflWm8.cjs.map → parse-api-errors-pw_TZf_b.cjs.map} +1 -1
- package/dist/{portal_tenant-DTIfG6m4.cjs → portal_tenant-CSxWYAH-.cjs} +1 -1
- package/dist/{portal_tenant-DTIfG6m4.cjs.map → portal_tenant-CSxWYAH-.cjs.map} +1 -1
- package/dist/{portal_tenant-S57LBMo6.mjs → portal_tenant-Taa7uJwV.mjs} +1 -1
- package/dist/{portal_tenant-S57LBMo6.mjs.map → portal_tenant-Taa7uJwV.mjs.map} +1 -1
- package/dist/{use-portal-products-client-DGYbhJLC.mjs → use-portal-products-client-CChGsvZI.mjs} +2 -2
- package/dist/{use-portal-products-client-DGYbhJLC.mjs.map → use-portal-products-client-CChGsvZI.mjs.map} +1 -1
- package/dist/{use-portal-products-client-CkehVVCL.cjs → use-portal-products-client-mpdZuZyu.cjs} +2 -2
- package/dist/{use-portal-products-client-CkehVVCL.cjs.map → use-portal-products-client-mpdZuZyu.cjs.map} +1 -1
- package/dist/{use-portal-shareables-api-BpQpcPcx.cjs → use-portal-shareables-api-CZ4ELYei.cjs} +3 -3
- package/dist/{use-portal-shareables-api-BpQpcPcx.cjs.map → use-portal-shareables-api-CZ4ELYei.cjs.map} +1 -1
- package/dist/{use-portal-shareables-api-kcUnux8J.mjs → use-portal-shareables-api-DXuaX66a.mjs} +3 -3
- package/dist/{use-portal-shareables-api-kcUnux8J.mjs.map → use-portal-shareables-api-DXuaX66a.mjs.map} +1 -1
- package/package.json +12 -12
- package/dist/FluidProvider-CRMe-Enf.cjs.map +0 -1
- package/dist/FluidProvider-DpET43hN.mjs.map +0 -1
- package/dist/MySiteScreen-CdsAyh7a.cjs.map +0 -1
- package/dist/MySiteScreen-gl8KGOrU.mjs.map +0 -1
- package/dist/portal_tenant_mysite-NSJTd8ff.mjs +0 -136
- package/dist/portal_tenant_mysite-NSJTd8ff.mjs.map +0 -1
- package/dist/portal_tenant_mysite-PDI1nxcm.cjs +0 -213
- package/dist/portal_tenant_mysite-PDI1nxcm.cjs.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { r as __exportAll } from "./es-Bstiidl5.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { B as Label, Gt as BreadcrumbPage, Ht as BreadcrumbItem, Kt as BreadcrumbSeparator, Q as DialogContent, T as Separator, Ut as BreadcrumbLink, Vt as Breadcrumb, Wt as BreadcrumbList, X as Dialog, _t as CardAction, an as Button, bt as CardHeader, et as DialogFooter, fn as useZodForm, gt as Card, it as DialogTitle, j as Input, pn as cn, qt as Badge, s as Textarea, tt as DialogHeader, vt as CardContent, xt as CardTitle, y as Skeleton } from "./src-BsT7Sq_P.mjs";
|
|
2
|
+
import { n as useMySiteApi } from "./mysite-api-context-C7eiw7TO.mjs";
|
|
3
|
+
import { B as Label, Gt as BreadcrumbPage, Ht as BreadcrumbItem, Kt as BreadcrumbSeparator, Q as DialogContent, T as Separator, Ut as BreadcrumbLink, Vt as Breadcrumb, Wt as BreadcrumbList, X as Dialog, _t as CardAction, an as Button, bt as CardHeader, et as DialogFooter, fn as useZodForm, gt as Card, it as DialogTitle, j as Input, pn as cn, s as Textarea, tt as DialogHeader, vt as CardContent, xt as CardTitle, y as Skeleton } from "./src-BsT7Sq_P.mjs";
|
|
5
4
|
import { r as useScreenHeaderBreadcrumbs } from "./ScreenHeaderContext-DjSO5A8k.mjs";
|
|
6
5
|
import { n as useAppNavigation } from "./AppNavigationContext-DTdo1dEH.mjs";
|
|
7
6
|
import { a as verticalListSortingStrategy, c as PointerSensor, d as useSensors, f as CSS, i as useSortable, l as closestCenter, n as arrayMove, o as DndContext, r as sortableKeyboardCoordinates, s as KeyboardSensor, t as SortableContext, u as useSensor } from "./sortable.esm-CzzU6kIR.mjs";
|
|
@@ -10,462 +9,139 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
10
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { ArrowLeft, Camera, Check, ChevronRight, Copy, Eye, GripVertical, LayoutGrid, Link2, LoaderCircle, Palette, Pencil, Plus, Trash2, User, Users } from "lucide-react";
|
|
12
11
|
import { z } from "zod";
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mysite_theme_id: profile.theme_id ?? null,
|
|
27
|
-
mysite_theme: null,
|
|
28
|
-
bio: profile.bio ?? null,
|
|
29
|
-
facebook: null,
|
|
30
|
-
instagram: null,
|
|
31
|
-
twitter: null,
|
|
32
|
-
youtube: null,
|
|
33
|
-
pinterest: null,
|
|
34
|
-
tiktok: null,
|
|
35
|
-
linkedin: null,
|
|
36
|
-
whatsapp: null,
|
|
37
|
-
wechat: null
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/** BFF Link → old MySiteLink shape (must pass Zod: { id, url, text, order, clicks? }) */
|
|
41
|
-
function mapBffLink(link) {
|
|
42
|
-
return {
|
|
43
|
-
id: link.id,
|
|
44
|
-
url: link.url ?? "",
|
|
45
|
-
text: link.title ?? "",
|
|
46
|
-
order: link.position ?? 0,
|
|
47
|
-
clicks: 0
|
|
48
|
-
};
|
|
12
|
+
//#region ../../mysite/ui/src/portal/hooks/use-mysite-portal.ts
|
|
13
|
+
const PORTAL_MYSITE_KEYS = {
|
|
14
|
+
profile: () => ["portal-mysite", "profile"],
|
|
15
|
+
links: () => ["portal-mysite", "links"],
|
|
16
|
+
favorites: () => ["portal-mysite", "favorites"],
|
|
17
|
+
themes: () => ["portal-mysite", "themes"]
|
|
18
|
+
};
|
|
19
|
+
function usePortalMySiteProfile() {
|
|
20
|
+
const api = useMySiteApi();
|
|
21
|
+
return useQuery({
|
|
22
|
+
queryKey: PORTAL_MYSITE_KEYS.profile(),
|
|
23
|
+
queryFn: () => api.fetchProfile()
|
|
24
|
+
});
|
|
49
25
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
created_at: fav.created_at,
|
|
59
|
-
favoriteable: {
|
|
60
|
-
id: fav.product_id,
|
|
61
|
-
title: fav.product_name ?? null,
|
|
62
|
-
name: fav.product_name ?? null,
|
|
63
|
-
image_url: fav.product_image_url ?? null,
|
|
64
|
-
type: "Product"
|
|
26
|
+
function usePortalUpdateProfile(options) {
|
|
27
|
+
const api = useMySiteApi();
|
|
28
|
+
const queryClient = useQueryClient();
|
|
29
|
+
return useMutation({
|
|
30
|
+
mutationFn: (body) => api.updateProfile(body),
|
|
31
|
+
onSuccess: () => {
|
|
32
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.profile() });
|
|
33
|
+
options?.onSuccess?.();
|
|
65
34
|
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/** BFF Theme → old MysiteTheme shape (must pass Zod themeSchema) */
|
|
69
|
-
function mapBffTheme(theme) {
|
|
70
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
71
|
-
return {
|
|
72
|
-
id: theme.id,
|
|
73
|
-
name: theme.name ?? "Untitled",
|
|
74
|
-
description: null,
|
|
75
|
-
public: true,
|
|
76
|
-
company_id: null,
|
|
77
|
-
created_at: now,
|
|
78
|
-
updated_at: now,
|
|
79
|
-
image_url: theme.preview_url ?? null,
|
|
80
|
-
application_theme_template_id: null
|
|
81
|
-
};
|
|
35
|
+
});
|
|
82
36
|
}
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* to portal-tenant MySite BFF endpoints.
|
|
92
|
-
*
|
|
93
|
-
* @param bffClient - A FetchClient pointed at the tenant BFF origin
|
|
94
|
-
* (e.g. https://acme.portal.fluid.app, **without** /api suffix — the
|
|
95
|
-
* generated namespace functions already include /api/mysite/... paths).
|
|
96
|
-
*/
|
|
97
|
-
function createPortalMySiteAdapter(bffClient) {
|
|
98
|
-
async function get(endpoint, params, options) {
|
|
99
|
-
if (endpoint === "/me.json") return mapProfileToMe((await mysite_profile_show(bffClient)).profile ?? {});
|
|
100
|
-
if (endpoint === "/mysite/themes") return ((await mysite_themes_list(bffClient)).themes ?? []).map(mapBffTheme);
|
|
101
|
-
if (LINKS_LIST.test(endpoint)) return ((await mysite_links_list(bffClient)).links ?? []).map(mapBffLink);
|
|
102
|
-
if (FAVORITES_LIST.test(endpoint)) return ((await mysite_favorites_list(bffClient)).favorites ?? []).map(mapBffFavorite);
|
|
103
|
-
return bffClient.get(endpoint, params, options);
|
|
104
|
-
}
|
|
105
|
-
async function post(endpoint, body, options) {
|
|
106
|
-
if (LINKS_LIST.test(endpoint)) {
|
|
107
|
-
const b = body;
|
|
108
|
-
return mapBffLink((await mysite_links_create(bffClient, { link: {
|
|
109
|
-
title: b?.text ?? "",
|
|
110
|
-
url: b?.url ?? ""
|
|
111
|
-
} })).link ?? {});
|
|
112
|
-
}
|
|
113
|
-
if (FAVORITES_LIST.test(endpoint)) return mapBffFavorite((await mysite_favorites_create(bffClient, { favorite: { product_id: body?.favorite?.favoriteable_id ?? 0 } })).favorite ?? {});
|
|
114
|
-
return bffClient.post(endpoint, body, options);
|
|
115
|
-
}
|
|
116
|
-
async function put(endpoint, body, options) {
|
|
117
|
-
if (endpoint === "/me.json") {
|
|
118
|
-
const b = body;
|
|
119
|
-
return mapProfileToMe((await mysite_profile_update(bffClient, { profile: {
|
|
120
|
-
display_name: b?.display_name ?? void 0,
|
|
121
|
-
bio: b?.bio ?? void 0,
|
|
122
|
-
avatar_url: b?.image_url ?? b?.avatar_url ?? void 0
|
|
123
|
-
} })).profile ?? {});
|
|
124
|
-
}
|
|
125
|
-
if (endpoint === "/mysite.json") {
|
|
126
|
-
const uc = body?.user_company;
|
|
127
|
-
if (uc?.theme_id !== void 0) return {
|
|
128
|
-
id: 0,
|
|
129
|
-
...(await mysite_settings_update(bffClient, { settings: { theme_id: uc.theme_id } })).settings ?? {}
|
|
130
|
-
};
|
|
131
|
-
if (uc?.username !== void 0) {
|
|
132
|
-
const profile = (await mysite_profile_update(bffClient, { profile: { slug: uc.username } })).profile ?? {};
|
|
133
|
-
return {
|
|
134
|
-
id: profile.id ?? 0,
|
|
135
|
-
...profile
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return { id: 0 };
|
|
139
|
-
}
|
|
140
|
-
const linkMatch = endpoint.match(LINK_SINGLE);
|
|
141
|
-
if (linkMatch) {
|
|
142
|
-
const linkId = Number(linkMatch[1]);
|
|
143
|
-
const b = body;
|
|
144
|
-
return mapBffLink((await mysite_links_update(bffClient, linkId, { link: {
|
|
145
|
-
title: b?.text,
|
|
146
|
-
url: b?.url
|
|
147
|
-
} })).link ?? {});
|
|
148
|
-
}
|
|
149
|
-
return bffClient.put(endpoint, body, options);
|
|
150
|
-
}
|
|
151
|
-
async function patch(endpoint, body, options) {
|
|
152
|
-
if (LINKS_REORDER.test(endpoint)) {
|
|
153
|
-
const items = body?.links ?? [];
|
|
154
|
-
if (items.length === 0) return [];
|
|
155
|
-
return ((await mysite_links_bulk_reorder(bffClient, { ordered_ids: [...items].sort((a, b2) => a.order - b2.order).map((l) => l.id) })).links ?? []).map(mapBffLink);
|
|
156
|
-
}
|
|
157
|
-
if (FAVORITES_REORDER.test(endpoint)) {
|
|
158
|
-
const items = body?.favorites ?? [];
|
|
159
|
-
if (items.length === 0) return [];
|
|
160
|
-
return ((await mysite_favorites_bulk_reorder(bffClient, { ordered_ids: [...items].sort((a, b2) => a.order - b2.order).map((f) => f.id) })).favorites ?? []).map(mapBffFavorite);
|
|
37
|
+
function usePortalUpdateSettings(options) {
|
|
38
|
+
const api = useMySiteApi();
|
|
39
|
+
const queryClient = useQueryClient();
|
|
40
|
+
return useMutation({
|
|
41
|
+
mutationFn: (body) => api.updateSettings(body),
|
|
42
|
+
onSuccess: () => {
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.profile() });
|
|
44
|
+
options?.onSuccess?.();
|
|
161
45
|
}
|
|
162
|
-
return bffClient.patch(endpoint, body, options);
|
|
163
|
-
}
|
|
164
|
-
async function del(endpoint, options) {
|
|
165
|
-
const linkMatch = endpoint.match(LINK_SINGLE);
|
|
166
|
-
if (linkMatch) return mysite_links_destroy(bffClient, Number(linkMatch[1]));
|
|
167
|
-
const favMatch = endpoint.match(FAVORITE_SINGLE);
|
|
168
|
-
if (favMatch) return mysite_favorites_destroy(bffClient, Number(favMatch[1]));
|
|
169
|
-
return bffClient.delete(endpoint, options);
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
request: bffClient.request,
|
|
173
|
-
requestWithFormData: bffClient.requestWithFormData,
|
|
174
|
-
get,
|
|
175
|
-
post,
|
|
176
|
-
put,
|
|
177
|
-
patch,
|
|
178
|
-
delete: del
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/mysite/use-portal-mysite-client.ts
|
|
183
|
-
/**
|
|
184
|
-
* Hook that returns a FetchClient adapter translating legacy mysite API
|
|
185
|
-
* calls to the portal-tenant MySite BFF.
|
|
186
|
-
*
|
|
187
|
-
* The adapter wraps the shared portal-tenant FetchClient so that existing
|
|
188
|
-
* mysite-ui hooks and components (which call `/me.json`, `/users/{id}/links.json`,
|
|
189
|
-
* etc.) work transparently against the BFF endpoints.
|
|
190
|
-
*/
|
|
191
|
-
function usePortalMySiteClient() {
|
|
192
|
-
const bffClient = usePortalTenantClient();
|
|
193
|
-
return useMemo(() => createPortalMySiteAdapter(bffClient), [bffClient]);
|
|
194
|
-
}
|
|
195
|
-
//#endregion
|
|
196
|
-
//#region ../../mysite/ui/src/shared/query-keys.ts
|
|
197
|
-
const MYSITE_KEYS = {
|
|
198
|
-
links: (userId) => [
|
|
199
|
-
"mysite",
|
|
200
|
-
"links",
|
|
201
|
-
userId
|
|
202
|
-
],
|
|
203
|
-
favorites: (affiliateId) => [
|
|
204
|
-
"mysite",
|
|
205
|
-
"favorites",
|
|
206
|
-
affiliateId
|
|
207
|
-
],
|
|
208
|
-
themes: () => ["mysite", "themes"],
|
|
209
|
-
defaultMySite: () => ["mysite", "default"],
|
|
210
|
-
defaultMySiteFavorites: () => [
|
|
211
|
-
"mysite",
|
|
212
|
-
"default",
|
|
213
|
-
"favorites"
|
|
214
|
-
]
|
|
215
|
-
};
|
|
216
|
-
//#endregion
|
|
217
|
-
//#region ../../mysite/ui/src/shared/schemas/mysite.schema.ts
|
|
218
|
-
const linkSchema = z.object({
|
|
219
|
-
id: z.number(),
|
|
220
|
-
url: z.string(),
|
|
221
|
-
text: z.string(),
|
|
222
|
-
order: z.number(),
|
|
223
|
-
clicks: z.number().optional().default(0)
|
|
224
|
-
});
|
|
225
|
-
const linksResponseSchema = z.array(linkSchema);
|
|
226
|
-
const favoriteableSchema = z.object({
|
|
227
|
-
id: z.number(),
|
|
228
|
-
title: z.string().nullable().optional(),
|
|
229
|
-
name: z.string().nullable().optional(),
|
|
230
|
-
image_url: z.string().nullable().optional(),
|
|
231
|
-
type: z.string().optional()
|
|
232
|
-
}).passthrough();
|
|
233
|
-
const favoriteSchema = z.object({
|
|
234
|
-
id: z.number(),
|
|
235
|
-
favoriteable_id: z.number().optional(),
|
|
236
|
-
favoriteable_type: z.string(),
|
|
237
|
-
order: z.number(),
|
|
238
|
-
user_company_id: z.number().optional(),
|
|
239
|
-
created_at: z.string().optional(),
|
|
240
|
-
favoriteable: favoriteableSchema.nullable()
|
|
241
|
-
}).passthrough();
|
|
242
|
-
const favoritesResponseSchema = z.array(favoriteSchema);
|
|
243
|
-
const mysiteUpdateResponseSchema = z.object({ id: z.number() }).passthrough();
|
|
244
|
-
const profileUpdateResponseSchema = z.object({
|
|
245
|
-
id: z.number(),
|
|
246
|
-
bio: z.string().nullable(),
|
|
247
|
-
facebook: z.string().nullable(),
|
|
248
|
-
twitter: z.string().nullable(),
|
|
249
|
-
instagram: z.string().nullable(),
|
|
250
|
-
youtube: z.string().nullable(),
|
|
251
|
-
pinterest: z.string().nullable(),
|
|
252
|
-
tiktok: z.string().nullable(),
|
|
253
|
-
linkedin: z.string().nullable(),
|
|
254
|
-
whatsapp: z.string().nullable(),
|
|
255
|
-
wechat: z.string().nullable(),
|
|
256
|
-
image_url: z.string().nullable()
|
|
257
|
-
});
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region ../../mysite/ui/src/admin/networking/mysite.api.ts
|
|
260
|
-
async function getUserLinks(client, userId) {
|
|
261
|
-
const response = await client.get(`/users/${userId}/links.json`);
|
|
262
|
-
return linksResponseSchema.parse(response);
|
|
263
|
-
}
|
|
264
|
-
async function createUserLink(client, userId, data) {
|
|
265
|
-
const response = await client.post(`/users/${userId}/links.json`, data);
|
|
266
|
-
const result = linkSchema.safeParse(response);
|
|
267
|
-
return result.success ? result.data : response;
|
|
268
|
-
}
|
|
269
|
-
async function updateUserLink(client, userId, linkId, data) {
|
|
270
|
-
const response = await client.put(`/users/${userId}/links/${linkId}.json`, data);
|
|
271
|
-
const result = linkSchema.safeParse(response);
|
|
272
|
-
return result.success ? result.data : response;
|
|
273
|
-
}
|
|
274
|
-
async function deleteUserLink(client, userId, linkId) {
|
|
275
|
-
return client.delete(`/users/${userId}/links/${linkId}.json`);
|
|
276
|
-
}
|
|
277
|
-
async function reorderUserLinks(client, userId, links) {
|
|
278
|
-
const response = await client.patch(`/users/${userId}/links/bulk_reorder.json`, { links });
|
|
279
|
-
const reorderResult = linksResponseSchema.safeParse(response);
|
|
280
|
-
return reorderResult.success ? reorderResult.data : response;
|
|
281
|
-
}
|
|
282
|
-
async function getUserFavorites(client, affiliateId) {
|
|
283
|
-
const response = await client.get(`/user_companies/${affiliateId}/favorites.json`);
|
|
284
|
-
return favoritesResponseSchema.parse(response);
|
|
285
|
-
}
|
|
286
|
-
async function deleteFavorite(client, affiliateId, favoriteId) {
|
|
287
|
-
return client.delete(`/user_companies/${affiliateId}/favorites/${favoriteId}.json`);
|
|
288
|
-
}
|
|
289
|
-
async function reorderFavorites(client, affiliateId, favorites, countryId, languageIso) {
|
|
290
|
-
const response = await client.patch(`/user_companies/${affiliateId}/favorites/bulk_reorder.json`, {
|
|
291
|
-
favorites,
|
|
292
|
-
country_id: countryId,
|
|
293
|
-
language_iso: languageIso
|
|
294
46
|
});
|
|
295
|
-
const reorderFavResult = favoritesResponseSchema.safeParse(response);
|
|
296
|
-
return reorderFavResult.success ? reorderFavResult.data : response;
|
|
297
|
-
}
|
|
298
|
-
async function updateMySite(client, data) {
|
|
299
|
-
const response = await client.put("/mysite.json", { user_company: data });
|
|
300
|
-
const mysiteResult = mysiteUpdateResponseSchema.safeParse(response);
|
|
301
|
-
return mysiteResult.success ? mysiteResult.data : response;
|
|
302
47
|
}
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
const profileResult = profileUpdateResponseSchema.safeParse(response);
|
|
306
|
-
return profileResult.success ? profileResult.data : response;
|
|
307
|
-
}
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region ../../mysite/ui/src/shared/schemas/mysite-theme.schema.ts
|
|
310
|
-
const themeSchema = z.object({
|
|
311
|
-
id: z.number(),
|
|
312
|
-
name: z.string(),
|
|
313
|
-
description: z.string().nullable(),
|
|
314
|
-
public: z.boolean(),
|
|
315
|
-
company_id: z.number().nullable(),
|
|
316
|
-
created_at: z.string().datetime(),
|
|
317
|
-
updated_at: z.string().datetime(),
|
|
318
|
-
image_url: z.string().nullable(),
|
|
319
|
-
application_theme_template_id: z.number().nullable()
|
|
320
|
-
});
|
|
321
|
-
const mysiteThemesSchema = z.array(themeSchema);
|
|
322
|
-
const legacyThemeTemplateSchema = z.object({
|
|
323
|
-
id: z.number(),
|
|
324
|
-
name: z.string(),
|
|
325
|
-
content: z.string().nullable(),
|
|
326
|
-
stylesheet: z.string().nullable(),
|
|
327
|
-
head: z.string().nullable(),
|
|
328
|
-
status: z.string()
|
|
329
|
-
});
|
|
330
|
-
z.object({ data: z.object({ legacy_theme: z.object({
|
|
331
|
-
id: z.number(),
|
|
332
|
-
name: z.string(),
|
|
333
|
-
description: z.string().nullable(),
|
|
334
|
-
image_url: z.string().nullable(),
|
|
335
|
-
public: z.boolean(),
|
|
336
|
-
company_id: z.number().nullable(),
|
|
337
|
-
template: legacyThemeTemplateSchema
|
|
338
|
-
}) }) });
|
|
339
|
-
//#endregion
|
|
340
|
-
//#region ../../mysite/ui/src/admin/networking/mysite-theme.api.ts
|
|
341
|
-
async function getMysiteThemes(client) {
|
|
342
|
-
const response = await client.get("/mysite/themes");
|
|
343
|
-
return mysiteThemesSchema.parse(response);
|
|
344
|
-
}
|
|
345
|
-
//#endregion
|
|
346
|
-
//#region ../../mysite/ui/src/admin/hooks/use-mysite.ts
|
|
347
|
-
function useUserLinks(client, userId) {
|
|
48
|
+
function usePortalLinks() {
|
|
49
|
+
const api = useMySiteApi();
|
|
348
50
|
return useQuery({
|
|
349
|
-
queryKey:
|
|
350
|
-
queryFn: () =>
|
|
351
|
-
enabled: !!userId
|
|
51
|
+
queryKey: PORTAL_MYSITE_KEYS.links(),
|
|
52
|
+
queryFn: () => api.listLinks()
|
|
352
53
|
});
|
|
353
54
|
}
|
|
354
|
-
function
|
|
55
|
+
function usePortalCreateLink() {
|
|
56
|
+
const api = useMySiteApi();
|
|
355
57
|
const queryClient = useQueryClient();
|
|
356
58
|
return useMutation({
|
|
357
|
-
mutationFn: (
|
|
358
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
359
|
-
return createUserLink(client, userId, data);
|
|
360
|
-
},
|
|
59
|
+
mutationFn: (body) => api.createLink(body),
|
|
361
60
|
onSuccess: () => {
|
|
362
|
-
|
|
61
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
363
62
|
}
|
|
364
63
|
});
|
|
365
64
|
}
|
|
366
|
-
function
|
|
65
|
+
function usePortalUpdateLink() {
|
|
66
|
+
const api = useMySiteApi();
|
|
367
67
|
const queryClient = useQueryClient();
|
|
368
68
|
return useMutation({
|
|
369
|
-
mutationFn: ({ linkId,
|
|
370
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
371
|
-
return updateUserLink(client, userId, linkId, data);
|
|
372
|
-
},
|
|
69
|
+
mutationFn: ({ linkId, body }) => api.updateLink(linkId, body),
|
|
373
70
|
onSuccess: () => {
|
|
374
|
-
|
|
71
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
375
72
|
}
|
|
376
73
|
});
|
|
377
74
|
}
|
|
378
|
-
function
|
|
75
|
+
function usePortalDeleteLink() {
|
|
76
|
+
const api = useMySiteApi();
|
|
379
77
|
const queryClient = useQueryClient();
|
|
380
78
|
return useMutation({
|
|
381
|
-
mutationFn: (linkId) =>
|
|
382
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
383
|
-
return deleteUserLink(client, userId, linkId);
|
|
384
|
-
},
|
|
79
|
+
mutationFn: (linkId) => api.deleteLink(linkId),
|
|
385
80
|
onSuccess: () => {
|
|
386
|
-
|
|
81
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
387
82
|
}
|
|
388
83
|
});
|
|
389
84
|
}
|
|
390
|
-
function
|
|
85
|
+
function usePortalReorderLinks() {
|
|
86
|
+
const api = useMySiteApi();
|
|
391
87
|
const queryClient = useQueryClient();
|
|
392
88
|
return useMutation({
|
|
393
|
-
mutationFn: ({
|
|
394
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
395
|
-
return reorderUserLinks(client, userId, payload);
|
|
396
|
-
},
|
|
89
|
+
mutationFn: ({ orderedIds }) => api.reorderLinks(orderedIds),
|
|
397
90
|
onMutate: async ({ optimisticItems }) => {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
queryClient.setQueryData(MYSITE_KEYS.links(userId), optimisticItems);
|
|
91
|
+
await queryClient.cancelQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
92
|
+
const previousData = queryClient.getQueryData(PORTAL_MYSITE_KEYS.links());
|
|
93
|
+
queryClient.setQueryData(PORTAL_MYSITE_KEYS.links(), optimisticItems);
|
|
402
94
|
return { previousData };
|
|
403
95
|
},
|
|
404
96
|
onError: (_err, _vars, context) => {
|
|
405
|
-
if (
|
|
97
|
+
if (context?.previousData) queryClient.setQueryData(PORTAL_MYSITE_KEYS.links(), context.previousData);
|
|
406
98
|
},
|
|
407
99
|
onSettled: () => {
|
|
408
|
-
|
|
100
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
409
101
|
}
|
|
410
102
|
});
|
|
411
103
|
}
|
|
412
|
-
function
|
|
104
|
+
function usePortalFavorites() {
|
|
105
|
+
const api = useMySiteApi();
|
|
413
106
|
return useQuery({
|
|
414
|
-
queryKey:
|
|
415
|
-
queryFn: () =>
|
|
416
|
-
enabled: !!affiliateId
|
|
107
|
+
queryKey: PORTAL_MYSITE_KEYS.favorites(),
|
|
108
|
+
queryFn: () => api.listFavorites()
|
|
417
109
|
});
|
|
418
110
|
}
|
|
419
|
-
function
|
|
111
|
+
function usePortalDeleteFavorite() {
|
|
112
|
+
const api = useMySiteApi();
|
|
420
113
|
const queryClient = useQueryClient();
|
|
421
114
|
return useMutation({
|
|
422
|
-
mutationFn: (favoriteId) =>
|
|
423
|
-
if (!affiliateId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
424
|
-
return deleteFavorite(client, affiliateId, favoriteId);
|
|
425
|
-
},
|
|
115
|
+
mutationFn: (favoriteId) => api.deleteFavorite(favoriteId),
|
|
426
116
|
onSuccess: () => {
|
|
427
|
-
|
|
117
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
428
118
|
}
|
|
429
119
|
});
|
|
430
120
|
}
|
|
431
|
-
function
|
|
121
|
+
function usePortalReorderFavorites() {
|
|
122
|
+
const api = useMySiteApi();
|
|
432
123
|
const queryClient = useQueryClient();
|
|
433
124
|
return useMutation({
|
|
434
|
-
mutationFn: ({
|
|
435
|
-
if (!affiliateId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
436
|
-
return reorderFavorites(client, affiliateId, payload);
|
|
437
|
-
},
|
|
125
|
+
mutationFn: ({ orderedIds }) => api.reorderFavorites(orderedIds),
|
|
438
126
|
onMutate: async ({ optimisticItems }) => {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
queryClient.setQueryData(MYSITE_KEYS.favorites(affiliateId), optimisticItems);
|
|
127
|
+
await queryClient.cancelQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
128
|
+
const previousData = queryClient.getQueryData(PORTAL_MYSITE_KEYS.favorites());
|
|
129
|
+
queryClient.setQueryData(PORTAL_MYSITE_KEYS.favorites(), optimisticItems);
|
|
443
130
|
return { previousData };
|
|
444
131
|
},
|
|
445
132
|
onError: (_err, _vars, context) => {
|
|
446
|
-
if (
|
|
133
|
+
if (context?.previousData) queryClient.setQueryData(PORTAL_MYSITE_KEYS.favorites(), context.previousData);
|
|
447
134
|
},
|
|
448
135
|
onSettled: () => {
|
|
449
|
-
|
|
136
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
450
137
|
}
|
|
451
138
|
});
|
|
452
139
|
}
|
|
453
|
-
function
|
|
140
|
+
function usePortalMySiteThemes() {
|
|
141
|
+
const api = useMySiteApi();
|
|
454
142
|
return useQuery({
|
|
455
|
-
queryKey:
|
|
456
|
-
queryFn: () =>
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
function useUpdateMySite(client, options) {
|
|
460
|
-
return useMutation({
|
|
461
|
-
mutationFn: (data) => updateMySite(client, data),
|
|
462
|
-
onSuccess: () => options?.onProfileRefetch?.()
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
function useUpdateProfile(client, options) {
|
|
466
|
-
return useMutation({
|
|
467
|
-
mutationFn: (data) => updateProfile(client, data),
|
|
468
|
-
onSuccess: () => options?.onProfileRefetch?.()
|
|
143
|
+
queryKey: PORTAL_MYSITE_KEYS.themes(),
|
|
144
|
+
queryFn: () => api.listThemes()
|
|
469
145
|
});
|
|
470
146
|
}
|
|
471
147
|
//#endregion
|
|
@@ -790,6 +466,7 @@ function MySiteThemeEditor({ themes, selectedThemeId, onSelectTheme, isPending,
|
|
|
790
466
|
className: "grid grid-cols-2 gap-4 sm:grid-cols-3",
|
|
791
467
|
children: themes.map((theme) => {
|
|
792
468
|
const isSelected = theme.id === selectedThemeId;
|
|
469
|
+
const imageUrl = theme.preview_url ?? theme.image_url;
|
|
793
470
|
return /* @__PURE__ */ jsxs("button", {
|
|
794
471
|
type: "button",
|
|
795
472
|
onClick: () => onSelectTheme(theme),
|
|
@@ -799,8 +476,8 @@ function MySiteThemeEditor({ themes, selectedThemeId, onSelectTheme, isPending,
|
|
|
799
476
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
800
477
|
className: "bg-muted relative aspect-[4/3] w-full",
|
|
801
478
|
children: [
|
|
802
|
-
|
|
803
|
-
src:
|
|
479
|
+
imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
480
|
+
src: imageUrl,
|
|
804
481
|
alt: theme.name,
|
|
805
482
|
loading: "lazy",
|
|
806
483
|
className: "absolute inset-0 h-full w-full object-cover"
|
|
@@ -829,6 +506,79 @@ function MySiteThemeEditor({ themes, selectedThemeId, onSelectTheme, isPending,
|
|
|
829
506
|
})] });
|
|
830
507
|
}
|
|
831
508
|
//#endregion
|
|
509
|
+
//#region ../../mysite/ui/src/shared/schemas/mysite.schema.ts
|
|
510
|
+
const linkSchema = z.object({
|
|
511
|
+
id: z.number(),
|
|
512
|
+
url: z.string(),
|
|
513
|
+
text: z.string(),
|
|
514
|
+
order: z.number(),
|
|
515
|
+
clicks: z.number().optional().default(0)
|
|
516
|
+
});
|
|
517
|
+
z.array(linkSchema);
|
|
518
|
+
const favoriteableSchema = z.object({
|
|
519
|
+
id: z.number(),
|
|
520
|
+
title: z.string().nullable().optional(),
|
|
521
|
+
name: z.string().nullable().optional(),
|
|
522
|
+
image_url: z.string().nullable().optional(),
|
|
523
|
+
type: z.string().optional()
|
|
524
|
+
}).passthrough();
|
|
525
|
+
const favoriteSchema = z.object({
|
|
526
|
+
id: z.number(),
|
|
527
|
+
favoriteable_id: z.number().optional(),
|
|
528
|
+
favoriteable_type: z.string(),
|
|
529
|
+
order: z.number(),
|
|
530
|
+
user_company_id: z.number().optional(),
|
|
531
|
+
created_at: z.string().optional(),
|
|
532
|
+
favoriteable: favoriteableSchema.nullable()
|
|
533
|
+
}).passthrough();
|
|
534
|
+
z.array(favoriteSchema);
|
|
535
|
+
z.object({ id: z.number() }).passthrough();
|
|
536
|
+
z.object({
|
|
537
|
+
id: z.number(),
|
|
538
|
+
bio: z.string().nullable(),
|
|
539
|
+
facebook: z.string().nullable(),
|
|
540
|
+
twitter: z.string().nullable(),
|
|
541
|
+
instagram: z.string().nullable(),
|
|
542
|
+
youtube: z.string().nullable(),
|
|
543
|
+
pinterest: z.string().nullable(),
|
|
544
|
+
tiktok: z.string().nullable(),
|
|
545
|
+
linkedin: z.string().nullable(),
|
|
546
|
+
whatsapp: z.string().nullable(),
|
|
547
|
+
wechat: z.string().nullable(),
|
|
548
|
+
image_url: z.string().nullable()
|
|
549
|
+
});
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region ../../mysite/ui/src/shared/schemas/mysite-theme.schema.ts
|
|
552
|
+
const themeSchema = z.object({
|
|
553
|
+
id: z.number(),
|
|
554
|
+
name: z.string(),
|
|
555
|
+
description: z.string().nullable(),
|
|
556
|
+
public: z.boolean(),
|
|
557
|
+
company_id: z.number().nullable(),
|
|
558
|
+
created_at: z.string().datetime(),
|
|
559
|
+
updated_at: z.string().datetime(),
|
|
560
|
+
image_url: z.string().nullable(),
|
|
561
|
+
application_theme_template_id: z.number().nullable()
|
|
562
|
+
});
|
|
563
|
+
z.array(themeSchema);
|
|
564
|
+
const legacyThemeTemplateSchema = z.object({
|
|
565
|
+
id: z.number(),
|
|
566
|
+
name: z.string(),
|
|
567
|
+
content: z.string().nullable(),
|
|
568
|
+
stylesheet: z.string().nullable(),
|
|
569
|
+
head: z.string().nullable(),
|
|
570
|
+
status: z.string()
|
|
571
|
+
});
|
|
572
|
+
z.object({ data: z.object({ legacy_theme: z.object({
|
|
573
|
+
id: z.number(),
|
|
574
|
+
name: z.string(),
|
|
575
|
+
description: z.string().nullable(),
|
|
576
|
+
image_url: z.string().nullable(),
|
|
577
|
+
public: z.boolean(),
|
|
578
|
+
company_id: z.number().nullable(),
|
|
579
|
+
template: legacyThemeTemplateSchema
|
|
580
|
+
}) }) });
|
|
581
|
+
//#endregion
|
|
832
582
|
//#region ../../mysite/ui/src/shared/utils.ts
|
|
833
583
|
function normalizeUrl(value) {
|
|
834
584
|
const trimmed = value.trim();
|
|
@@ -836,10 +586,14 @@ function normalizeUrl(value) {
|
|
|
836
586
|
if (/^https?:\/\//i.test(trimmed)) return trimmed;
|
|
837
587
|
return `https://${trimmed}`;
|
|
838
588
|
}
|
|
589
|
+
z.object({
|
|
590
|
+
text: z.string().min(1, "Button text is required"),
|
|
591
|
+
url: z.string().transform(normalizeUrl).pipe(z.string().url("Must be a valid URL"))
|
|
592
|
+
});
|
|
839
593
|
//#endregion
|
|
840
|
-
//#region ../../mysite/ui/src/portal/components/
|
|
594
|
+
//#region ../../mysite/ui/src/portal/components/PortalButtonsEditor.tsx
|
|
841
595
|
const buttonSchema = z.object({
|
|
842
|
-
|
|
596
|
+
title: z.string().min(1, "Button text is required"),
|
|
843
597
|
url: z.string().transform(normalizeUrl).pipe(z.string().url("Must be a valid URL"))
|
|
844
598
|
});
|
|
845
599
|
function SortableButtonCard({ link, onEdit, onDelete }) {
|
|
@@ -866,17 +620,12 @@ function SortableButtonCard({ link, onEdit, onDelete }) {
|
|
|
866
620
|
className: "min-w-0 flex-1",
|
|
867
621
|
children: [/* @__PURE__ */ jsx("p", {
|
|
868
622
|
className: "text-foreground truncate font-medium",
|
|
869
|
-
children: link.
|
|
623
|
+
children: link.title
|
|
870
624
|
}), /* @__PURE__ */ jsx("p", {
|
|
871
625
|
className: "text-muted-foreground truncate text-sm",
|
|
872
626
|
children: truncatedUrl
|
|
873
627
|
})]
|
|
874
628
|
}),
|
|
875
|
-
/* @__PURE__ */ jsxs(Badge, {
|
|
876
|
-
variant: "secondary",
|
|
877
|
-
className: "hidden shrink-0 sm:inline-flex",
|
|
878
|
-
children: [link.clicks ?? 0, " clicks"]
|
|
879
|
-
}),
|
|
880
629
|
/* @__PURE__ */ jsxs("div", {
|
|
881
630
|
className: "flex shrink-0 items-center gap-1",
|
|
882
631
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
@@ -898,26 +647,30 @@ function SortableButtonCard({ link, onEdit, onDelete }) {
|
|
|
898
647
|
]
|
|
899
648
|
});
|
|
900
649
|
}
|
|
901
|
-
|
|
650
|
+
/**
|
|
651
|
+
* Portal-specific buttons editor that uses MySiteApi context.
|
|
652
|
+
* No client/userId props needed — data comes from context.
|
|
653
|
+
*/
|
|
654
|
+
function PortalButtonsEditor({ onBack, onRefreshPreview, onToast }) {
|
|
902
655
|
"use no memo";
|
|
903
|
-
const { data: links = [], isLoading } =
|
|
904
|
-
const createLinkMutation =
|
|
905
|
-
const updateLinkMutation =
|
|
906
|
-
const deleteLinkMutation =
|
|
907
|
-
const reorderLinksMutation =
|
|
656
|
+
const { data: links = [], isLoading } = usePortalLinks();
|
|
657
|
+
const createLinkMutation = usePortalCreateLink();
|
|
658
|
+
const updateLinkMutation = usePortalUpdateLink();
|
|
659
|
+
const deleteLinkMutation = usePortalDeleteLink();
|
|
660
|
+
const reorderLinksMutation = usePortalReorderLinks();
|
|
908
661
|
const [isAddEditDialogOpen, setIsAddEditDialogOpen] = useState(false);
|
|
909
662
|
const [editingLink, setEditingLink] = useState(null);
|
|
910
663
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
|
911
664
|
const [deletingLink, setDeletingLink] = useState(null);
|
|
912
665
|
const { register, handleSubmit: handleButtonSubmit, reset: resetButtonForm, formState: { errors: buttonErrors, isSubmitting: isButtonSubmitting } } = useZodForm(buttonSchema, { defaultValues: {
|
|
913
|
-
|
|
666
|
+
title: "",
|
|
914
667
|
url: ""
|
|
915
668
|
} });
|
|
916
669
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
917
670
|
const handleOpenAddDialog = useCallback(() => {
|
|
918
671
|
setEditingLink(null);
|
|
919
672
|
resetButtonForm({
|
|
920
|
-
|
|
673
|
+
title: "",
|
|
921
674
|
url: ""
|
|
922
675
|
});
|
|
923
676
|
setIsAddEditDialogOpen(true);
|
|
@@ -925,7 +678,7 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
925
678
|
const handleOpenEditDialog = useCallback((link) => {
|
|
926
679
|
setEditingLink(link);
|
|
927
680
|
resetButtonForm({
|
|
928
|
-
|
|
681
|
+
title: link.title,
|
|
929
682
|
url: link.url
|
|
930
683
|
});
|
|
931
684
|
setIsAddEditDialogOpen(true);
|
|
@@ -934,14 +687,17 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
934
687
|
setIsAddEditDialogOpen(false);
|
|
935
688
|
setEditingLink(null);
|
|
936
689
|
resetButtonForm({
|
|
937
|
-
|
|
690
|
+
title: "",
|
|
938
691
|
url: ""
|
|
939
692
|
});
|
|
940
693
|
}, [resetButtonForm]);
|
|
941
694
|
const onButtonSubmit = useCallback((data) => {
|
|
942
695
|
if (editingLink) updateLinkMutation.mutate({
|
|
943
696
|
linkId: editingLink.id,
|
|
944
|
-
|
|
697
|
+
body: {
|
|
698
|
+
title: data.title,
|
|
699
|
+
url: data.url
|
|
700
|
+
}
|
|
945
701
|
}, {
|
|
946
702
|
onSuccess: () => {
|
|
947
703
|
onToast?.("Button updated", "success");
|
|
@@ -952,7 +708,10 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
952
708
|
onToast?.("Failed to update button", "error");
|
|
953
709
|
}
|
|
954
710
|
});
|
|
955
|
-
else createLinkMutation.mutate(
|
|
711
|
+
else createLinkMutation.mutate({
|
|
712
|
+
title: data.title,
|
|
713
|
+
url: data.url
|
|
714
|
+
}, {
|
|
956
715
|
onSuccess: () => {
|
|
957
716
|
onToast?.("Button created", "success");
|
|
958
717
|
handleCloseAddEditDialog();
|
|
@@ -1000,12 +759,9 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1000
759
|
const { active, over } = event;
|
|
1001
760
|
if (over && active.id !== over.id) {
|
|
1002
761
|
const reordered = arrayMove(links, links.findIndex((l) => l.id === active.id), links.findIndex((l) => l.id === over.id));
|
|
1003
|
-
const
|
|
1004
|
-
id: link.id,
|
|
1005
|
-
order: index + 1
|
|
1006
|
-
}));
|
|
762
|
+
const orderedIds = reordered.map((link) => link.id);
|
|
1007
763
|
reorderLinksMutation.mutate({
|
|
1008
|
-
|
|
764
|
+
orderedIds,
|
|
1009
765
|
optimisticItems: reordered
|
|
1010
766
|
}, {
|
|
1011
767
|
onSuccess: () => {
|
|
@@ -1052,7 +808,6 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1052
808
|
className: "min-w-0 flex-1 space-y-2",
|
|
1053
809
|
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-48" })]
|
|
1054
810
|
}),
|
|
1055
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "hidden h-5 w-16 sm:block" }),
|
|
1056
811
|
/* @__PURE__ */ jsxs("div", {
|
|
1057
812
|
className: "flex gap-1",
|
|
1058
813
|
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-8" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-8" })]
|
|
@@ -1097,18 +852,18 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1097
852
|
className: "space-y-2",
|
|
1098
853
|
children: [
|
|
1099
854
|
/* @__PURE__ */ jsx(Label, {
|
|
1100
|
-
htmlFor: "
|
|
855
|
+
htmlFor: "title",
|
|
1101
856
|
children: "Button Text"
|
|
1102
857
|
}),
|
|
1103
858
|
/* @__PURE__ */ jsx(Input, {
|
|
1104
|
-
id: "
|
|
859
|
+
id: "title",
|
|
1105
860
|
placeholder: "Enter button text...",
|
|
1106
|
-
...register("
|
|
1107
|
-
className: buttonErrors.
|
|
861
|
+
...register("title"),
|
|
862
|
+
className: buttonErrors.title ? "border-destructive" : ""
|
|
1108
863
|
}),
|
|
1109
|
-
buttonErrors.
|
|
864
|
+
buttonErrors.title && /* @__PURE__ */ jsx("p", {
|
|
1110
865
|
className: "text-destructive text-sm",
|
|
1111
|
-
children: buttonErrors.
|
|
866
|
+
children: buttonErrors.title.message
|
|
1112
867
|
})
|
|
1113
868
|
]
|
|
1114
869
|
}),
|
|
@@ -1167,7 +922,7 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1167
922
|
className: "text-muted-foreground",
|
|
1168
923
|
children: [
|
|
1169
924
|
"Are you sure you want to delete the button \"",
|
|
1170
|
-
deletingLink?.
|
|
925
|
+
deletingLink?.title,
|
|
1171
926
|
"\"? This action cannot be undone."
|
|
1172
927
|
]
|
|
1173
928
|
}),
|
|
@@ -1188,16 +943,15 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1188
943
|
] });
|
|
1189
944
|
}
|
|
1190
945
|
//#endregion
|
|
1191
|
-
//#region ../../mysite/ui/src/portal/components/
|
|
946
|
+
//#region ../../mysite/ui/src/portal/components/PortalFavoritesEditor.tsx
|
|
1192
947
|
function SortableFavoriteCard({ favorite, onDelete }) {
|
|
1193
948
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: favorite.id });
|
|
1194
949
|
const style = {
|
|
1195
950
|
transform: CSS.Transform.toString(transform),
|
|
1196
951
|
transition
|
|
1197
952
|
};
|
|
1198
|
-
const title = favorite.
|
|
1199
|
-
const imageUrl = favorite.
|
|
1200
|
-
const type = favorite.favoriteable_type.replace(/([A-Z])/g, " $1").trim();
|
|
953
|
+
const title = favorite.product_name ?? "Untitled";
|
|
954
|
+
const imageUrl = favorite.product_image_url;
|
|
1201
955
|
return /* @__PURE__ */ jsxs("div", {
|
|
1202
956
|
ref: setNodeRef,
|
|
1203
957
|
style,
|
|
@@ -1225,15 +979,12 @@ function SortableFavoriteCard({ favorite, onDelete }) {
|
|
|
1225
979
|
children: "N/A"
|
|
1226
980
|
})
|
|
1227
981
|
}),
|
|
1228
|
-
/* @__PURE__ */
|
|
982
|
+
/* @__PURE__ */ jsx("div", {
|
|
1229
983
|
className: "min-w-0 flex-1",
|
|
1230
|
-
children:
|
|
984
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
1231
985
|
className: "text-foreground truncate font-medium",
|
|
1232
986
|
children: title
|
|
1233
|
-
})
|
|
1234
|
-
className: "text-muted-foreground truncate text-sm",
|
|
1235
|
-
children: type
|
|
1236
|
-
})]
|
|
987
|
+
})
|
|
1237
988
|
}),
|
|
1238
989
|
/* @__PURE__ */ jsx("div", {
|
|
1239
990
|
className: "flex shrink-0 items-center gap-1",
|
|
@@ -1249,10 +1000,14 @@ function SortableFavoriteCard({ favorite, onDelete }) {
|
|
|
1249
1000
|
]
|
|
1250
1001
|
});
|
|
1251
1002
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1003
|
+
/**
|
|
1004
|
+
* Portal-specific favorites editor that uses MySiteApi context.
|
|
1005
|
+
* No client/affiliateId props needed — data comes from context.
|
|
1006
|
+
*/
|
|
1007
|
+
function PortalFavoritesEditor({ onBack, onRefreshPreview, onToast }) {
|
|
1008
|
+
const { data: favorites = [], isLoading } = usePortalFavorites();
|
|
1009
|
+
const deleteFavoriteMutation = usePortalDeleteFavorite();
|
|
1010
|
+
const reorderFavoritesMutation = usePortalReorderFavorites();
|
|
1256
1011
|
const [isDeleteFavoriteDialogOpen, setIsDeleteFavoriteDialogOpen] = useState(false);
|
|
1257
1012
|
const [deletingFavorite, setDeletingFavorite] = useState(null);
|
|
1258
1013
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
@@ -1286,12 +1041,9 @@ function MySiteFavoritesEditor({ onBack, onRefreshPreview, client, affiliateId,
|
|
|
1286
1041
|
const { active, over } = event;
|
|
1287
1042
|
if (over && active.id !== over.id) {
|
|
1288
1043
|
const reordered = arrayMove(favorites, favorites.findIndex((f) => f.id === active.id), favorites.findIndex((f) => f.id === over.id));
|
|
1289
|
-
const
|
|
1290
|
-
id: fav.id,
|
|
1291
|
-
order: index + 1
|
|
1292
|
-
}));
|
|
1044
|
+
const orderedIds = reordered.map((fav) => fav.id);
|
|
1293
1045
|
reorderFavoritesMutation.mutate({
|
|
1294
|
-
|
|
1046
|
+
orderedIds,
|
|
1295
1047
|
optimisticItems: reordered
|
|
1296
1048
|
}, {
|
|
1297
1049
|
onSuccess: () => {
|
|
@@ -1366,7 +1118,7 @@ function MySiteFavoritesEditor({ onBack, onRefreshPreview, client, affiliateId,
|
|
|
1366
1118
|
className: "text-muted-foreground",
|
|
1367
1119
|
children: [
|
|
1368
1120
|
"Are you sure you want to remove \"",
|
|
1369
|
-
deletingFavorite?.
|
|
1121
|
+
deletingFavorite?.product_name ?? "this item",
|
|
1370
1122
|
"\" from your MySite? This action cannot be undone."
|
|
1371
1123
|
]
|
|
1372
1124
|
}),
|
|
@@ -1388,92 +1140,24 @@ function MySiteFavoritesEditor({ onBack, onRefreshPreview, client, affiliateId,
|
|
|
1388
1140
|
}
|
|
1389
1141
|
//#endregion
|
|
1390
1142
|
//#region ../../mysite/ui/src/portal/components/MySiteProfileForm.tsx
|
|
1391
|
-
|
|
1392
|
-
{
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
name: "facebook",
|
|
1399
|
-
label: "Facebook",
|
|
1400
|
-
placeholder: "https://facebook.com/username"
|
|
1401
|
-
},
|
|
1402
|
-
{
|
|
1403
|
-
name: "twitter",
|
|
1404
|
-
label: "X (Twitter)",
|
|
1405
|
-
placeholder: "https://x.com/username"
|
|
1406
|
-
},
|
|
1407
|
-
{
|
|
1408
|
-
name: "instagram",
|
|
1409
|
-
label: "Instagram",
|
|
1410
|
-
placeholder: "https://instagram.com/username"
|
|
1411
|
-
},
|
|
1412
|
-
{
|
|
1413
|
-
name: "youtube",
|
|
1414
|
-
label: "YouTube",
|
|
1415
|
-
placeholder: "https://youtube.com/@channel"
|
|
1416
|
-
},
|
|
1417
|
-
{
|
|
1418
|
-
name: "pinterest",
|
|
1419
|
-
label: "Pinterest",
|
|
1420
|
-
placeholder: "https://pinterest.com/username"
|
|
1421
|
-
},
|
|
1422
|
-
{
|
|
1423
|
-
name: "tiktok",
|
|
1424
|
-
label: "TikTok",
|
|
1425
|
-
placeholder: "https://tiktok.com/@username"
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
name: "whatsapp",
|
|
1429
|
-
label: "WhatsApp",
|
|
1430
|
-
placeholder: "Phone number or link"
|
|
1431
|
-
},
|
|
1432
|
-
{
|
|
1433
|
-
name: "wechat",
|
|
1434
|
-
label: "WeChat",
|
|
1435
|
-
placeholder: "WeChat ID"
|
|
1436
|
-
}
|
|
1437
|
-
];
|
|
1438
|
-
function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl, userName, userInitial }) {
|
|
1439
|
-
const queryClient = useQueryClient();
|
|
1440
|
-
const { data: meProfile, isLoading: isProfileLoading } = useQuery({
|
|
1441
|
-
queryKey: ["sdk-mysite", "me"],
|
|
1442
|
-
queryFn: () => client.get("/me.json")
|
|
1443
|
-
});
|
|
1444
|
-
const updateProfileMutation = useUpdateProfile(client);
|
|
1445
|
-
const initialFormState = useMemo(() => ({
|
|
1446
|
-
bio: meProfile?.bio ?? "",
|
|
1447
|
-
linkedin: meProfile?.linkedin ?? "",
|
|
1448
|
-
facebook: meProfile?.facebook ?? "",
|
|
1449
|
-
twitter: meProfile?.twitter ?? "",
|
|
1450
|
-
instagram: meProfile?.instagram ?? "",
|
|
1451
|
-
youtube: meProfile?.youtube ?? "",
|
|
1452
|
-
pinterest: meProfile?.pinterest ?? "",
|
|
1453
|
-
tiktok: meProfile?.tiktok ?? "",
|
|
1454
|
-
whatsapp: meProfile?.whatsapp ?? "",
|
|
1455
|
-
wechat: meProfile?.wechat ?? ""
|
|
1456
|
-
}), [meProfile?.id]);
|
|
1457
|
-
const [formState, setFormState] = useState(() => initialFormState);
|
|
1143
|
+
function MySiteProfileForm({ onBack, onToast, onUploadPhoto, avatarUrl, userName, userInitial }) {
|
|
1144
|
+
const { data: profile, isLoading: isProfileLoading } = usePortalMySiteProfile();
|
|
1145
|
+
const updateProfileMutation = usePortalUpdateProfile();
|
|
1146
|
+
const [formState, setFormState] = useState(() => ({
|
|
1147
|
+
display_name: "",
|
|
1148
|
+
bio: ""
|
|
1149
|
+
}));
|
|
1458
1150
|
const profileSyncedRef = useRef(false);
|
|
1459
1151
|
useEffect(() => {
|
|
1460
|
-
if (
|
|
1152
|
+
if (profile && !profileSyncedRef.current) {
|
|
1461
1153
|
profileSyncedRef.current = true;
|
|
1462
1154
|
setFormState({
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
facebook: meProfile.facebook ?? "",
|
|
1466
|
-
twitter: meProfile.twitter ?? "",
|
|
1467
|
-
instagram: meProfile.instagram ?? "",
|
|
1468
|
-
youtube: meProfile.youtube ?? "",
|
|
1469
|
-
pinterest: meProfile.pinterest ?? "",
|
|
1470
|
-
tiktok: meProfile.tiktok ?? "",
|
|
1471
|
-
whatsapp: meProfile.whatsapp ?? "",
|
|
1472
|
-
wechat: meProfile.wechat ?? ""
|
|
1155
|
+
display_name: profile.display_name ?? "",
|
|
1156
|
+
bio: profile.bio ?? ""
|
|
1473
1157
|
});
|
|
1474
1158
|
}
|
|
1475
|
-
}, [
|
|
1476
|
-
const isDirty = formState.
|
|
1159
|
+
}, [profile]);
|
|
1160
|
+
const isDirty = formState.display_name !== (profile?.display_name ?? "") || formState.bio !== (profile?.bio ?? "");
|
|
1477
1161
|
const handleFieldChange = useCallback((field, value) => {
|
|
1478
1162
|
setFormState((s) => ({
|
|
1479
1163
|
...s,
|
|
@@ -1482,20 +1166,11 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1482
1166
|
}, []);
|
|
1483
1167
|
const handleSave = useCallback(() => {
|
|
1484
1168
|
updateProfileMutation.mutate({
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
facebook: formState.facebook,
|
|
1488
|
-
twitter: formState.twitter,
|
|
1489
|
-
instagram: formState.instagram,
|
|
1490
|
-
youtube: formState.youtube,
|
|
1491
|
-
pinterest: formState.pinterest,
|
|
1492
|
-
tiktok: formState.tiktok,
|
|
1493
|
-
whatsapp: formState.whatsapp,
|
|
1494
|
-
wechat: formState.wechat
|
|
1169
|
+
display_name: formState.display_name,
|
|
1170
|
+
bio: formState.bio
|
|
1495
1171
|
}, {
|
|
1496
1172
|
onSuccess: () => {
|
|
1497
1173
|
profileSyncedRef.current = false;
|
|
1498
|
-
queryClient.invalidateQueries({ queryKey: ["sdk-mysite", "me"] });
|
|
1499
1174
|
onToast?.("Profile updated successfully", "success");
|
|
1500
1175
|
},
|
|
1501
1176
|
onError: () => {
|
|
@@ -1505,7 +1180,6 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1505
1180
|
}, [
|
|
1506
1181
|
formState,
|
|
1507
1182
|
updateProfileMutation,
|
|
1508
|
-
queryClient,
|
|
1509
1183
|
onToast
|
|
1510
1184
|
]);
|
|
1511
1185
|
const fileInputRef = useRef(null);
|
|
@@ -1527,7 +1201,7 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1527
1201
|
setIsUploadingPhoto(true);
|
|
1528
1202
|
try {
|
|
1529
1203
|
const imageUrl = await onUploadPhoto(file);
|
|
1530
|
-
updateProfileMutation.mutate({
|
|
1204
|
+
updateProfileMutation.mutate({ avatar_url: imageUrl }, {
|
|
1531
1205
|
onSuccess: () => {
|
|
1532
1206
|
onToast?.("Profile photo updated", "success");
|
|
1533
1207
|
},
|
|
@@ -1555,7 +1229,7 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1555
1229
|
children: "Loading..."
|
|
1556
1230
|
})
|
|
1557
1231
|
});
|
|
1558
|
-
const displayAvatarUrl = previewUrl || avatarUrl;
|
|
1232
|
+
const displayAvatarUrl = previewUrl || avatarUrl || profile?.avatar_url;
|
|
1559
1233
|
return /* @__PURE__ */ jsxs("div", {
|
|
1560
1234
|
className: "space-y-4 p-4 sm:space-y-6 sm:p-6",
|
|
1561
1235
|
children: [
|
|
@@ -1604,6 +1278,25 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1604
1278
|
})]
|
|
1605
1279
|
})]
|
|
1606
1280
|
}),
|
|
1281
|
+
/* @__PURE__ */ jsxs(Card, {
|
|
1282
|
+
className: "p-4 sm:p-6",
|
|
1283
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
1284
|
+
className: "text-foreground mb-4 text-base font-semibold sm:text-lg",
|
|
1285
|
+
children: "Display Name"
|
|
1286
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1287
|
+
className: "space-y-2",
|
|
1288
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
1289
|
+
htmlFor: "profile-display-name",
|
|
1290
|
+
children: "Name shown on your MySite"
|
|
1291
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
1292
|
+
id: "profile-display-name",
|
|
1293
|
+
type: "text",
|
|
1294
|
+
value: formState.display_name,
|
|
1295
|
+
onChange: (e) => handleFieldChange("display_name", e.target.value),
|
|
1296
|
+
placeholder: "Your display name"
|
|
1297
|
+
})]
|
|
1298
|
+
})]
|
|
1299
|
+
}),
|
|
1607
1300
|
/* @__PURE__ */ jsxs(Card, {
|
|
1608
1301
|
className: "p-4 sm:p-6",
|
|
1609
1302
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
@@ -1623,28 +1316,6 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1623
1316
|
})]
|
|
1624
1317
|
})]
|
|
1625
1318
|
}),
|
|
1626
|
-
/* @__PURE__ */ jsxs(Card, {
|
|
1627
|
-
className: "p-4 sm:p-6",
|
|
1628
|
-
children: [/* @__PURE__ */ jsx("h2", {
|
|
1629
|
-
className: "text-foreground mb-4 text-base font-semibold sm:text-lg",
|
|
1630
|
-
children: "Social Media Links"
|
|
1631
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
1632
|
-
className: "space-y-4",
|
|
1633
|
-
children: socialFields.map((field) => /* @__PURE__ */ jsxs("div", {
|
|
1634
|
-
className: "space-y-2",
|
|
1635
|
-
children: [/* @__PURE__ */ jsx(Label, {
|
|
1636
|
-
htmlFor: `profile-${field.name}`,
|
|
1637
|
-
children: field.label
|
|
1638
|
-
}), /* @__PURE__ */ jsx(Input, {
|
|
1639
|
-
id: `profile-${field.name}`,
|
|
1640
|
-
type: "text",
|
|
1641
|
-
value: formState[field.name],
|
|
1642
|
-
onChange: (e) => handleFieldChange(field.name, e.target.value),
|
|
1643
|
-
placeholder: field.placeholder
|
|
1644
|
-
})]
|
|
1645
|
-
}, field.name))
|
|
1646
|
-
})]
|
|
1647
|
-
}),
|
|
1648
1319
|
/* @__PURE__ */ jsx("div", {
|
|
1649
1320
|
className: "flex justify-end",
|
|
1650
1321
|
children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -1685,7 +1356,7 @@ function defaultToast$1(message, type) {
|
|
|
1685
1356
|
if (type === "error") console.warn("[MySite]", message);
|
|
1686
1357
|
else console.info("[MySite]", message);
|
|
1687
1358
|
}
|
|
1688
|
-
function MySiteMainView(
|
|
1359
|
+
function MySiteMainView() {
|
|
1689
1360
|
const { navigate } = useAppNavigation();
|
|
1690
1361
|
const [animPhase, setAnimPhase] = useState("idle");
|
|
1691
1362
|
const [editingSection, setEditingSection] = useState(null);
|
|
@@ -1709,27 +1380,23 @@ function MySiteMainView({ client }) {
|
|
|
1709
1380
|
"exit-fade-out",
|
|
1710
1381
|
"exit-slide"
|
|
1711
1382
|
].includes(animPhase);
|
|
1712
|
-
const { data:
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
});
|
|
1716
|
-
const queryClient = useQueryClient();
|
|
1717
|
-
const { data: themes = [] } = useMySiteThemes(client);
|
|
1718
|
-
const updateMySiteMutation = useUpdateMySite(client);
|
|
1383
|
+
const { data: profile, isLoading: isProfileLoading } = usePortalMySiteProfile();
|
|
1384
|
+
const { data: themes = [] } = usePortalMySiteThemes();
|
|
1385
|
+
const updateSettingsMutation = usePortalUpdateSettings();
|
|
1719
1386
|
const [previewKey, setPreviewKey] = useState(0);
|
|
1720
1387
|
const refreshPreview = useCallback(() => setPreviewKey((k) => k + 1), []);
|
|
1721
1388
|
const [selectedThemeId, setSelectedThemeId] = useState(null);
|
|
1722
|
-
const resolvedThemeId = selectedThemeId ??
|
|
1389
|
+
const resolvedThemeId = selectedThemeId ?? profile?.theme_id ?? themes.find((t) => t.name === "Default")?.id ?? themes[0]?.id ?? null;
|
|
1723
1390
|
const themeName = themes.find((t) => t.id === resolvedThemeId)?.name ?? "Default";
|
|
1724
|
-
const mysiteUrl =
|
|
1391
|
+
const mysiteUrl = profile?.mysite_url ?? "";
|
|
1725
1392
|
const displayUrl = mysiteUrl ? mysiteUrl.replace(/^https?:\/\//, "") : "";
|
|
1726
|
-
const views =
|
|
1727
|
-
const leads =
|
|
1393
|
+
const views = profile?.mysite_views ?? 0;
|
|
1394
|
+
const leads = profile?.mysite_leads ?? 0;
|
|
1728
1395
|
const handleSelectTheme = useCallback((theme) => {
|
|
1729
1396
|
if (theme.id === resolvedThemeId) return;
|
|
1730
1397
|
const previousThemeId = selectedThemeId;
|
|
1731
1398
|
setSelectedThemeId(theme.id);
|
|
1732
|
-
|
|
1399
|
+
updateSettingsMutation.mutate({ theme_id: theme.id }, {
|
|
1733
1400
|
onSuccess: () => {
|
|
1734
1401
|
defaultToast$1(`Theme changed to "${theme.name}"`, "success");
|
|
1735
1402
|
refreshPreview();
|
|
@@ -1742,18 +1409,17 @@ function MySiteMainView({ client }) {
|
|
|
1742
1409
|
}, [
|
|
1743
1410
|
resolvedThemeId,
|
|
1744
1411
|
selectedThemeId,
|
|
1745
|
-
|
|
1412
|
+
updateSettingsMutation,
|
|
1746
1413
|
refreshPreview
|
|
1747
1414
|
]);
|
|
1748
1415
|
const handleUpdateSlug = useCallback(async (slug) => {
|
|
1749
1416
|
await new Promise((resolve, reject) => {
|
|
1750
|
-
|
|
1417
|
+
updateSettingsMutation.mutate({ slug }, {
|
|
1751
1418
|
onSuccess: () => resolve(),
|
|
1752
1419
|
onError: () => reject(/* @__PURE__ */ new Error("Failed"))
|
|
1753
1420
|
});
|
|
1754
1421
|
});
|
|
1755
|
-
|
|
1756
|
-
}, [updateMySiteMutation, queryClient]);
|
|
1422
|
+
}, [updateSettingsMutation]);
|
|
1757
1423
|
const handleEditSection = useCallback((section) => {
|
|
1758
1424
|
cancelScheduled();
|
|
1759
1425
|
setEditingSection(section);
|
|
@@ -1782,7 +1448,7 @@ function MySiteMainView({ client }) {
|
|
|
1782
1448
|
if (editingSection === "content") return "MySite Content";
|
|
1783
1449
|
return "";
|
|
1784
1450
|
}, [editingSection]);
|
|
1785
|
-
if (
|
|
1451
|
+
if (isProfileLoading) return /* @__PURE__ */ jsxs("div", {
|
|
1786
1452
|
className: "flex h-full overflow-hidden px-2 py-6",
|
|
1787
1453
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1788
1454
|
className: "w-full px-4 2xl:w-2/3 2xl:shrink-0",
|
|
@@ -1822,19 +1488,15 @@ function MySiteMainView({ client }) {
|
|
|
1822
1488
|
themes,
|
|
1823
1489
|
selectedThemeId: resolvedThemeId,
|
|
1824
1490
|
onSelectTheme: handleSelectTheme,
|
|
1825
|
-
isPending:
|
|
1491
|
+
isPending: updateSettingsMutation.isPending,
|
|
1826
1492
|
onBack: handleBackClick
|
|
1827
|
-
}) : showEditContent && editingSection === "buttons" ? /* @__PURE__ */ jsx(
|
|
1493
|
+
}) : showEditContent && editingSection === "buttons" ? /* @__PURE__ */ jsx(PortalButtonsEditor, {
|
|
1828
1494
|
onBack: handleBackClick,
|
|
1829
1495
|
onRefreshPreview: refreshPreview,
|
|
1830
|
-
client,
|
|
1831
|
-
userId: meProfile?.id,
|
|
1832
1496
|
onToast: defaultToast$1
|
|
1833
|
-
}) : showEditContent && editingSection === "content" ? /* @__PURE__ */ jsx(
|
|
1497
|
+
}) : showEditContent && editingSection === "content" ? /* @__PURE__ */ jsx(PortalFavoritesEditor, {
|
|
1834
1498
|
onBack: handleBackClick,
|
|
1835
1499
|
onRefreshPreview: refreshPreview,
|
|
1836
|
-
client,
|
|
1837
|
-
affiliateId: meProfile?.affiliate_id,
|
|
1838
1500
|
onToast: defaultToast$1
|
|
1839
1501
|
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1840
1502
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -1891,7 +1553,7 @@ function MySiteMainView({ client }) {
|
|
|
1891
1553
|
mysiteUrl,
|
|
1892
1554
|
themeName,
|
|
1893
1555
|
previewKey,
|
|
1894
|
-
isUpdating:
|
|
1556
|
+
isUpdating: updateSettingsMutation.isPending,
|
|
1895
1557
|
onPreview: handlePreview
|
|
1896
1558
|
})
|
|
1897
1559
|
})]
|
|
@@ -1903,10 +1565,9 @@ function defaultToast(message, type) {
|
|
|
1903
1565
|
if (type === "error") console.warn("[MySite]", message);
|
|
1904
1566
|
else console.info("[MySite]", message);
|
|
1905
1567
|
}
|
|
1906
|
-
function MySiteProfileView(
|
|
1568
|
+
function MySiteProfileView() {
|
|
1907
1569
|
const { navigate } = useAppNavigation();
|
|
1908
1570
|
return /* @__PURE__ */ jsx(MySiteProfileForm, {
|
|
1909
|
-
client,
|
|
1910
1571
|
onBack: () => navigate("my-site"),
|
|
1911
1572
|
onToast: defaultToast
|
|
1912
1573
|
});
|
|
@@ -1918,7 +1579,6 @@ var MySiteScreen_exports = /* @__PURE__ */ __exportAll({
|
|
|
1918
1579
|
mySiteScreenPropertySchema: () => mySiteScreenPropertySchema
|
|
1919
1580
|
});
|
|
1920
1581
|
function MySiteScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
1921
|
-
const client = usePortalMySiteClient();
|
|
1922
1582
|
const { currentSlug, navigate } = useAppNavigation();
|
|
1923
1583
|
const isProfileView = (currentSlug.split("/")[1] ?? null) === "profile";
|
|
1924
1584
|
useScreenHeaderBreadcrumbs(useMemo(() => /* @__PURE__ */ jsx(Breadcrumb, { children: /* @__PURE__ */ jsxs(BreadcrumbList, {
|
|
@@ -1941,7 +1601,7 @@ function MySiteScreen({ background, textColor, accentColor, padding, borderRadiu
|
|
|
1941
1601
|
return /* @__PURE__ */ jsx("div", {
|
|
1942
1602
|
...divProps,
|
|
1943
1603
|
className: `h-full ${divProps.className ?? ""}`,
|
|
1944
|
-
children: isProfileView ? /* @__PURE__ */ jsx(MySiteProfileView, {
|
|
1604
|
+
children: isProfileView ? /* @__PURE__ */ jsx(MySiteProfileView, {}) : /* @__PURE__ */ jsx(MySiteMainView, {})
|
|
1945
1605
|
});
|
|
1946
1606
|
}
|
|
1947
1607
|
const mySiteScreenPropertySchema = {
|
|
@@ -1956,4 +1616,4 @@ const mySiteScreenPropertySchema = {
|
|
|
1956
1616
|
//#endregion
|
|
1957
1617
|
export { MySiteScreen_exports as n, mySiteScreenPropertySchema as r, MySiteScreen as t };
|
|
1958
1618
|
|
|
1959
|
-
//# sourceMappingURL=MySiteScreen-
|
|
1619
|
+
//# sourceMappingURL=MySiteScreen-BEbj9K8U.mjs.map
|