@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,6 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_PortalTenantClientProvider = require("./PortalTenantClientProvider-C4Gnq5tJ.cjs");
|
|
2
|
+
const require_mysite_api_context = require("./mysite-api-context-BTt-_urb.cjs");
|
|
4
3
|
const require_src = require("./src-Bm9zqmV3.cjs");
|
|
5
4
|
const require_ScreenHeaderContext = require("./ScreenHeaderContext-DRIKmM2G.cjs");
|
|
6
5
|
const require_AppNavigationContext = require("./AppNavigationContext-r22AeKGk.cjs");
|
|
@@ -11,473 +10,139 @@ let _tanstack_react_query = require("@tanstack/react-query");
|
|
|
11
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
11
|
let lucide_react = require("lucide-react");
|
|
13
12
|
let zod = require("zod");
|
|
14
|
-
//#region src/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
mysite_theme_id: profile.theme_id ?? null,
|
|
28
|
-
mysite_theme: null,
|
|
29
|
-
bio: profile.bio ?? null,
|
|
30
|
-
facebook: null,
|
|
31
|
-
instagram: null,
|
|
32
|
-
twitter: null,
|
|
33
|
-
youtube: null,
|
|
34
|
-
pinterest: null,
|
|
35
|
-
tiktok: null,
|
|
36
|
-
linkedin: null,
|
|
37
|
-
whatsapp: null,
|
|
38
|
-
wechat: null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** BFF Link → old MySiteLink shape (must pass Zod: { id, url, text, order, clicks? }) */
|
|
42
|
-
function mapBffLink(link) {
|
|
43
|
-
return {
|
|
44
|
-
id: link.id,
|
|
45
|
-
url: link.url ?? "",
|
|
46
|
-
text: link.title ?? "",
|
|
47
|
-
order: link.position ?? 0,
|
|
48
|
-
clicks: 0
|
|
49
|
-
};
|
|
13
|
+
//#region ../../mysite/ui/src/portal/hooks/use-mysite-portal.ts
|
|
14
|
+
const PORTAL_MYSITE_KEYS = {
|
|
15
|
+
profile: () => ["portal-mysite", "profile"],
|
|
16
|
+
links: () => ["portal-mysite", "links"],
|
|
17
|
+
favorites: () => ["portal-mysite", "favorites"],
|
|
18
|
+
themes: () => ["portal-mysite", "themes"]
|
|
19
|
+
};
|
|
20
|
+
function usePortalMySiteProfile() {
|
|
21
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
22
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
23
|
+
queryKey: PORTAL_MYSITE_KEYS.profile(),
|
|
24
|
+
queryFn: () => api.fetchProfile()
|
|
25
|
+
});
|
|
50
26
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
created_at: fav.created_at,
|
|
60
|
-
favoriteable: {
|
|
61
|
-
id: fav.product_id,
|
|
62
|
-
title: fav.product_name ?? null,
|
|
63
|
-
name: fav.product_name ?? null,
|
|
64
|
-
image_url: fav.product_image_url ?? null,
|
|
65
|
-
type: "Product"
|
|
27
|
+
function usePortalUpdateProfile(options) {
|
|
28
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
29
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
30
|
+
return (0, _tanstack_react_query.useMutation)({
|
|
31
|
+
mutationFn: (body) => api.updateProfile(body),
|
|
32
|
+
onSuccess: () => {
|
|
33
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.profile() });
|
|
34
|
+
options?.onSuccess?.();
|
|
66
35
|
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/** BFF Theme → old MysiteTheme shape (must pass Zod themeSchema) */
|
|
70
|
-
function mapBffTheme(theme) {
|
|
71
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
72
|
-
return {
|
|
73
|
-
id: theme.id,
|
|
74
|
-
name: theme.name ?? "Untitled",
|
|
75
|
-
description: null,
|
|
76
|
-
public: true,
|
|
77
|
-
company_id: null,
|
|
78
|
-
created_at: now,
|
|
79
|
-
updated_at: now,
|
|
80
|
-
image_url: theme.preview_url ?? null,
|
|
81
|
-
application_theme_template_id: null
|
|
82
|
-
};
|
|
36
|
+
});
|
|
83
37
|
}
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* to portal-tenant MySite BFF endpoints.
|
|
93
|
-
*
|
|
94
|
-
* @param bffClient - A FetchClient pointed at the tenant BFF origin
|
|
95
|
-
* (e.g. https://acme.portal.fluid.app, **without** /api suffix — the
|
|
96
|
-
* generated namespace functions already include /api/mysite/... paths).
|
|
97
|
-
*/
|
|
98
|
-
function createPortalMySiteAdapter(bffClient) {
|
|
99
|
-
async function get(endpoint, params, options) {
|
|
100
|
-
if (endpoint === "/me.json") return mapProfileToMe((await require_portal_tenant_mysite.mysite_profile_show(bffClient)).profile ?? {});
|
|
101
|
-
if (endpoint === "/mysite/themes") return ((await require_portal_tenant_mysite.mysite_themes_list(bffClient)).themes ?? []).map(mapBffTheme);
|
|
102
|
-
if (LINKS_LIST.test(endpoint)) return ((await require_portal_tenant_mysite.mysite_links_list(bffClient)).links ?? []).map(mapBffLink);
|
|
103
|
-
if (FAVORITES_LIST.test(endpoint)) return ((await require_portal_tenant_mysite.mysite_favorites_list(bffClient)).favorites ?? []).map(mapBffFavorite);
|
|
104
|
-
return bffClient.get(endpoint, params, options);
|
|
105
|
-
}
|
|
106
|
-
async function post(endpoint, body, options) {
|
|
107
|
-
if (LINKS_LIST.test(endpoint)) {
|
|
108
|
-
const b = body;
|
|
109
|
-
return mapBffLink((await require_portal_tenant_mysite.mysite_links_create(bffClient, { link: {
|
|
110
|
-
title: b?.text ?? "",
|
|
111
|
-
url: b?.url ?? ""
|
|
112
|
-
} })).link ?? {});
|
|
113
|
-
}
|
|
114
|
-
if (FAVORITES_LIST.test(endpoint)) {
|
|
115
|
-
const b = body;
|
|
116
|
-
return mapBffFavorite((await require_portal_tenant_mysite.mysite_favorites_create(bffClient, { favorite: { product_id: b?.favorite?.favoriteable_id ?? 0 } })).favorite ?? {});
|
|
117
|
-
}
|
|
118
|
-
return bffClient.post(endpoint, body, options);
|
|
119
|
-
}
|
|
120
|
-
async function put(endpoint, body, options) {
|
|
121
|
-
if (endpoint === "/me.json") {
|
|
122
|
-
const b = body;
|
|
123
|
-
return mapProfileToMe((await require_portal_tenant_mysite.mysite_profile_update(bffClient, { profile: {
|
|
124
|
-
display_name: b?.display_name ?? void 0,
|
|
125
|
-
bio: b?.bio ?? void 0,
|
|
126
|
-
avatar_url: b?.image_url ?? b?.avatar_url ?? void 0
|
|
127
|
-
} })).profile ?? {});
|
|
128
|
-
}
|
|
129
|
-
if (endpoint === "/mysite.json") {
|
|
130
|
-
const uc = body?.user_company;
|
|
131
|
-
if (uc?.theme_id !== void 0) return {
|
|
132
|
-
id: 0,
|
|
133
|
-
...(await require_portal_tenant_mysite.mysite_settings_update(bffClient, { settings: { theme_id: uc.theme_id } })).settings ?? {}
|
|
134
|
-
};
|
|
135
|
-
if (uc?.username !== void 0) {
|
|
136
|
-
const profile = (await require_portal_tenant_mysite.mysite_profile_update(bffClient, { profile: { slug: uc.username } })).profile ?? {};
|
|
137
|
-
return {
|
|
138
|
-
id: profile.id ?? 0,
|
|
139
|
-
...profile
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
return { id: 0 };
|
|
143
|
-
}
|
|
144
|
-
const linkMatch = endpoint.match(LINK_SINGLE);
|
|
145
|
-
if (linkMatch) {
|
|
146
|
-
const linkId = Number(linkMatch[1]);
|
|
147
|
-
const b = body;
|
|
148
|
-
return mapBffLink((await require_portal_tenant_mysite.mysite_links_update(bffClient, linkId, { link: {
|
|
149
|
-
title: b?.text,
|
|
150
|
-
url: b?.url
|
|
151
|
-
} })).link ?? {});
|
|
152
|
-
}
|
|
153
|
-
return bffClient.put(endpoint, body, options);
|
|
154
|
-
}
|
|
155
|
-
async function patch(endpoint, body, options) {
|
|
156
|
-
if (LINKS_REORDER.test(endpoint)) {
|
|
157
|
-
const items = body?.links ?? [];
|
|
158
|
-
if (items.length === 0) return [];
|
|
159
|
-
const sortedIds = [...items].sort((a, b2) => a.order - b2.order).map((l) => l.id);
|
|
160
|
-
return ((await require_portal_tenant_mysite.mysite_links_bulk_reorder(bffClient, { ordered_ids: sortedIds })).links ?? []).map(mapBffLink);
|
|
161
|
-
}
|
|
162
|
-
if (FAVORITES_REORDER.test(endpoint)) {
|
|
163
|
-
const items = body?.favorites ?? [];
|
|
164
|
-
if (items.length === 0) return [];
|
|
165
|
-
const sortedIds = [...items].sort((a, b2) => a.order - b2.order).map((f) => f.id);
|
|
166
|
-
return ((await require_portal_tenant_mysite.mysite_favorites_bulk_reorder(bffClient, { ordered_ids: sortedIds })).favorites ?? []).map(mapBffFavorite);
|
|
167
|
-
}
|
|
168
|
-
return bffClient.patch(endpoint, body, options);
|
|
169
|
-
}
|
|
170
|
-
async function del(endpoint, options) {
|
|
171
|
-
const linkMatch = endpoint.match(LINK_SINGLE);
|
|
172
|
-
if (linkMatch) {
|
|
173
|
-
const linkId = Number(linkMatch[1]);
|
|
174
|
-
return require_portal_tenant_mysite.mysite_links_destroy(bffClient, linkId);
|
|
175
|
-
}
|
|
176
|
-
const favMatch = endpoint.match(FAVORITE_SINGLE);
|
|
177
|
-
if (favMatch) {
|
|
178
|
-
const favId = Number(favMatch[1]);
|
|
179
|
-
return require_portal_tenant_mysite.mysite_favorites_destroy(bffClient, favId);
|
|
38
|
+
function usePortalUpdateSettings(options) {
|
|
39
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
40
|
+
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
41
|
+
return (0, _tanstack_react_query.useMutation)({
|
|
42
|
+
mutationFn: (body) => api.updateSettings(body),
|
|
43
|
+
onSuccess: () => {
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.profile() });
|
|
45
|
+
options?.onSuccess?.();
|
|
180
46
|
}
|
|
181
|
-
return bffClient.delete(endpoint, options);
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
request: bffClient.request,
|
|
185
|
-
requestWithFormData: bffClient.requestWithFormData,
|
|
186
|
-
get,
|
|
187
|
-
post,
|
|
188
|
-
put,
|
|
189
|
-
patch,
|
|
190
|
-
delete: del
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/mysite/use-portal-mysite-client.ts
|
|
195
|
-
/**
|
|
196
|
-
* Hook that returns a FetchClient adapter translating legacy mysite API
|
|
197
|
-
* calls to the portal-tenant MySite BFF.
|
|
198
|
-
*
|
|
199
|
-
* The adapter wraps the shared portal-tenant FetchClient so that existing
|
|
200
|
-
* mysite-ui hooks and components (which call `/me.json`, `/users/{id}/links.json`,
|
|
201
|
-
* etc.) work transparently against the BFF endpoints.
|
|
202
|
-
*/
|
|
203
|
-
function usePortalMySiteClient() {
|
|
204
|
-
const bffClient = require_PortalTenantClientProvider.usePortalTenantClient();
|
|
205
|
-
return (0, react.useMemo)(() => createPortalMySiteAdapter(bffClient), [bffClient]);
|
|
206
|
-
}
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region ../../mysite/ui/src/shared/query-keys.ts
|
|
209
|
-
const MYSITE_KEYS = {
|
|
210
|
-
links: (userId) => [
|
|
211
|
-
"mysite",
|
|
212
|
-
"links",
|
|
213
|
-
userId
|
|
214
|
-
],
|
|
215
|
-
favorites: (affiliateId) => [
|
|
216
|
-
"mysite",
|
|
217
|
-
"favorites",
|
|
218
|
-
affiliateId
|
|
219
|
-
],
|
|
220
|
-
themes: () => ["mysite", "themes"],
|
|
221
|
-
defaultMySite: () => ["mysite", "default"],
|
|
222
|
-
defaultMySiteFavorites: () => [
|
|
223
|
-
"mysite",
|
|
224
|
-
"default",
|
|
225
|
-
"favorites"
|
|
226
|
-
]
|
|
227
|
-
};
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region ../../mysite/ui/src/shared/schemas/mysite.schema.ts
|
|
230
|
-
const linkSchema = zod.z.object({
|
|
231
|
-
id: zod.z.number(),
|
|
232
|
-
url: zod.z.string(),
|
|
233
|
-
text: zod.z.string(),
|
|
234
|
-
order: zod.z.number(),
|
|
235
|
-
clicks: zod.z.number().optional().default(0)
|
|
236
|
-
});
|
|
237
|
-
const linksResponseSchema = zod.z.array(linkSchema);
|
|
238
|
-
const favoriteableSchema = zod.z.object({
|
|
239
|
-
id: zod.z.number(),
|
|
240
|
-
title: zod.z.string().nullable().optional(),
|
|
241
|
-
name: zod.z.string().nullable().optional(),
|
|
242
|
-
image_url: zod.z.string().nullable().optional(),
|
|
243
|
-
type: zod.z.string().optional()
|
|
244
|
-
}).passthrough();
|
|
245
|
-
const favoriteSchema = zod.z.object({
|
|
246
|
-
id: zod.z.number(),
|
|
247
|
-
favoriteable_id: zod.z.number().optional(),
|
|
248
|
-
favoriteable_type: zod.z.string(),
|
|
249
|
-
order: zod.z.number(),
|
|
250
|
-
user_company_id: zod.z.number().optional(),
|
|
251
|
-
created_at: zod.z.string().optional(),
|
|
252
|
-
favoriteable: favoriteableSchema.nullable()
|
|
253
|
-
}).passthrough();
|
|
254
|
-
const favoritesResponseSchema = zod.z.array(favoriteSchema);
|
|
255
|
-
const mysiteUpdateResponseSchema = zod.z.object({ id: zod.z.number() }).passthrough();
|
|
256
|
-
const profileUpdateResponseSchema = zod.z.object({
|
|
257
|
-
id: zod.z.number(),
|
|
258
|
-
bio: zod.z.string().nullable(),
|
|
259
|
-
facebook: zod.z.string().nullable(),
|
|
260
|
-
twitter: zod.z.string().nullable(),
|
|
261
|
-
instagram: zod.z.string().nullable(),
|
|
262
|
-
youtube: zod.z.string().nullable(),
|
|
263
|
-
pinterest: zod.z.string().nullable(),
|
|
264
|
-
tiktok: zod.z.string().nullable(),
|
|
265
|
-
linkedin: zod.z.string().nullable(),
|
|
266
|
-
whatsapp: zod.z.string().nullable(),
|
|
267
|
-
wechat: zod.z.string().nullable(),
|
|
268
|
-
image_url: zod.z.string().nullable()
|
|
269
|
-
});
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region ../../mysite/ui/src/admin/networking/mysite.api.ts
|
|
272
|
-
async function getUserLinks(client, userId) {
|
|
273
|
-
const response = await client.get(`/users/${userId}/links.json`);
|
|
274
|
-
return linksResponseSchema.parse(response);
|
|
275
|
-
}
|
|
276
|
-
async function createUserLink(client, userId, data) {
|
|
277
|
-
const response = await client.post(`/users/${userId}/links.json`, data);
|
|
278
|
-
const result = linkSchema.safeParse(response);
|
|
279
|
-
return result.success ? result.data : response;
|
|
280
|
-
}
|
|
281
|
-
async function updateUserLink(client, userId, linkId, data) {
|
|
282
|
-
const response = await client.put(`/users/${userId}/links/${linkId}.json`, data);
|
|
283
|
-
const result = linkSchema.safeParse(response);
|
|
284
|
-
return result.success ? result.data : response;
|
|
285
|
-
}
|
|
286
|
-
async function deleteUserLink(client, userId, linkId) {
|
|
287
|
-
return client.delete(`/users/${userId}/links/${linkId}.json`);
|
|
288
|
-
}
|
|
289
|
-
async function reorderUserLinks(client, userId, links) {
|
|
290
|
-
const response = await client.patch(`/users/${userId}/links/bulk_reorder.json`, { links });
|
|
291
|
-
const reorderResult = linksResponseSchema.safeParse(response);
|
|
292
|
-
return reorderResult.success ? reorderResult.data : response;
|
|
293
|
-
}
|
|
294
|
-
async function getUserFavorites(client, affiliateId) {
|
|
295
|
-
const response = await client.get(`/user_companies/${affiliateId}/favorites.json`);
|
|
296
|
-
return favoritesResponseSchema.parse(response);
|
|
297
|
-
}
|
|
298
|
-
async function deleteFavorite(client, affiliateId, favoriteId) {
|
|
299
|
-
return client.delete(`/user_companies/${affiliateId}/favorites/${favoriteId}.json`);
|
|
300
|
-
}
|
|
301
|
-
async function reorderFavorites(client, affiliateId, favorites, countryId, languageIso) {
|
|
302
|
-
const response = await client.patch(`/user_companies/${affiliateId}/favorites/bulk_reorder.json`, {
|
|
303
|
-
favorites,
|
|
304
|
-
country_id: countryId,
|
|
305
|
-
language_iso: languageIso
|
|
306
47
|
});
|
|
307
|
-
const reorderFavResult = favoritesResponseSchema.safeParse(response);
|
|
308
|
-
return reorderFavResult.success ? reorderFavResult.data : response;
|
|
309
|
-
}
|
|
310
|
-
async function updateMySite(client, data) {
|
|
311
|
-
const response = await client.put("/mysite.json", { user_company: data });
|
|
312
|
-
const mysiteResult = mysiteUpdateResponseSchema.safeParse(response);
|
|
313
|
-
return mysiteResult.success ? mysiteResult.data : response;
|
|
314
|
-
}
|
|
315
|
-
async function updateProfile(client, data) {
|
|
316
|
-
const response = await client.put("/me.json", data);
|
|
317
|
-
const profileResult = profileUpdateResponseSchema.safeParse(response);
|
|
318
|
-
return profileResult.success ? profileResult.data : response;
|
|
319
|
-
}
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region ../../mysite/ui/src/shared/schemas/mysite-theme.schema.ts
|
|
322
|
-
const themeSchema = zod.z.object({
|
|
323
|
-
id: zod.z.number(),
|
|
324
|
-
name: zod.z.string(),
|
|
325
|
-
description: zod.z.string().nullable(),
|
|
326
|
-
public: zod.z.boolean(),
|
|
327
|
-
company_id: zod.z.number().nullable(),
|
|
328
|
-
created_at: zod.z.string().datetime(),
|
|
329
|
-
updated_at: zod.z.string().datetime(),
|
|
330
|
-
image_url: zod.z.string().nullable(),
|
|
331
|
-
application_theme_template_id: zod.z.number().nullable()
|
|
332
|
-
});
|
|
333
|
-
const mysiteThemesSchema = zod.z.array(themeSchema);
|
|
334
|
-
const legacyThemeTemplateSchema = zod.z.object({
|
|
335
|
-
id: zod.z.number(),
|
|
336
|
-
name: zod.z.string(),
|
|
337
|
-
content: zod.z.string().nullable(),
|
|
338
|
-
stylesheet: zod.z.string().nullable(),
|
|
339
|
-
head: zod.z.string().nullable(),
|
|
340
|
-
status: zod.z.string()
|
|
341
|
-
});
|
|
342
|
-
zod.z.object({ data: zod.z.object({ legacy_theme: zod.z.object({
|
|
343
|
-
id: zod.z.number(),
|
|
344
|
-
name: zod.z.string(),
|
|
345
|
-
description: zod.z.string().nullable(),
|
|
346
|
-
image_url: zod.z.string().nullable(),
|
|
347
|
-
public: zod.z.boolean(),
|
|
348
|
-
company_id: zod.z.number().nullable(),
|
|
349
|
-
template: legacyThemeTemplateSchema
|
|
350
|
-
}) }) });
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region ../../mysite/ui/src/admin/networking/mysite-theme.api.ts
|
|
353
|
-
async function getMysiteThemes(client) {
|
|
354
|
-
const response = await client.get("/mysite/themes");
|
|
355
|
-
return mysiteThemesSchema.parse(response);
|
|
356
48
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
function useUserLinks(client, userId) {
|
|
49
|
+
function usePortalLinks() {
|
|
50
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
360
51
|
return (0, _tanstack_react_query.useQuery)({
|
|
361
|
-
queryKey:
|
|
362
|
-
queryFn: () =>
|
|
363
|
-
enabled: !!userId
|
|
52
|
+
queryKey: PORTAL_MYSITE_KEYS.links(),
|
|
53
|
+
queryFn: () => api.listLinks()
|
|
364
54
|
});
|
|
365
55
|
}
|
|
366
|
-
function
|
|
56
|
+
function usePortalCreateLink() {
|
|
57
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
367
58
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
368
59
|
return (0, _tanstack_react_query.useMutation)({
|
|
369
|
-
mutationFn: (
|
|
370
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
371
|
-
return createUserLink(client, userId, data);
|
|
372
|
-
},
|
|
60
|
+
mutationFn: (body) => api.createLink(body),
|
|
373
61
|
onSuccess: () => {
|
|
374
|
-
|
|
62
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
375
63
|
}
|
|
376
64
|
});
|
|
377
65
|
}
|
|
378
|
-
function
|
|
66
|
+
function usePortalUpdateLink() {
|
|
67
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
379
68
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
380
69
|
return (0, _tanstack_react_query.useMutation)({
|
|
381
|
-
mutationFn: ({ linkId,
|
|
382
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
383
|
-
return updateUserLink(client, userId, linkId, data);
|
|
384
|
-
},
|
|
70
|
+
mutationFn: ({ linkId, body }) => api.updateLink(linkId, body),
|
|
385
71
|
onSuccess: () => {
|
|
386
|
-
|
|
72
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
387
73
|
}
|
|
388
74
|
});
|
|
389
75
|
}
|
|
390
|
-
function
|
|
76
|
+
function usePortalDeleteLink() {
|
|
77
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
391
78
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
392
79
|
return (0, _tanstack_react_query.useMutation)({
|
|
393
|
-
mutationFn: (linkId) =>
|
|
394
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
395
|
-
return deleteUserLink(client, userId, linkId);
|
|
396
|
-
},
|
|
80
|
+
mutationFn: (linkId) => api.deleteLink(linkId),
|
|
397
81
|
onSuccess: () => {
|
|
398
|
-
|
|
82
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
399
83
|
}
|
|
400
84
|
});
|
|
401
85
|
}
|
|
402
|
-
function
|
|
86
|
+
function usePortalReorderLinks() {
|
|
87
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
403
88
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
404
89
|
return (0, _tanstack_react_query.useMutation)({
|
|
405
|
-
mutationFn: ({
|
|
406
|
-
if (!userId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
407
|
-
return reorderUserLinks(client, userId, payload);
|
|
408
|
-
},
|
|
90
|
+
mutationFn: ({ orderedIds }) => api.reorderLinks(orderedIds),
|
|
409
91
|
onMutate: async ({ optimisticItems }) => {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
queryClient.setQueryData(MYSITE_KEYS.links(userId), optimisticItems);
|
|
92
|
+
await queryClient.cancelQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
93
|
+
const previousData = queryClient.getQueryData(PORTAL_MYSITE_KEYS.links());
|
|
94
|
+
queryClient.setQueryData(PORTAL_MYSITE_KEYS.links(), optimisticItems);
|
|
414
95
|
return { previousData };
|
|
415
96
|
},
|
|
416
97
|
onError: (_err, _vars, context) => {
|
|
417
|
-
if (
|
|
98
|
+
if (context?.previousData) queryClient.setQueryData(PORTAL_MYSITE_KEYS.links(), context.previousData);
|
|
418
99
|
},
|
|
419
100
|
onSettled: () => {
|
|
420
|
-
|
|
101
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.links() });
|
|
421
102
|
}
|
|
422
103
|
});
|
|
423
104
|
}
|
|
424
|
-
function
|
|
105
|
+
function usePortalFavorites() {
|
|
106
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
425
107
|
return (0, _tanstack_react_query.useQuery)({
|
|
426
|
-
queryKey:
|
|
427
|
-
queryFn: () =>
|
|
428
|
-
enabled: !!affiliateId
|
|
108
|
+
queryKey: PORTAL_MYSITE_KEYS.favorites(),
|
|
109
|
+
queryFn: () => api.listFavorites()
|
|
429
110
|
});
|
|
430
111
|
}
|
|
431
|
-
function
|
|
112
|
+
function usePortalDeleteFavorite() {
|
|
113
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
432
114
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
433
115
|
return (0, _tanstack_react_query.useMutation)({
|
|
434
|
-
mutationFn: (favoriteId) =>
|
|
435
|
-
if (!affiliateId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
436
|
-
return deleteFavorite(client, affiliateId, favoriteId);
|
|
437
|
-
},
|
|
116
|
+
mutationFn: (favoriteId) => api.deleteFavorite(favoriteId),
|
|
438
117
|
onSuccess: () => {
|
|
439
|
-
|
|
118
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
440
119
|
}
|
|
441
120
|
});
|
|
442
121
|
}
|
|
443
|
-
function
|
|
122
|
+
function usePortalReorderFavorites() {
|
|
123
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
444
124
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
445
125
|
return (0, _tanstack_react_query.useMutation)({
|
|
446
|
-
mutationFn: ({
|
|
447
|
-
if (!affiliateId) return Promise.reject(/* @__PURE__ */ new Error("User not loaded"));
|
|
448
|
-
return reorderFavorites(client, affiliateId, payload);
|
|
449
|
-
},
|
|
126
|
+
mutationFn: ({ orderedIds }) => api.reorderFavorites(orderedIds),
|
|
450
127
|
onMutate: async ({ optimisticItems }) => {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
queryClient.setQueryData(MYSITE_KEYS.favorites(affiliateId), optimisticItems);
|
|
128
|
+
await queryClient.cancelQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
129
|
+
const previousData = queryClient.getQueryData(PORTAL_MYSITE_KEYS.favorites());
|
|
130
|
+
queryClient.setQueryData(PORTAL_MYSITE_KEYS.favorites(), optimisticItems);
|
|
455
131
|
return { previousData };
|
|
456
132
|
},
|
|
457
133
|
onError: (_err, _vars, context) => {
|
|
458
|
-
if (
|
|
134
|
+
if (context?.previousData) queryClient.setQueryData(PORTAL_MYSITE_KEYS.favorites(), context.previousData);
|
|
459
135
|
},
|
|
460
136
|
onSettled: () => {
|
|
461
|
-
|
|
137
|
+
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
462
138
|
}
|
|
463
139
|
});
|
|
464
140
|
}
|
|
465
|
-
function
|
|
141
|
+
function usePortalMySiteThemes() {
|
|
142
|
+
const api = require_mysite_api_context.useMySiteApi();
|
|
466
143
|
return (0, _tanstack_react_query.useQuery)({
|
|
467
|
-
queryKey:
|
|
468
|
-
queryFn: () =>
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
function useUpdateMySite(client, options) {
|
|
472
|
-
return (0, _tanstack_react_query.useMutation)({
|
|
473
|
-
mutationFn: (data) => updateMySite(client, data),
|
|
474
|
-
onSuccess: () => options?.onProfileRefetch?.()
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
function useUpdateProfile(client, options) {
|
|
478
|
-
return (0, _tanstack_react_query.useMutation)({
|
|
479
|
-
mutationFn: (data) => updateProfile(client, data),
|
|
480
|
-
onSuccess: () => options?.onProfileRefetch?.()
|
|
144
|
+
queryKey: PORTAL_MYSITE_KEYS.themes(),
|
|
145
|
+
queryFn: () => api.listThemes()
|
|
481
146
|
});
|
|
482
147
|
}
|
|
483
148
|
//#endregion
|
|
@@ -802,6 +467,7 @@ function MySiteThemeEditor({ themes, selectedThemeId, onSelectTheme, isPending,
|
|
|
802
467
|
className: "grid grid-cols-2 gap-4 sm:grid-cols-3",
|
|
803
468
|
children: themes.map((theme) => {
|
|
804
469
|
const isSelected = theme.id === selectedThemeId;
|
|
470
|
+
const imageUrl = theme.preview_url ?? theme.image_url;
|
|
805
471
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
806
472
|
type: "button",
|
|
807
473
|
onClick: () => onSelectTheme(theme),
|
|
@@ -811,8 +477,8 @@ function MySiteThemeEditor({ themes, selectedThemeId, onSelectTheme, isPending,
|
|
|
811
477
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
812
478
|
className: "bg-muted relative aspect-[4/3] w-full",
|
|
813
479
|
children: [
|
|
814
|
-
|
|
815
|
-
src:
|
|
480
|
+
imageUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
481
|
+
src: imageUrl,
|
|
816
482
|
alt: theme.name,
|
|
817
483
|
loading: "lazy",
|
|
818
484
|
className: "absolute inset-0 h-full w-full object-cover"
|
|
@@ -841,6 +507,79 @@ function MySiteThemeEditor({ themes, selectedThemeId, onSelectTheme, isPending,
|
|
|
841
507
|
})] });
|
|
842
508
|
}
|
|
843
509
|
//#endregion
|
|
510
|
+
//#region ../../mysite/ui/src/shared/schemas/mysite.schema.ts
|
|
511
|
+
const linkSchema = zod.z.object({
|
|
512
|
+
id: zod.z.number(),
|
|
513
|
+
url: zod.z.string(),
|
|
514
|
+
text: zod.z.string(),
|
|
515
|
+
order: zod.z.number(),
|
|
516
|
+
clicks: zod.z.number().optional().default(0)
|
|
517
|
+
});
|
|
518
|
+
zod.z.array(linkSchema);
|
|
519
|
+
const favoriteableSchema = zod.z.object({
|
|
520
|
+
id: zod.z.number(),
|
|
521
|
+
title: zod.z.string().nullable().optional(),
|
|
522
|
+
name: zod.z.string().nullable().optional(),
|
|
523
|
+
image_url: zod.z.string().nullable().optional(),
|
|
524
|
+
type: zod.z.string().optional()
|
|
525
|
+
}).passthrough();
|
|
526
|
+
const favoriteSchema = zod.z.object({
|
|
527
|
+
id: zod.z.number(),
|
|
528
|
+
favoriteable_id: zod.z.number().optional(),
|
|
529
|
+
favoriteable_type: zod.z.string(),
|
|
530
|
+
order: zod.z.number(),
|
|
531
|
+
user_company_id: zod.z.number().optional(),
|
|
532
|
+
created_at: zod.z.string().optional(),
|
|
533
|
+
favoriteable: favoriteableSchema.nullable()
|
|
534
|
+
}).passthrough();
|
|
535
|
+
zod.z.array(favoriteSchema);
|
|
536
|
+
zod.z.object({ id: zod.z.number() }).passthrough();
|
|
537
|
+
zod.z.object({
|
|
538
|
+
id: zod.z.number(),
|
|
539
|
+
bio: zod.z.string().nullable(),
|
|
540
|
+
facebook: zod.z.string().nullable(),
|
|
541
|
+
twitter: zod.z.string().nullable(),
|
|
542
|
+
instagram: zod.z.string().nullable(),
|
|
543
|
+
youtube: zod.z.string().nullable(),
|
|
544
|
+
pinterest: zod.z.string().nullable(),
|
|
545
|
+
tiktok: zod.z.string().nullable(),
|
|
546
|
+
linkedin: zod.z.string().nullable(),
|
|
547
|
+
whatsapp: zod.z.string().nullable(),
|
|
548
|
+
wechat: zod.z.string().nullable(),
|
|
549
|
+
image_url: zod.z.string().nullable()
|
|
550
|
+
});
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region ../../mysite/ui/src/shared/schemas/mysite-theme.schema.ts
|
|
553
|
+
const themeSchema = zod.z.object({
|
|
554
|
+
id: zod.z.number(),
|
|
555
|
+
name: zod.z.string(),
|
|
556
|
+
description: zod.z.string().nullable(),
|
|
557
|
+
public: zod.z.boolean(),
|
|
558
|
+
company_id: zod.z.number().nullable(),
|
|
559
|
+
created_at: zod.z.string().datetime(),
|
|
560
|
+
updated_at: zod.z.string().datetime(),
|
|
561
|
+
image_url: zod.z.string().nullable(),
|
|
562
|
+
application_theme_template_id: zod.z.number().nullable()
|
|
563
|
+
});
|
|
564
|
+
zod.z.array(themeSchema);
|
|
565
|
+
const legacyThemeTemplateSchema = zod.z.object({
|
|
566
|
+
id: zod.z.number(),
|
|
567
|
+
name: zod.z.string(),
|
|
568
|
+
content: zod.z.string().nullable(),
|
|
569
|
+
stylesheet: zod.z.string().nullable(),
|
|
570
|
+
head: zod.z.string().nullable(),
|
|
571
|
+
status: zod.z.string()
|
|
572
|
+
});
|
|
573
|
+
zod.z.object({ data: zod.z.object({ legacy_theme: zod.z.object({
|
|
574
|
+
id: zod.z.number(),
|
|
575
|
+
name: zod.z.string(),
|
|
576
|
+
description: zod.z.string().nullable(),
|
|
577
|
+
image_url: zod.z.string().nullable(),
|
|
578
|
+
public: zod.z.boolean(),
|
|
579
|
+
company_id: zod.z.number().nullable(),
|
|
580
|
+
template: legacyThemeTemplateSchema
|
|
581
|
+
}) }) });
|
|
582
|
+
//#endregion
|
|
844
583
|
//#region ../../mysite/ui/src/shared/utils.ts
|
|
845
584
|
function normalizeUrl(value) {
|
|
846
585
|
const trimmed = value.trim();
|
|
@@ -853,10 +592,16 @@ function normalizeUrl(value) {
|
|
|
853
592
|
var import_dist = require_dist$3.require_dist$1();
|
|
854
593
|
var import_dist$1 = require_dist$3.require_dist();
|
|
855
594
|
var import_dist$2 = require_dist$3.require_dist$2();
|
|
856
|
-
|
|
595
|
+
zod.z.object({
|
|
857
596
|
text: zod.z.string().min(1, "Button text is required"),
|
|
858
597
|
url: zod.z.string().transform(normalizeUrl).pipe(zod.z.string().url("Must be a valid URL"))
|
|
859
598
|
});
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region ../../mysite/ui/src/portal/components/PortalButtonsEditor.tsx
|
|
601
|
+
const buttonSchema = zod.z.object({
|
|
602
|
+
title: zod.z.string().min(1, "Button text is required"),
|
|
603
|
+
url: zod.z.string().transform(normalizeUrl).pipe(zod.z.string().url("Must be a valid URL"))
|
|
604
|
+
});
|
|
860
605
|
function SortableButtonCard({ link, onEdit, onDelete }) {
|
|
861
606
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = (0, import_dist$1.useSortable)({ id: link.id });
|
|
862
607
|
const style = {
|
|
@@ -881,17 +626,12 @@ function SortableButtonCard({ link, onEdit, onDelete }) {
|
|
|
881
626
|
className: "min-w-0 flex-1",
|
|
882
627
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
883
628
|
className: "text-foreground truncate font-medium",
|
|
884
|
-
children: link.
|
|
629
|
+
children: link.title
|
|
885
630
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
886
631
|
className: "text-muted-foreground truncate text-sm",
|
|
887
632
|
children: truncatedUrl
|
|
888
633
|
})]
|
|
889
634
|
}),
|
|
890
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.Badge, {
|
|
891
|
-
variant: "secondary",
|
|
892
|
-
className: "hidden shrink-0 sm:inline-flex",
|
|
893
|
-
children: [link.clicks ?? 0, " clicks"]
|
|
894
|
-
}),
|
|
895
635
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
896
636
|
className: "flex shrink-0 items-center gap-1",
|
|
897
637
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
|
|
@@ -913,26 +653,30 @@ function SortableButtonCard({ link, onEdit, onDelete }) {
|
|
|
913
653
|
]
|
|
914
654
|
});
|
|
915
655
|
}
|
|
916
|
-
|
|
656
|
+
/**
|
|
657
|
+
* Portal-specific buttons editor that uses MySiteApi context.
|
|
658
|
+
* No client/userId props needed — data comes from context.
|
|
659
|
+
*/
|
|
660
|
+
function PortalButtonsEditor({ onBack, onRefreshPreview, onToast }) {
|
|
917
661
|
"use no memo";
|
|
918
|
-
const { data: links = [], isLoading } =
|
|
919
|
-
const createLinkMutation =
|
|
920
|
-
const updateLinkMutation =
|
|
921
|
-
const deleteLinkMutation =
|
|
922
|
-
const reorderLinksMutation =
|
|
662
|
+
const { data: links = [], isLoading } = usePortalLinks();
|
|
663
|
+
const createLinkMutation = usePortalCreateLink();
|
|
664
|
+
const updateLinkMutation = usePortalUpdateLink();
|
|
665
|
+
const deleteLinkMutation = usePortalDeleteLink();
|
|
666
|
+
const reorderLinksMutation = usePortalReorderLinks();
|
|
923
667
|
const [isAddEditDialogOpen, setIsAddEditDialogOpen] = (0, react.useState)(false);
|
|
924
668
|
const [editingLink, setEditingLink] = (0, react.useState)(null);
|
|
925
669
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = (0, react.useState)(false);
|
|
926
670
|
const [deletingLink, setDeletingLink] = (0, react.useState)(null);
|
|
927
671
|
const { register, handleSubmit: handleButtonSubmit, reset: resetButtonForm, formState: { errors: buttonErrors, isSubmitting: isButtonSubmitting } } = require_src.useZodForm(buttonSchema, { defaultValues: {
|
|
928
|
-
|
|
672
|
+
title: "",
|
|
929
673
|
url: ""
|
|
930
674
|
} });
|
|
931
675
|
const sensors = (0, import_dist.useSensors)((0, import_dist.useSensor)(import_dist.PointerSensor), (0, import_dist.useSensor)(import_dist.KeyboardSensor, { coordinateGetter: import_dist$1.sortableKeyboardCoordinates }));
|
|
932
676
|
const handleOpenAddDialog = (0, react.useCallback)(() => {
|
|
933
677
|
setEditingLink(null);
|
|
934
678
|
resetButtonForm({
|
|
935
|
-
|
|
679
|
+
title: "",
|
|
936
680
|
url: ""
|
|
937
681
|
});
|
|
938
682
|
setIsAddEditDialogOpen(true);
|
|
@@ -940,7 +684,7 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
940
684
|
const handleOpenEditDialog = (0, react.useCallback)((link) => {
|
|
941
685
|
setEditingLink(link);
|
|
942
686
|
resetButtonForm({
|
|
943
|
-
|
|
687
|
+
title: link.title,
|
|
944
688
|
url: link.url
|
|
945
689
|
});
|
|
946
690
|
setIsAddEditDialogOpen(true);
|
|
@@ -949,14 +693,17 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
949
693
|
setIsAddEditDialogOpen(false);
|
|
950
694
|
setEditingLink(null);
|
|
951
695
|
resetButtonForm({
|
|
952
|
-
|
|
696
|
+
title: "",
|
|
953
697
|
url: ""
|
|
954
698
|
});
|
|
955
699
|
}, [resetButtonForm]);
|
|
956
700
|
const onButtonSubmit = (0, react.useCallback)((data) => {
|
|
957
701
|
if (editingLink) updateLinkMutation.mutate({
|
|
958
702
|
linkId: editingLink.id,
|
|
959
|
-
|
|
703
|
+
body: {
|
|
704
|
+
title: data.title,
|
|
705
|
+
url: data.url
|
|
706
|
+
}
|
|
960
707
|
}, {
|
|
961
708
|
onSuccess: () => {
|
|
962
709
|
onToast?.("Button updated", "success");
|
|
@@ -967,7 +714,10 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
967
714
|
onToast?.("Failed to update button", "error");
|
|
968
715
|
}
|
|
969
716
|
});
|
|
970
|
-
else createLinkMutation.mutate(
|
|
717
|
+
else createLinkMutation.mutate({
|
|
718
|
+
title: data.title,
|
|
719
|
+
url: data.url
|
|
720
|
+
}, {
|
|
971
721
|
onSuccess: () => {
|
|
972
722
|
onToast?.("Button created", "success");
|
|
973
723
|
handleCloseAddEditDialog();
|
|
@@ -1015,12 +765,9 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1015
765
|
const { active, over } = event;
|
|
1016
766
|
if (over && active.id !== over.id) {
|
|
1017
767
|
const reordered = (0, import_dist$1.arrayMove)(links, links.findIndex((l) => l.id === active.id), links.findIndex((l) => l.id === over.id));
|
|
1018
|
-
const
|
|
1019
|
-
id: link.id,
|
|
1020
|
-
order: index + 1
|
|
1021
|
-
}));
|
|
768
|
+
const orderedIds = reordered.map((link) => link.id);
|
|
1022
769
|
reorderLinksMutation.mutate({
|
|
1023
|
-
|
|
770
|
+
orderedIds,
|
|
1024
771
|
optimisticItems: reordered
|
|
1025
772
|
}, {
|
|
1026
773
|
onSuccess: () => {
|
|
@@ -1067,7 +814,6 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1067
814
|
className: "min-w-0 flex-1 space-y-2",
|
|
1068
815
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-4 w-32" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-3 w-48" })]
|
|
1069
816
|
}),
|
|
1070
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "hidden h-5 w-16 sm:block" }),
|
|
1071
817
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1072
818
|
className: "flex gap-1",
|
|
1073
819
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-8 w-8" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Skeleton, { className: "h-8 w-8" })]
|
|
@@ -1112,18 +858,18 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1112
858
|
className: "space-y-2",
|
|
1113
859
|
children: [
|
|
1114
860
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Label, {
|
|
1115
|
-
htmlFor: "
|
|
861
|
+
htmlFor: "title",
|
|
1116
862
|
children: "Button Text"
|
|
1117
863
|
}),
|
|
1118
864
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Input, {
|
|
1119
|
-
id: "
|
|
865
|
+
id: "title",
|
|
1120
866
|
placeholder: "Enter button text...",
|
|
1121
|
-
...register("
|
|
1122
|
-
className: buttonErrors.
|
|
867
|
+
...register("title"),
|
|
868
|
+
className: buttonErrors.title ? "border-destructive" : ""
|
|
1123
869
|
}),
|
|
1124
|
-
buttonErrors.
|
|
870
|
+
buttonErrors.title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1125
871
|
className: "text-destructive text-sm",
|
|
1126
|
-
children: buttonErrors.
|
|
872
|
+
children: buttonErrors.title.message
|
|
1127
873
|
})
|
|
1128
874
|
]
|
|
1129
875
|
}),
|
|
@@ -1182,7 +928,7 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1182
928
|
className: "text-muted-foreground",
|
|
1183
929
|
children: [
|
|
1184
930
|
"Are you sure you want to delete the button \"",
|
|
1185
|
-
deletingLink?.
|
|
931
|
+
deletingLink?.title,
|
|
1186
932
|
"\"? This action cannot be undone."
|
|
1187
933
|
]
|
|
1188
934
|
}),
|
|
@@ -1203,16 +949,15 @@ function MySiteButtonsEditor({ onBack, onRefreshPreview, client, userId, onToast
|
|
|
1203
949
|
] });
|
|
1204
950
|
}
|
|
1205
951
|
//#endregion
|
|
1206
|
-
//#region ../../mysite/ui/src/portal/components/
|
|
952
|
+
//#region ../../mysite/ui/src/portal/components/PortalFavoritesEditor.tsx
|
|
1207
953
|
function SortableFavoriteCard({ favorite, onDelete }) {
|
|
1208
954
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = (0, import_dist$1.useSortable)({ id: favorite.id });
|
|
1209
955
|
const style = {
|
|
1210
956
|
transform: import_dist$2.CSS.Transform.toString(transform),
|
|
1211
957
|
transition
|
|
1212
958
|
};
|
|
1213
|
-
const title = favorite.
|
|
1214
|
-
const imageUrl = favorite.
|
|
1215
|
-
const type = favorite.favoriteable_type.replace(/([A-Z])/g, " $1").trim();
|
|
959
|
+
const title = favorite.product_name ?? "Untitled";
|
|
960
|
+
const imageUrl = favorite.product_image_url;
|
|
1216
961
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1217
962
|
ref: setNodeRef,
|
|
1218
963
|
style,
|
|
@@ -1240,15 +985,12 @@ function SortableFavoriteCard({ favorite, onDelete }) {
|
|
|
1240
985
|
children: "N/A"
|
|
1241
986
|
})
|
|
1242
987
|
}),
|
|
1243
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
988
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1244
989
|
className: "min-w-0 flex-1",
|
|
1245
|
-
children:
|
|
990
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1246
991
|
className: "text-foreground truncate font-medium",
|
|
1247
992
|
children: title
|
|
1248
|
-
})
|
|
1249
|
-
className: "text-muted-foreground truncate text-sm",
|
|
1250
|
-
children: type
|
|
1251
|
-
})]
|
|
993
|
+
})
|
|
1252
994
|
}),
|
|
1253
995
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1254
996
|
className: "flex shrink-0 items-center gap-1",
|
|
@@ -1264,10 +1006,14 @@ function SortableFavoriteCard({ favorite, onDelete }) {
|
|
|
1264
1006
|
]
|
|
1265
1007
|
});
|
|
1266
1008
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1009
|
+
/**
|
|
1010
|
+
* Portal-specific favorites editor that uses MySiteApi context.
|
|
1011
|
+
* No client/affiliateId props needed — data comes from context.
|
|
1012
|
+
*/
|
|
1013
|
+
function PortalFavoritesEditor({ onBack, onRefreshPreview, onToast }) {
|
|
1014
|
+
const { data: favorites = [], isLoading } = usePortalFavorites();
|
|
1015
|
+
const deleteFavoriteMutation = usePortalDeleteFavorite();
|
|
1016
|
+
const reorderFavoritesMutation = usePortalReorderFavorites();
|
|
1271
1017
|
const [isDeleteFavoriteDialogOpen, setIsDeleteFavoriteDialogOpen] = (0, react.useState)(false);
|
|
1272
1018
|
const [deletingFavorite, setDeletingFavorite] = (0, react.useState)(null);
|
|
1273
1019
|
const sensors = (0, import_dist.useSensors)((0, import_dist.useSensor)(import_dist.PointerSensor), (0, import_dist.useSensor)(import_dist.KeyboardSensor, { coordinateGetter: import_dist$1.sortableKeyboardCoordinates }));
|
|
@@ -1301,12 +1047,9 @@ function MySiteFavoritesEditor({ onBack, onRefreshPreview, client, affiliateId,
|
|
|
1301
1047
|
const { active, over } = event;
|
|
1302
1048
|
if (over && active.id !== over.id) {
|
|
1303
1049
|
const reordered = (0, import_dist$1.arrayMove)(favorites, favorites.findIndex((f) => f.id === active.id), favorites.findIndex((f) => f.id === over.id));
|
|
1304
|
-
const
|
|
1305
|
-
id: fav.id,
|
|
1306
|
-
order: index + 1
|
|
1307
|
-
}));
|
|
1050
|
+
const orderedIds = reordered.map((fav) => fav.id);
|
|
1308
1051
|
reorderFavoritesMutation.mutate({
|
|
1309
|
-
|
|
1052
|
+
orderedIds,
|
|
1310
1053
|
optimisticItems: reordered
|
|
1311
1054
|
}, {
|
|
1312
1055
|
onSuccess: () => {
|
|
@@ -1381,7 +1124,7 @@ function MySiteFavoritesEditor({ onBack, onRefreshPreview, client, affiliateId,
|
|
|
1381
1124
|
className: "text-muted-foreground",
|
|
1382
1125
|
children: [
|
|
1383
1126
|
"Are you sure you want to remove \"",
|
|
1384
|
-
deletingFavorite?.
|
|
1127
|
+
deletingFavorite?.product_name ?? "this item",
|
|
1385
1128
|
"\" from your MySite? This action cannot be undone."
|
|
1386
1129
|
]
|
|
1387
1130
|
}),
|
|
@@ -1403,92 +1146,24 @@ function MySiteFavoritesEditor({ onBack, onRefreshPreview, client, affiliateId,
|
|
|
1403
1146
|
}
|
|
1404
1147
|
//#endregion
|
|
1405
1148
|
//#region ../../mysite/ui/src/portal/components/MySiteProfileForm.tsx
|
|
1406
|
-
|
|
1407
|
-
{
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
name: "facebook",
|
|
1414
|
-
label: "Facebook",
|
|
1415
|
-
placeholder: "https://facebook.com/username"
|
|
1416
|
-
},
|
|
1417
|
-
{
|
|
1418
|
-
name: "twitter",
|
|
1419
|
-
label: "X (Twitter)",
|
|
1420
|
-
placeholder: "https://x.com/username"
|
|
1421
|
-
},
|
|
1422
|
-
{
|
|
1423
|
-
name: "instagram",
|
|
1424
|
-
label: "Instagram",
|
|
1425
|
-
placeholder: "https://instagram.com/username"
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
name: "youtube",
|
|
1429
|
-
label: "YouTube",
|
|
1430
|
-
placeholder: "https://youtube.com/@channel"
|
|
1431
|
-
},
|
|
1432
|
-
{
|
|
1433
|
-
name: "pinterest",
|
|
1434
|
-
label: "Pinterest",
|
|
1435
|
-
placeholder: "https://pinterest.com/username"
|
|
1436
|
-
},
|
|
1437
|
-
{
|
|
1438
|
-
name: "tiktok",
|
|
1439
|
-
label: "TikTok",
|
|
1440
|
-
placeholder: "https://tiktok.com/@username"
|
|
1441
|
-
},
|
|
1442
|
-
{
|
|
1443
|
-
name: "whatsapp",
|
|
1444
|
-
label: "WhatsApp",
|
|
1445
|
-
placeholder: "Phone number or link"
|
|
1446
|
-
},
|
|
1447
|
-
{
|
|
1448
|
-
name: "wechat",
|
|
1449
|
-
label: "WeChat",
|
|
1450
|
-
placeholder: "WeChat ID"
|
|
1451
|
-
}
|
|
1452
|
-
];
|
|
1453
|
-
function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl, userName, userInitial }) {
|
|
1454
|
-
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
1455
|
-
const { data: meProfile, isLoading: isProfileLoading } = (0, _tanstack_react_query.useQuery)({
|
|
1456
|
-
queryKey: ["sdk-mysite", "me"],
|
|
1457
|
-
queryFn: () => client.get("/me.json")
|
|
1458
|
-
});
|
|
1459
|
-
const updateProfileMutation = useUpdateProfile(client);
|
|
1460
|
-
const initialFormState = (0, react.useMemo)(() => ({
|
|
1461
|
-
bio: meProfile?.bio ?? "",
|
|
1462
|
-
linkedin: meProfile?.linkedin ?? "",
|
|
1463
|
-
facebook: meProfile?.facebook ?? "",
|
|
1464
|
-
twitter: meProfile?.twitter ?? "",
|
|
1465
|
-
instagram: meProfile?.instagram ?? "",
|
|
1466
|
-
youtube: meProfile?.youtube ?? "",
|
|
1467
|
-
pinterest: meProfile?.pinterest ?? "",
|
|
1468
|
-
tiktok: meProfile?.tiktok ?? "",
|
|
1469
|
-
whatsapp: meProfile?.whatsapp ?? "",
|
|
1470
|
-
wechat: meProfile?.wechat ?? ""
|
|
1471
|
-
}), [meProfile?.id]);
|
|
1472
|
-
const [formState, setFormState] = (0, react.useState)(() => initialFormState);
|
|
1149
|
+
function MySiteProfileForm({ onBack, onToast, onUploadPhoto, avatarUrl, userName, userInitial }) {
|
|
1150
|
+
const { data: profile, isLoading: isProfileLoading } = usePortalMySiteProfile();
|
|
1151
|
+
const updateProfileMutation = usePortalUpdateProfile();
|
|
1152
|
+
const [formState, setFormState] = (0, react.useState)(() => ({
|
|
1153
|
+
display_name: "",
|
|
1154
|
+
bio: ""
|
|
1155
|
+
}));
|
|
1473
1156
|
const profileSyncedRef = (0, react.useRef)(false);
|
|
1474
1157
|
(0, react.useEffect)(() => {
|
|
1475
|
-
if (
|
|
1158
|
+
if (profile && !profileSyncedRef.current) {
|
|
1476
1159
|
profileSyncedRef.current = true;
|
|
1477
1160
|
setFormState({
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
facebook: meProfile.facebook ?? "",
|
|
1481
|
-
twitter: meProfile.twitter ?? "",
|
|
1482
|
-
instagram: meProfile.instagram ?? "",
|
|
1483
|
-
youtube: meProfile.youtube ?? "",
|
|
1484
|
-
pinterest: meProfile.pinterest ?? "",
|
|
1485
|
-
tiktok: meProfile.tiktok ?? "",
|
|
1486
|
-
whatsapp: meProfile.whatsapp ?? "",
|
|
1487
|
-
wechat: meProfile.wechat ?? ""
|
|
1161
|
+
display_name: profile.display_name ?? "",
|
|
1162
|
+
bio: profile.bio ?? ""
|
|
1488
1163
|
});
|
|
1489
1164
|
}
|
|
1490
|
-
}, [
|
|
1491
|
-
const isDirty = formState.
|
|
1165
|
+
}, [profile]);
|
|
1166
|
+
const isDirty = formState.display_name !== (profile?.display_name ?? "") || formState.bio !== (profile?.bio ?? "");
|
|
1492
1167
|
const handleFieldChange = (0, react.useCallback)((field, value) => {
|
|
1493
1168
|
setFormState((s) => ({
|
|
1494
1169
|
...s,
|
|
@@ -1497,20 +1172,11 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1497
1172
|
}, []);
|
|
1498
1173
|
const handleSave = (0, react.useCallback)(() => {
|
|
1499
1174
|
updateProfileMutation.mutate({
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
facebook: formState.facebook,
|
|
1503
|
-
twitter: formState.twitter,
|
|
1504
|
-
instagram: formState.instagram,
|
|
1505
|
-
youtube: formState.youtube,
|
|
1506
|
-
pinterest: formState.pinterest,
|
|
1507
|
-
tiktok: formState.tiktok,
|
|
1508
|
-
whatsapp: formState.whatsapp,
|
|
1509
|
-
wechat: formState.wechat
|
|
1175
|
+
display_name: formState.display_name,
|
|
1176
|
+
bio: formState.bio
|
|
1510
1177
|
}, {
|
|
1511
1178
|
onSuccess: () => {
|
|
1512
1179
|
profileSyncedRef.current = false;
|
|
1513
|
-
queryClient.invalidateQueries({ queryKey: ["sdk-mysite", "me"] });
|
|
1514
1180
|
onToast?.("Profile updated successfully", "success");
|
|
1515
1181
|
},
|
|
1516
1182
|
onError: () => {
|
|
@@ -1520,7 +1186,6 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1520
1186
|
}, [
|
|
1521
1187
|
formState,
|
|
1522
1188
|
updateProfileMutation,
|
|
1523
|
-
queryClient,
|
|
1524
1189
|
onToast
|
|
1525
1190
|
]);
|
|
1526
1191
|
const fileInputRef = (0, react.useRef)(null);
|
|
@@ -1542,7 +1207,7 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1542
1207
|
setIsUploadingPhoto(true);
|
|
1543
1208
|
try {
|
|
1544
1209
|
const imageUrl = await onUploadPhoto(file);
|
|
1545
|
-
updateProfileMutation.mutate({
|
|
1210
|
+
updateProfileMutation.mutate({ avatar_url: imageUrl }, {
|
|
1546
1211
|
onSuccess: () => {
|
|
1547
1212
|
onToast?.("Profile photo updated", "success");
|
|
1548
1213
|
},
|
|
@@ -1570,7 +1235,7 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1570
1235
|
children: "Loading..."
|
|
1571
1236
|
})
|
|
1572
1237
|
});
|
|
1573
|
-
const displayAvatarUrl = previewUrl || avatarUrl;
|
|
1238
|
+
const displayAvatarUrl = previewUrl || avatarUrl || profile?.avatar_url;
|
|
1574
1239
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1575
1240
|
className: "space-y-4 p-4 sm:space-y-6 sm:p-6",
|
|
1576
1241
|
children: [
|
|
@@ -1619,6 +1284,25 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1619
1284
|
})]
|
|
1620
1285
|
})]
|
|
1621
1286
|
}),
|
|
1287
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.Card, {
|
|
1288
|
+
className: "p-4 sm:p-6",
|
|
1289
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
1290
|
+
className: "text-foreground mb-4 text-base font-semibold sm:text-lg",
|
|
1291
|
+
children: "Display Name"
|
|
1292
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1293
|
+
className: "space-y-2",
|
|
1294
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Label, {
|
|
1295
|
+
htmlFor: "profile-display-name",
|
|
1296
|
+
children: "Name shown on your MySite"
|
|
1297
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Input, {
|
|
1298
|
+
id: "profile-display-name",
|
|
1299
|
+
type: "text",
|
|
1300
|
+
value: formState.display_name,
|
|
1301
|
+
onChange: (e) => handleFieldChange("display_name", e.target.value),
|
|
1302
|
+
placeholder: "Your display name"
|
|
1303
|
+
})]
|
|
1304
|
+
})]
|
|
1305
|
+
}),
|
|
1622
1306
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.Card, {
|
|
1623
1307
|
className: "p-4 sm:p-6",
|
|
1624
1308
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
@@ -1638,28 +1322,6 @@ function MySiteProfileForm({ client, onBack, onToast, onUploadPhoto, avatarUrl,
|
|
|
1638
1322
|
})]
|
|
1639
1323
|
})]
|
|
1640
1324
|
}),
|
|
1641
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.Card, {
|
|
1642
|
-
className: "p-4 sm:p-6",
|
|
1643
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
1644
|
-
className: "text-foreground mb-4 text-base font-semibold sm:text-lg",
|
|
1645
|
-
children: "Social Media Links"
|
|
1646
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1647
|
-
className: "space-y-4",
|
|
1648
|
-
children: socialFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1649
|
-
className: "space-y-2",
|
|
1650
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Label, {
|
|
1651
|
-
htmlFor: `profile-${field.name}`,
|
|
1652
|
-
children: field.label
|
|
1653
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Input, {
|
|
1654
|
-
id: `profile-${field.name}`,
|
|
1655
|
-
type: "text",
|
|
1656
|
-
value: formState[field.name],
|
|
1657
|
-
onChange: (e) => handleFieldChange(field.name, e.target.value),
|
|
1658
|
-
placeholder: field.placeholder
|
|
1659
|
-
})]
|
|
1660
|
-
}, field.name))
|
|
1661
|
-
})]
|
|
1662
|
-
}),
|
|
1663
1325
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1664
1326
|
className: "flex justify-end",
|
|
1665
1327
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Button, {
|
|
@@ -1700,7 +1362,7 @@ function defaultToast$1(message, type) {
|
|
|
1700
1362
|
if (type === "error") console.warn("[MySite]", message);
|
|
1701
1363
|
else console.info("[MySite]", message);
|
|
1702
1364
|
}
|
|
1703
|
-
function MySiteMainView(
|
|
1365
|
+
function MySiteMainView() {
|
|
1704
1366
|
const { navigate } = require_AppNavigationContext.useAppNavigation();
|
|
1705
1367
|
const [animPhase, setAnimPhase] = (0, react.useState)("idle");
|
|
1706
1368
|
const [editingSection, setEditingSection] = (0, react.useState)(null);
|
|
@@ -1724,27 +1386,23 @@ function MySiteMainView({ client }) {
|
|
|
1724
1386
|
"exit-fade-out",
|
|
1725
1387
|
"exit-slide"
|
|
1726
1388
|
].includes(animPhase);
|
|
1727
|
-
const { data:
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
});
|
|
1731
|
-
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
1732
|
-
const { data: themes = [] } = useMySiteThemes(client);
|
|
1733
|
-
const updateMySiteMutation = useUpdateMySite(client);
|
|
1389
|
+
const { data: profile, isLoading: isProfileLoading } = usePortalMySiteProfile();
|
|
1390
|
+
const { data: themes = [] } = usePortalMySiteThemes();
|
|
1391
|
+
const updateSettingsMutation = usePortalUpdateSettings();
|
|
1734
1392
|
const [previewKey, setPreviewKey] = (0, react.useState)(0);
|
|
1735
1393
|
const refreshPreview = (0, react.useCallback)(() => setPreviewKey((k) => k + 1), []);
|
|
1736
1394
|
const [selectedThemeId, setSelectedThemeId] = (0, react.useState)(null);
|
|
1737
|
-
const resolvedThemeId = selectedThemeId ??
|
|
1395
|
+
const resolvedThemeId = selectedThemeId ?? profile?.theme_id ?? themes.find((t) => t.name === "Default")?.id ?? themes[0]?.id ?? null;
|
|
1738
1396
|
const themeName = themes.find((t) => t.id === resolvedThemeId)?.name ?? "Default";
|
|
1739
|
-
const mysiteUrl =
|
|
1397
|
+
const mysiteUrl = profile?.mysite_url ?? "";
|
|
1740
1398
|
const displayUrl = mysiteUrl ? mysiteUrl.replace(/^https?:\/\//, "") : "";
|
|
1741
|
-
const views =
|
|
1742
|
-
const leads =
|
|
1399
|
+
const views = profile?.mysite_views ?? 0;
|
|
1400
|
+
const leads = profile?.mysite_leads ?? 0;
|
|
1743
1401
|
const handleSelectTheme = (0, react.useCallback)((theme) => {
|
|
1744
1402
|
if (theme.id === resolvedThemeId) return;
|
|
1745
1403
|
const previousThemeId = selectedThemeId;
|
|
1746
1404
|
setSelectedThemeId(theme.id);
|
|
1747
|
-
|
|
1405
|
+
updateSettingsMutation.mutate({ theme_id: theme.id }, {
|
|
1748
1406
|
onSuccess: () => {
|
|
1749
1407
|
defaultToast$1(`Theme changed to "${theme.name}"`, "success");
|
|
1750
1408
|
refreshPreview();
|
|
@@ -1757,18 +1415,17 @@ function MySiteMainView({ client }) {
|
|
|
1757
1415
|
}, [
|
|
1758
1416
|
resolvedThemeId,
|
|
1759
1417
|
selectedThemeId,
|
|
1760
|
-
|
|
1418
|
+
updateSettingsMutation,
|
|
1761
1419
|
refreshPreview
|
|
1762
1420
|
]);
|
|
1763
1421
|
const handleUpdateSlug = (0, react.useCallback)(async (slug) => {
|
|
1764
1422
|
await new Promise((resolve, reject) => {
|
|
1765
|
-
|
|
1423
|
+
updateSettingsMutation.mutate({ slug }, {
|
|
1766
1424
|
onSuccess: () => resolve(),
|
|
1767
1425
|
onError: () => reject(/* @__PURE__ */ new Error("Failed"))
|
|
1768
1426
|
});
|
|
1769
1427
|
});
|
|
1770
|
-
|
|
1771
|
-
}, [updateMySiteMutation, queryClient]);
|
|
1428
|
+
}, [updateSettingsMutation]);
|
|
1772
1429
|
const handleEditSection = (0, react.useCallback)((section) => {
|
|
1773
1430
|
cancelScheduled();
|
|
1774
1431
|
setEditingSection(section);
|
|
@@ -1797,7 +1454,7 @@ function MySiteMainView({ client }) {
|
|
|
1797
1454
|
if (editingSection === "content") return "MySite Content";
|
|
1798
1455
|
return "";
|
|
1799
1456
|
}, [editingSection]);
|
|
1800
|
-
if (
|
|
1457
|
+
if (isProfileLoading) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1801
1458
|
className: "flex h-full overflow-hidden px-2 py-6",
|
|
1802
1459
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1803
1460
|
className: "w-full px-4 2xl:w-2/3 2xl:shrink-0",
|
|
@@ -1837,19 +1494,15 @@ function MySiteMainView({ client }) {
|
|
|
1837
1494
|
themes,
|
|
1838
1495
|
selectedThemeId: resolvedThemeId,
|
|
1839
1496
|
onSelectTheme: handleSelectTheme,
|
|
1840
|
-
isPending:
|
|
1497
|
+
isPending: updateSettingsMutation.isPending,
|
|
1841
1498
|
onBack: handleBackClick
|
|
1842
|
-
}) : showEditContent && editingSection === "buttons" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1499
|
+
}) : showEditContent && editingSection === "buttons" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PortalButtonsEditor, {
|
|
1843
1500
|
onBack: handleBackClick,
|
|
1844
1501
|
onRefreshPreview: refreshPreview,
|
|
1845
|
-
client,
|
|
1846
|
-
userId: meProfile?.id,
|
|
1847
1502
|
onToast: defaultToast$1
|
|
1848
|
-
}) : showEditContent && editingSection === "content" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1503
|
+
}) : showEditContent && editingSection === "content" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PortalFavoritesEditor, {
|
|
1849
1504
|
onBack: handleBackClick,
|
|
1850
1505
|
onRefreshPreview: refreshPreview,
|
|
1851
|
-
client,
|
|
1852
|
-
affiliateId: meProfile?.affiliate_id,
|
|
1853
1506
|
onToast: defaultToast$1
|
|
1854
1507
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1855
1508
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -1906,7 +1559,7 @@ function MySiteMainView({ client }) {
|
|
|
1906
1559
|
mysiteUrl,
|
|
1907
1560
|
themeName,
|
|
1908
1561
|
previewKey,
|
|
1909
|
-
isUpdating:
|
|
1562
|
+
isUpdating: updateSettingsMutation.isPending,
|
|
1910
1563
|
onPreview: handlePreview
|
|
1911
1564
|
})
|
|
1912
1565
|
})]
|
|
@@ -1918,10 +1571,9 @@ function defaultToast(message, type) {
|
|
|
1918
1571
|
if (type === "error") console.warn("[MySite]", message);
|
|
1919
1572
|
else console.info("[MySite]", message);
|
|
1920
1573
|
}
|
|
1921
|
-
function MySiteProfileView(
|
|
1574
|
+
function MySiteProfileView() {
|
|
1922
1575
|
const { navigate } = require_AppNavigationContext.useAppNavigation();
|
|
1923
1576
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MySiteProfileForm, {
|
|
1924
|
-
client,
|
|
1925
1577
|
onBack: () => navigate("my-site"),
|
|
1926
1578
|
onToast: defaultToast
|
|
1927
1579
|
});
|
|
@@ -1929,7 +1581,6 @@ function MySiteProfileView({ client }) {
|
|
|
1929
1581
|
//#endregion
|
|
1930
1582
|
//#region src/screens/MySiteScreen/index.tsx
|
|
1931
1583
|
function MySiteScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
1932
|
-
const client = usePortalMySiteClient();
|
|
1933
1584
|
const { currentSlug, navigate } = require_AppNavigationContext.useAppNavigation();
|
|
1934
1585
|
const isProfileView = (currentSlug.split("/")[1] ?? null) === "profile";
|
|
1935
1586
|
require_ScreenHeaderContext.useScreenHeaderBreadcrumbs((0, react.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.Breadcrumb, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_src.BreadcrumbList, {
|
|
@@ -1952,7 +1603,7 @@ function MySiteScreen({ background, textColor, accentColor, padding, borderRadiu
|
|
|
1952
1603
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1953
1604
|
...divProps,
|
|
1954
1605
|
className: `h-full ${divProps.className ?? ""}`,
|
|
1955
|
-
children: isProfileView ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MySiteProfileView, {
|
|
1606
|
+
children: isProfileView ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MySiteProfileView, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MySiteMainView, {})
|
|
1956
1607
|
});
|
|
1957
1608
|
}
|
|
1958
1609
|
const mySiteScreenPropertySchema = {
|
|
@@ -1978,4 +1629,4 @@ Object.defineProperty(exports, "mySiteScreenPropertySchema", {
|
|
|
1978
1629
|
}
|
|
1979
1630
|
});
|
|
1980
1631
|
|
|
1981
|
-
//# sourceMappingURL=MySiteScreen-
|
|
1632
|
+
//# sourceMappingURL=MySiteScreen-D8YvEYwH.cjs.map
|