@hartl-services/medusa-storefront 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/browser/actions.d.ts +6 -0
- package/dist/browser/cart-mutations.d.ts +2 -1
- package/dist/browser/cart-mutations.js +2 -2
- package/dist/browser/index.d.ts +5 -1
- package/dist/browser/query-keys.d.ts +1 -0
- package/dist/browser/query-keys.js +2 -0
- package/dist/browser/query-options.d.ts +4 -0
- package/dist/browser/query-options.js +6 -0
- package/dist/core/catalog/category-filter.d.ts +16 -0
- package/dist/core/catalog/category-filter.js +33 -0
- package/dist/core/catalog/partner-only.d.ts +18 -0
- package/dist/core/catalog/partner-only.js +31 -0
- package/dist/core/form-values.d.ts +96 -4
- package/dist/core/form-values.js +131 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/report-error.d.ts +1 -1
- package/dist/core/texts-de.d.ts +4 -0
- package/dist/core/texts-de.js +4 -0
- package/dist/react/use-account.d.ts +10 -0
- package/dist/react/use-account.js +10 -0
- package/dist/react/use-auth.d.ts +16 -1
- package/dist/react/use-auth.js +67 -0
- package/dist/react/use-cart.d.ts +26 -1
- package/dist/react/use-cart.js +50 -3
- package/dist/react/use-checkout-address-form.d.ts +12 -12
- package/dist/react/use-checkout.d.ts +8 -8
- package/dist/registry/account.json +2 -2
- package/dist/registry/affiliate.json +2 -2
- package/dist/registry/cart.json +1 -1
- package/dist/registry/checkout.json +1 -1
- package/dist/registry/form.json +1 -1
- package/dist/registry/registry.json +9 -9
- package/dist/registry/setup.json +3 -3
- package/dist/server/affiliate.d.ts +4 -1
- package/dist/server/affiliate.js +29 -0
- package/dist/server/catalog.d.ts +17 -3
- package/dist/server/catalog.js +54 -6
- package/dist/server/customer.d.ts +39 -2
- package/dist/server/customer.js +174 -4
- package/dist/server/index.d.ts +25 -1
- package/dist/server/index.js +4 -3
- package/package.json +2 -2
package/dist/react/use-auth.js
CHANGED
|
@@ -73,6 +73,10 @@ export function usePasswordAuth({ getValues, onSuccess }) {
|
|
|
73
73
|
// Set while the backend waits for the address to be confirmed; replaces the form with the next steps.
|
|
74
74
|
const [verification, setVerification] = useState(null);
|
|
75
75
|
const [isContinuing, setIsContinuing] = useState(false);
|
|
76
|
+
// A registration with profile succeeded but its address could not be stored.
|
|
77
|
+
const [isAddressNotSaved, setIsAddressNotSaved] = useState(false);
|
|
78
|
+
// A partner registration succeeded but its application could not be submitted.
|
|
79
|
+
const [isApplicationNotSubmitted, setIsApplicationNotSubmitted] = useState(false);
|
|
76
80
|
// The background check and the "continue" button must not sign in twice.
|
|
77
81
|
const confirmationSignIn = useRef("idle");
|
|
78
82
|
async function completeSignIn(sessionToken) {
|
|
@@ -130,6 +134,69 @@ export function usePasswordAuth({ getValues, onSuccess }) {
|
|
|
130
134
|
cancelVerification: () => setVerification(null),
|
|
131
135
|
login: (value) => authenticate(actions.loginCustomer, value),
|
|
132
136
|
register: (value) => authenticate(actions.registerCustomer, value),
|
|
137
|
+
/** The registration did not store its address; the account exists (add it in the account). */
|
|
138
|
+
isAddressNotSaved,
|
|
139
|
+
/**
|
|
140
|
+
* Registration with name, phone and address; needs the shop's optional
|
|
141
|
+
* `registerCustomerWithProfile` action. True once signed in.
|
|
142
|
+
*/
|
|
143
|
+
async registerWithProfile(value) {
|
|
144
|
+
const action = actions.registerCustomerWithProfile;
|
|
145
|
+
setErrorMessage(null);
|
|
146
|
+
setIsAddressNotSaved(false);
|
|
147
|
+
if (!action) {
|
|
148
|
+
setErrorMessage(t("auth.registration_unsupported_step"));
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const result = unwrapMedusaAction(await action(value));
|
|
153
|
+
if (result.state === "verification_required") {
|
|
154
|
+
setVerification((current) => ({ email: value.email, stillUnverified: current !== null }));
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
setIsAddressNotSaved(!result.addressSaved);
|
|
158
|
+
await completeSignIn(result.sessionToken);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
setVerification(null);
|
|
163
|
+
setErrorMessage(t.message(getErrorMessage(error, t("auth.sign_in_failed"))));
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
/** The partner registration did not submit its application; the account exists. */
|
|
168
|
+
isApplicationNotSubmitted,
|
|
169
|
+
/**
|
|
170
|
+
* Partner registration with company address; the application follows
|
|
171
|
+
* (after an e-mail confirmation: at the first login). Needs the shop's
|
|
172
|
+
* optional `registerPartnerWithProfile` action. True once signed in.
|
|
173
|
+
*/
|
|
174
|
+
async registerPartner(value) {
|
|
175
|
+
const action = actions.registerPartnerWithProfile;
|
|
176
|
+
setErrorMessage(null);
|
|
177
|
+
setIsAddressNotSaved(false);
|
|
178
|
+
setIsApplicationNotSubmitted(false);
|
|
179
|
+
if (!action) {
|
|
180
|
+
setErrorMessage(t("partner_registration.unavailable"));
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const result = unwrapMedusaAction(await action(value));
|
|
185
|
+
if (result.state === "verification_required") {
|
|
186
|
+
setVerification((current) => ({ email: value.email, stillUnverified: current !== null }));
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
setIsAddressNotSaved(!result.addressSaved);
|
|
190
|
+
setIsApplicationNotSubmitted(!result.applicationSubmitted);
|
|
191
|
+
await completeSignIn(result.sessionToken);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
setVerification(null);
|
|
196
|
+
setErrorMessage(t.message(getErrorMessage(error, t("auth.sign_in_failed"))));
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
133
200
|
/** "I confirmed it": signs in again with the kept form values, also after a registration (the account exists by now). */
|
|
134
201
|
async continueAfterVerification() {
|
|
135
202
|
setIsContinuing(true);
|
package/dist/react/use-cart.d.ts
CHANGED
|
@@ -7,11 +7,36 @@ export declare function useActiveCart(): import("@tanstack/react-query").UseQuer
|
|
|
7
7
|
* opening its cart popover).
|
|
8
8
|
*/
|
|
9
9
|
export declare function useAddToCart(countryCode: string): {
|
|
10
|
-
addToCart: (variant: HttpTypes.StoreProductVariant) => Promise<void>;
|
|
10
|
+
addToCart: (variant: HttpTypes.StoreProductVariant, quantity?: number) => Promise<void>;
|
|
11
11
|
errorMessage: string | null;
|
|
12
12
|
isReady: boolean;
|
|
13
13
|
isSubmitting: boolean;
|
|
14
14
|
};
|
|
15
|
+
/** A line of an earlier order to put into the cart again. */
|
|
16
|
+
export interface ReorderLine {
|
|
17
|
+
/** Order line id; reported back for the lines that could not be added. */
|
|
18
|
+
id: string;
|
|
19
|
+
quantity: number;
|
|
20
|
+
title: string;
|
|
21
|
+
/** Null once the variant was deleted. */
|
|
22
|
+
variant_id: string | null | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Puts lines of an earlier order into the active cart again ("Erneut
|
|
26
|
+
* bestellen", or one line). Medusa has no reorder endpoint, so the lines are
|
|
27
|
+
* added one after another into the same cart (the first add may create it);
|
|
28
|
+
* a deleted, unavailable or refused line is reported in `failedLines` while
|
|
29
|
+
* the others are still added.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useReorder(countryCode: string): {
|
|
32
|
+
failedLines: ReorderLine[];
|
|
33
|
+
isReady: boolean;
|
|
34
|
+
isSubmitting: boolean;
|
|
35
|
+
reorder: (lines: ReorderLine[]) => Promise<{
|
|
36
|
+
added: number;
|
|
37
|
+
failed: ReorderLine[];
|
|
38
|
+
} | undefined>;
|
|
39
|
+
};
|
|
15
40
|
/**
|
|
16
41
|
* Runs one line-item change at a time (quantity, removal) through the "cart
|
|
17
42
|
* price changed" boundary; `pendingItemId` marks the line that is busy.
|
package/dist/react/use-cart.js
CHANGED
|
@@ -23,16 +23,17 @@ export function useAddToCart(countryCode) {
|
|
|
23
23
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
24
24
|
const { data: activeCart, isPending: isCartPending } = useQuery(queries.activeCart());
|
|
25
25
|
const { data: region } = useQuery(queries.region(countryCode));
|
|
26
|
-
|
|
26
|
+
/** Adds `quantity` (a whole number of at least 1, default 1) of the variant. */
|
|
27
|
+
const addToCart = async (variant, quantity = 1) => {
|
|
27
28
|
// activeCart is undefined while the query is still pending - that must
|
|
28
29
|
// never be mistaken for "no cart yet" (which would create a second cart).
|
|
29
|
-
if (!region?.id || activeCart === undefined) {
|
|
30
|
+
if (!region?.id || activeCart === undefined || !Number.isInteger(quantity) || quantity < 1) {
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
setErrorMessage(null);
|
|
33
34
|
setIsSubmitting(true);
|
|
34
35
|
try {
|
|
35
|
-
await storefront.cart.addProductToCart({ activeCart, regionId: region.id, variantId: variant.id });
|
|
36
|
+
await storefront.cart.addProductToCart({ activeCart, quantity, regionId: region.id, variantId: variant.id });
|
|
36
37
|
await storefront.refreshCartAfterMutation(queryClient);
|
|
37
38
|
callbacks.onAddedToCart?.(variant);
|
|
38
39
|
}
|
|
@@ -45,6 +46,52 @@ export function useAddToCart(countryCode) {
|
|
|
45
46
|
};
|
|
46
47
|
return { addToCart, errorMessage, isReady: Boolean(region?.id) && !isCartPending, isSubmitting };
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Puts lines of an earlier order into the active cart again ("Erneut
|
|
51
|
+
* bestellen", or one line). Medusa has no reorder endpoint, so the lines are
|
|
52
|
+
* added one after another into the same cart (the first add may create it);
|
|
53
|
+
* a deleted, unavailable or refused line is reported in `failedLines` while
|
|
54
|
+
* the others are still added.
|
|
55
|
+
*/
|
|
56
|
+
export function useReorder(countryCode) {
|
|
57
|
+
const storefront = useStorefront();
|
|
58
|
+
const { queries } = storefront;
|
|
59
|
+
const queryClient = useQueryClient();
|
|
60
|
+
const [failedLines, setFailedLines] = useState([]);
|
|
61
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
62
|
+
const { data: activeCart, isPending: isCartPending } = useQuery(queries.activeCart());
|
|
63
|
+
const { data: region } = useQuery(queries.region(countryCode));
|
|
64
|
+
const reorder = async (lines) => {
|
|
65
|
+
if (!region?.id || activeCart === undefined) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setFailedLines([]);
|
|
69
|
+
setIsSubmitting(true);
|
|
70
|
+
const failed = [];
|
|
71
|
+
let cart = activeCart;
|
|
72
|
+
try {
|
|
73
|
+
for (const line of lines) {
|
|
74
|
+
if (!line.variant_id || !Number.isInteger(line.quantity) || line.quantity < 1) {
|
|
75
|
+
failed.push(line);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
cart = await storefront.cart.addProductToCart({ activeCart: cart, quantity: line.quantity, regionId: region.id, variantId: line.variant_id });
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
failed.push(line);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
await storefront.refreshCartAfterMutation(queryClient);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
setFailedLines(failed);
|
|
89
|
+
setIsSubmitting(false);
|
|
90
|
+
}
|
|
91
|
+
return { added: lines.length - failed.length, failed };
|
|
92
|
+
};
|
|
93
|
+
return { failedLines, isReady: Boolean(region?.id) && !isCartPending, isSubmitting, reorder };
|
|
94
|
+
}
|
|
48
95
|
/**
|
|
49
96
|
* Runs one line-item change at a time (quantity, removal) through the "cart
|
|
50
97
|
* price changed" boundary; `pendingItemId` marks the line that is busy.
|
|
@@ -34,26 +34,26 @@ export declare function useCheckoutAddressForm({ countryCode, countryOptions, in
|
|
|
34
34
|
has_different_billing_address: boolean;
|
|
35
35
|
shipping_address: {
|
|
36
36
|
address_1: string;
|
|
37
|
-
address_2: string;
|
|
38
37
|
city: string;
|
|
39
38
|
company: string;
|
|
40
39
|
country_code: string;
|
|
40
|
+
postal_code: string;
|
|
41
41
|
first_name: string;
|
|
42
42
|
last_name: string;
|
|
43
43
|
phone: string;
|
|
44
|
-
|
|
44
|
+
address_2: string;
|
|
45
45
|
province: string;
|
|
46
46
|
};
|
|
47
47
|
billing_address: {
|
|
48
48
|
address_1: string;
|
|
49
|
-
address_2: string;
|
|
50
49
|
city: string;
|
|
51
50
|
company: string;
|
|
52
51
|
country_code: string;
|
|
52
|
+
postal_code: string;
|
|
53
53
|
first_name: string;
|
|
54
54
|
last_name: string;
|
|
55
55
|
phone: string;
|
|
56
|
-
|
|
56
|
+
address_2: string;
|
|
57
57
|
province: string;
|
|
58
58
|
};
|
|
59
59
|
vat_number: string;
|
|
@@ -68,26 +68,26 @@ export declare function useCheckoutAddressForm({ countryCode, countryOptions, in
|
|
|
68
68
|
has_different_billing_address: boolean;
|
|
69
69
|
shipping_address: {
|
|
70
70
|
address_1: string;
|
|
71
|
-
address_2: string;
|
|
72
71
|
city: string;
|
|
73
72
|
company: string;
|
|
74
73
|
country_code: string;
|
|
74
|
+
postal_code: string;
|
|
75
75
|
first_name: string;
|
|
76
76
|
last_name: string;
|
|
77
77
|
phone: string;
|
|
78
|
-
|
|
78
|
+
address_2: string;
|
|
79
79
|
province: string;
|
|
80
80
|
};
|
|
81
81
|
billing_address: {
|
|
82
82
|
address_1: string;
|
|
83
|
-
address_2: string;
|
|
84
83
|
city: string;
|
|
85
84
|
company: string;
|
|
86
85
|
country_code: string;
|
|
86
|
+
postal_code: string;
|
|
87
87
|
first_name: string;
|
|
88
88
|
last_name: string;
|
|
89
89
|
phone: string;
|
|
90
|
-
|
|
90
|
+
address_2: string;
|
|
91
91
|
province: string;
|
|
92
92
|
};
|
|
93
93
|
vat_number: string;
|
|
@@ -104,26 +104,26 @@ export declare function useCheckoutAddressForm({ countryCode, countryOptions, in
|
|
|
104
104
|
has_different_billing_address: import("zod").ZodBoolean;
|
|
105
105
|
shipping_address: import("zod").ZodObject<{
|
|
106
106
|
address_1: import("zod").ZodString;
|
|
107
|
-
address_2: import("zod").ZodString;
|
|
108
107
|
city: import("zod").ZodString;
|
|
109
108
|
company: import("zod").ZodString;
|
|
110
109
|
country_code: import("zod").ZodString;
|
|
110
|
+
postal_code: import("zod").ZodString;
|
|
111
111
|
first_name: import("zod").ZodString;
|
|
112
112
|
last_name: import("zod").ZodString;
|
|
113
113
|
phone: import("zod").ZodString;
|
|
114
|
-
|
|
114
|
+
address_2: import("zod").ZodString;
|
|
115
115
|
province: import("zod").ZodString;
|
|
116
116
|
}, import("zod/v4/core").$strip>;
|
|
117
117
|
billing_address: import("zod").ZodObject<{
|
|
118
118
|
address_1: import("zod").ZodString;
|
|
119
|
-
address_2: import("zod").ZodString;
|
|
120
119
|
city: import("zod").ZodString;
|
|
121
120
|
company: import("zod").ZodString;
|
|
122
121
|
country_code: import("zod").ZodString;
|
|
122
|
+
postal_code: import("zod").ZodString;
|
|
123
123
|
first_name: import("zod").ZodString;
|
|
124
124
|
last_name: import("zod").ZodString;
|
|
125
125
|
phone: import("zod").ZodString;
|
|
126
|
-
|
|
126
|
+
address_2: import("zod").ZodString;
|
|
127
127
|
province: import("zod").ZodString;
|
|
128
128
|
}, import("zod/v4/core").$strip>;
|
|
129
129
|
vat_number: import("zod").ZodString;
|
|
@@ -28,26 +28,26 @@ export declare function useCheckout(countryCode: string): {
|
|
|
28
28
|
has_different_billing_address: boolean;
|
|
29
29
|
shipping_address: {
|
|
30
30
|
address_1: string;
|
|
31
|
-
address_2: string;
|
|
32
31
|
city: string;
|
|
33
32
|
company: string;
|
|
34
33
|
country_code: string;
|
|
34
|
+
postal_code: string;
|
|
35
35
|
first_name: string;
|
|
36
36
|
last_name: string;
|
|
37
37
|
phone: string;
|
|
38
|
-
|
|
38
|
+
address_2: string;
|
|
39
39
|
province: string;
|
|
40
40
|
};
|
|
41
41
|
billing_address: {
|
|
42
42
|
address_1: string;
|
|
43
|
-
address_2: string;
|
|
44
43
|
city: string;
|
|
45
44
|
company: string;
|
|
46
45
|
country_code: string;
|
|
46
|
+
postal_code: string;
|
|
47
47
|
first_name: string;
|
|
48
48
|
last_name: string;
|
|
49
49
|
phone: string;
|
|
50
|
-
|
|
50
|
+
address_2: string;
|
|
51
51
|
province: string;
|
|
52
52
|
};
|
|
53
53
|
vat_number: string;
|
|
@@ -59,26 +59,26 @@ export declare function useCheckout(countryCode: string): {
|
|
|
59
59
|
has_different_billing_address: boolean;
|
|
60
60
|
shipping_address: {
|
|
61
61
|
address_1: string;
|
|
62
|
-
address_2: string;
|
|
63
62
|
city: string;
|
|
64
63
|
company: string;
|
|
65
64
|
country_code: string;
|
|
65
|
+
postal_code: string;
|
|
66
66
|
first_name: string;
|
|
67
67
|
last_name: string;
|
|
68
68
|
phone: string;
|
|
69
|
-
|
|
69
|
+
address_2: string;
|
|
70
70
|
province: string;
|
|
71
71
|
};
|
|
72
72
|
billing_address: {
|
|
73
73
|
address_1: string;
|
|
74
|
-
address_2: string;
|
|
75
74
|
city: string;
|
|
76
75
|
company: string;
|
|
77
76
|
country_code: string;
|
|
77
|
+
postal_code: string;
|
|
78
78
|
first_name: string;
|
|
79
79
|
last_name: string;
|
|
80
80
|
phone: string;
|
|
81
|
-
|
|
81
|
+
address_2: string;
|
|
82
82
|
province: string;
|
|
83
83
|
};
|
|
84
84
|
vat_number: string;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"title": "Customer account",
|
|
5
5
|
"description": "Sign-in with password or e-mail code, password reset, account verification, address book with UID check, profile, orders, the account workspace layout and the document download route.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@hartl-services/medusa-storefront@^0.
|
|
8
|
-
"@hartl-services/medusa-contracts@^1.
|
|
7
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
8
|
+
"@hartl-services/medusa-contracts@^1.2.0",
|
|
9
9
|
"@medusajs/types@^2.19.0",
|
|
10
10
|
"lucide-react"
|
|
11
11
|
],
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"title": "Partner portal",
|
|
5
5
|
"description": "Partner portal: gated registration with UID check, links, coupon codes, commissions with date filter, consignment reports, and its Route Handlers.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@hartl-services/medusa-storefront@^0.
|
|
8
|
-
"@hartl-services/medusa-contracts@^1.
|
|
7
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
8
|
+
"@hartl-services/medusa-contracts@^1.2.0",
|
|
9
9
|
"@medusajs/types@^2.19.0",
|
|
10
10
|
"lucide-react",
|
|
11
11
|
"react-day-picker"
|
package/dist/registry/cart.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"title": "Cart",
|
|
5
5
|
"description": "Cart widget with popover, line items, totals, cart page, add-to-cart button, variant picker and product price.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@hartl-services/medusa-storefront@^0.
|
|
7
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
8
8
|
"@medusajs/types@^2.19.0",
|
|
9
9
|
"lucide-react"
|
|
10
10
|
],
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"title": "Checkout",
|
|
5
5
|
"description": "Checkout page (address, login prompt, shipping and Stripe payment, coupon, UID status) and the order confirmation page.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@hartl-services/medusa-storefront@^0.
|
|
7
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
8
8
|
"@medusajs/types@^2.19.0",
|
|
9
9
|
"@stripe/react-stripe-js@^5.6.1",
|
|
10
10
|
"@stripe/stripe-js@^8.11.0",
|
package/dist/registry/form.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"title": "Storefront form kit",
|
|
5
5
|
"description": "The shop's TanStack form hook (useAppForm) with unstyled field components; the package's hooks hand their formOptions to it.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@hartl-services/medusa-storefront@^0.
|
|
7
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
8
8
|
"@tanstack/react-form@^1.33.5",
|
|
9
9
|
"input-otp",
|
|
10
10
|
"lucide-react"
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"title": "Storefront setup",
|
|
8
8
|
"description": "Wires the storefront package into a Next shop: server and browser instances, the Server Action wrappers, texts, error reporting and the provider root for the [countryCode] layout.",
|
|
9
9
|
"dependencies": [
|
|
10
|
-
"@hartl-services/medusa-storefront@^0.
|
|
11
|
-
"@hartl-services/medusa-contracts@^1.
|
|
10
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
11
|
+
"@hartl-services/medusa-contracts@^1.2.0",
|
|
12
12
|
"@medusajs/framework@^2.19.0",
|
|
13
13
|
"@medusajs/js-sdk@^2.19.0",
|
|
14
14
|
"@medusajs/types@^2.19.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"title": "Storefront form kit",
|
|
74
74
|
"description": "The shop's TanStack form hook (useAppForm) with unstyled field components; the package's hooks hand their formOptions to it.",
|
|
75
75
|
"dependencies": [
|
|
76
|
-
"@hartl-services/medusa-storefront@^0.
|
|
76
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
77
77
|
"@tanstack/react-form@^1.33.5",
|
|
78
78
|
"input-otp",
|
|
79
79
|
"lucide-react"
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"title": "Cart",
|
|
198
198
|
"description": "Cart widget with popover, line items, totals, cart page, add-to-cart button, variant picker and product price.",
|
|
199
199
|
"dependencies": [
|
|
200
|
-
"@hartl-services/medusa-storefront@^0.
|
|
200
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
201
201
|
"@medusajs/types@^2.19.0",
|
|
202
202
|
"lucide-react"
|
|
203
203
|
],
|
|
@@ -306,8 +306,8 @@
|
|
|
306
306
|
"title": "Customer account",
|
|
307
307
|
"description": "Sign-in with password or e-mail code, password reset, account verification, address book with UID check, profile, orders, the account workspace layout and the document download route.",
|
|
308
308
|
"dependencies": [
|
|
309
|
-
"@hartl-services/medusa-storefront@^0.
|
|
310
|
-
"@hartl-services/medusa-contracts@^1.
|
|
309
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
310
|
+
"@hartl-services/medusa-contracts@^1.2.0",
|
|
311
311
|
"@medusajs/types@^2.19.0",
|
|
312
312
|
"lucide-react"
|
|
313
313
|
],
|
|
@@ -516,7 +516,7 @@
|
|
|
516
516
|
"title": "Checkout",
|
|
517
517
|
"description": "Checkout page (address, login prompt, shipping and Stripe payment, coupon, UID status) and the order confirmation page.",
|
|
518
518
|
"dependencies": [
|
|
519
|
-
"@hartl-services/medusa-storefront@^0.
|
|
519
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
520
520
|
"@medusajs/types@^2.19.0",
|
|
521
521
|
"@stripe/react-stripe-js@^5.6.1",
|
|
522
522
|
"@stripe/stripe-js@^8.11.0",
|
|
@@ -661,8 +661,8 @@
|
|
|
661
661
|
"title": "Partner portal",
|
|
662
662
|
"description": "Partner portal: gated registration with UID check, links, coupon codes, commissions with date filter, consignment reports, and its Route Handlers.",
|
|
663
663
|
"dependencies": [
|
|
664
|
-
"@hartl-services/medusa-storefront@^0.
|
|
665
|
-
"@hartl-services/medusa-contracts@^1.
|
|
664
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
665
|
+
"@hartl-services/medusa-contracts@^1.2.0",
|
|
666
666
|
"@medusajs/types@^2.19.0",
|
|
667
667
|
"lucide-react",
|
|
668
668
|
"react-day-picker"
|
package/dist/registry/setup.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"title": "Storefront setup",
|
|
5
5
|
"description": "Wires the storefront package into a Next shop: server and browser instances, the Server Action wrappers, texts, error reporting and the provider root for the [countryCode] layout.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"@hartl-services/medusa-storefront@^0.
|
|
8
|
-
"@hartl-services/medusa-contracts@^1.
|
|
7
|
+
"@hartl-services/medusa-storefront@^0.3.0",
|
|
8
|
+
"@hartl-services/medusa-contracts@^1.2.0",
|
|
9
9
|
"@medusajs/framework@^2.19.0",
|
|
10
10
|
"@medusajs/js-sdk@^2.19.0",
|
|
11
11
|
"@medusajs/types@^2.19.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"path": "registry/items/setup/lib/storefront/actions.ts",
|
|
35
35
|
"target": "@lib/storefront/actions.ts",
|
|
36
36
|
"type": "registry:lib",
|
|
37
|
-
"content": "\"use server\"\n\n// One Server Action per storefront server function: Next only accepts \"use server\"\n// functions defined in the app. The browser side gets them through lib/storefront/client.ts.\n\nimport { storefront } from \"@/lib/storefront/server\"\n\nexport async function getActiveCart(...args: Parameters<typeof storefront.cart.getActiveCart>) {\n return await storefront.cart.getActiveCart(...args)\n}\n\nexport async function applyCustomerDefaultsToActiveCart(...args: Parameters<typeof storefront.cart.applyCustomerDefaultsToActiveCart>) {\n return await storefront.cart.applyCustomerDefaultsToActiveCart(...args)\n}\n\nexport async function syncCartId(...args: Parameters<typeof storefront.cart.syncCartId>) {\n return await storefront.cart.syncCartId(...args)\n}\n\nexport async function clearCartId(...args: Parameters<typeof storefront.cart.clearCartId>) {\n return await storefront.cart.clearCartId(...args)\n}\n\nexport async function discardActiveCart(...args: Parameters<typeof storefront.cart.discardActiveCart>) {\n return await storefront.cart.discardActiveCart(...args)\n}\n\nexport async function retrieveCustomer(...args: Parameters<typeof storefront.customer.retrieveCustomer>) {\n return await storefront.customer.retrieveCustomer(...args)\n}\n\nexport async function loginCustomer(...args: Parameters<typeof storefront.customer.loginCustomer>) {\n return await storefront.customer.loginCustomer(...args)\n}\n\nexport async function checkCustomerVerification(...args: Parameters<typeof storefront.customer.checkCustomerVerification>) {\n return await storefront.customer.checkCustomerVerification(...args)\n}\n\nexport async function registerCustomer(...args: Parameters<typeof storefront.customer.registerCustomer>) {\n return await storefront.customer.registerCustomer(...args)\n}\n\nexport async function requestLoginCode(...args: Parameters<typeof storefront.customer.requestLoginCode>) {\n return await storefront.customer.requestLoginCode(...args)\n}\n\nexport async function loginWithCode(...args: Parameters<typeof storefront.customer.loginWithCode>) {\n return await storefront.customer.loginWithCode(...args)\n}\n\nexport async function requestCustomerPasswordReset(...args: Parameters<typeof storefront.customer.requestCustomerPasswordReset>) {\n return await storefront.customer.requestCustomerPasswordReset(...args)\n}\n\nexport async function resetCustomerPassword(...args: Parameters<typeof storefront.customer.resetCustomerPassword>) {\n return await storefront.customer.resetCustomerPassword(...args)\n}\n\nexport async function confirmCustomerEmail(...args: Parameters<typeof storefront.customer.confirmCustomerEmail>) {\n return await storefront.customer.confirmCustomerEmail(...args)\n}\n\nexport async function resendCustomerVerification(...args: Parameters<typeof storefront.customer.resendCustomerVerification>) {\n return await storefront.customer.resendCustomerVerification(...args)\n}\n\nexport async function fetchCustomerPasswordPolicy(...args: Parameters<typeof storefront.customer.fetchCustomerPasswordPolicy>) {\n return await storefront.customer.fetchCustomerPasswordPolicy(...args)\n}\n\nexport async function updateCustomer(...args: Parameters<typeof storefront.customer.updateCustomer>) {\n return await storefront.customer.updateCustomer(...args)\n}\n\nexport async function createCustomerAddress(...args: Parameters<typeof storefront.customer.createCustomerAddress>) {\n return await storefront.customer.createCustomerAddress(...args)\n}\n\nexport async function saveFirstCheckoutAddresses(...args: Parameters<typeof storefront.customer.saveFirstCheckoutAddresses>) {\n return await storefront.customer.saveFirstCheckoutAddresses(...args)\n}\n\nexport async function updateCustomerAddress(...args: Parameters<typeof storefront.customer.updateCustomerAddress>) {\n return await storefront.customer.updateCustomerAddress(...args)\n}\n\nexport async function deleteCustomerAddress(...args: Parameters<typeof storefront.customer.deleteCustomerAddress>) {\n return await storefront.customer.deleteCustomerAddress(...args)\n}\n\nexport async function logoutCustomer(...args: Parameters<typeof storefront.customer.logoutCustomer>) {\n return await storefront.customer.logoutCustomer(...args)\n}\n\nexport async function listShippingOptions(...args: Parameters<typeof storefront.checkout.listShippingOptions>) {\n return await storefront.checkout.listShippingOptions(...args)\n}\n\nexport async function listPaymentProviders(...args: Parameters<typeof storefront.checkout.listPaymentProviders>) {\n return await storefront.checkout.listPaymentProviders(...args)\n}\n\nexport async function listRegions(...args: Parameters<typeof storefront.region.listRegions>) {\n return await storefront.region.listRegions(...args)\n}\n\nexport async function fetchPluginFeatures(...args: Parameters<typeof storefront.pluginFeatures.fetchPluginFeatures>) {\n return await storefront.pluginFeatures.fetchPluginFeatures(...args)\n}\n\nexport async function checkCartTaxIdentification(...args: Parameters<typeof storefront.taxCompliance.checkCartTaxIdentification>) {\n return await storefront.taxCompliance.checkCartTaxIdentification(...args)\n}\n\nexport async function listCustomerTaxIdentifications(...args: Parameters<typeof storefront.taxCompliance.listCustomerTaxIdentifications>) {\n return await storefront.taxCompliance.listCustomerTaxIdentifications(...args)\n}\n\nexport async function verifyCustomerAddressTaxIdentification(...args: Parameters<typeof storefront.taxCompliance.verifyCustomerAddressTaxIdentification>) {\n return await storefront.taxCompliance.verifyCustomerAddressTaxIdentification(...args)\n}\n\nexport async function submitAffiliateApplication(...args: Parameters<typeof storefront.affiliate.submitAffiliateApplication>) {\n return await storefront.affiliate.submitAffiliateApplication(...args)\n}\n\nexport async function applyAffiliateOwnOrderPromotion(...args: Parameters<typeof storefront.affiliate.applyAffiliateOwnOrderPromotion>) {\n return await storefront.affiliate.applyAffiliateOwnOrderPromotion(...args)\n}\n\nexport async function createAffiliateSlug(...args: Parameters<typeof storefront.affiliate.createAffiliateSlug>) {\n return await storefront.affiliate.createAffiliateSlug(...args)\n}\n\nexport async function updateAffiliateSlug(...args: Parameters<typeof storefront.affiliate.updateAffiliateSlug>) {\n return await storefront.affiliate.updateAffiliateSlug(...args)\n}\n\nexport async function createAffiliateCouponCode(...args: Parameters<typeof storefront.affiliate.createAffiliateCouponCode>) {\n return await storefront.affiliate.createAffiliateCouponCode(...args)\n}\n\nexport async function rotateAffiliateCouponCode(...args: Parameters<typeof storefront.affiliate.rotateAffiliateCouponCode>) {\n return await storefront.affiliate.rotateAffiliateCouponCode(...args)\n}\n\nexport async function revokeAffiliateCouponCode(...args: Parameters<typeof storefront.affiliate.revokeAffiliateCouponCode>) {\n return await storefront.affiliate.revokeAffiliateCouponCode(...args)\n}\n\nexport async function createConsignmentReport(...args: Parameters<typeof storefront.affiliate.createConsignmentReport>) {\n return await storefront.affiliate.createConsignmentReport(...args)\n}\n\nexport async function listOrders(...args: Parameters<typeof storefront.orders.listOrders>) {\n return await storefront.orders.listOrders(...args)\n}\n\nexport async function listDocuments(...args: Parameters<typeof storefront.documents.listDocuments>) {\n return await storefront.documents.listDocuments(...args)\n}\n"
|
|
37
|
+
"content": "\"use server\"\n\n// One Server Action per storefront server function: Next only accepts \"use server\"\n// functions defined in the app. The browser side gets them through lib/storefront/client.ts.\n\nimport { storefront } from \"@/lib/storefront/server\"\n\nexport async function getActiveCart(...args: Parameters<typeof storefront.cart.getActiveCart>) {\n return await storefront.cart.getActiveCart(...args)\n}\n\nexport async function applyCustomerDefaultsToActiveCart(...args: Parameters<typeof storefront.cart.applyCustomerDefaultsToActiveCart>) {\n return await storefront.cart.applyCustomerDefaultsToActiveCart(...args)\n}\n\nexport async function syncCartId(...args: Parameters<typeof storefront.cart.syncCartId>) {\n return await storefront.cart.syncCartId(...args)\n}\n\nexport async function clearCartId(...args: Parameters<typeof storefront.cart.clearCartId>) {\n return await storefront.cart.clearCartId(...args)\n}\n\nexport async function discardActiveCart(...args: Parameters<typeof storefront.cart.discardActiveCart>) {\n return await storefront.cart.discardActiveCart(...args)\n}\n\nexport async function retrieveCustomer(...args: Parameters<typeof storefront.customer.retrieveCustomer>) {\n return await storefront.customer.retrieveCustomer(...args)\n}\n\nexport async function loginCustomer(...args: Parameters<typeof storefront.customer.loginCustomer>) {\n return await storefront.customer.loginCustomer(...args)\n}\n\nexport async function checkCustomerVerification(...args: Parameters<typeof storefront.customer.checkCustomerVerification>) {\n return await storefront.customer.checkCustomerVerification(...args)\n}\n\nexport async function registerCustomer(...args: Parameters<typeof storefront.customer.registerCustomer>) {\n return await storefront.customer.registerCustomer(...args)\n}\n\nexport async function registerCustomerWithProfile(...args: Parameters<typeof storefront.customer.registerCustomerWithProfile>) {\n return await storefront.customer.registerCustomerWithProfile(...args)\n}\n\nexport async function registerPartnerWithProfile(...args: Parameters<typeof storefront.customer.registerPartnerWithProfile>) {\n return await storefront.customer.registerPartnerWithProfile(...args)\n}\n\nexport async function requestLoginCode(...args: Parameters<typeof storefront.customer.requestLoginCode>) {\n return await storefront.customer.requestLoginCode(...args)\n}\n\nexport async function loginWithCode(...args: Parameters<typeof storefront.customer.loginWithCode>) {\n return await storefront.customer.loginWithCode(...args)\n}\n\nexport async function requestCustomerPasswordReset(...args: Parameters<typeof storefront.customer.requestCustomerPasswordReset>) {\n return await storefront.customer.requestCustomerPasswordReset(...args)\n}\n\nexport async function resetCustomerPassword(...args: Parameters<typeof storefront.customer.resetCustomerPassword>) {\n return await storefront.customer.resetCustomerPassword(...args)\n}\n\nexport async function confirmCustomerEmail(...args: Parameters<typeof storefront.customer.confirmCustomerEmail>) {\n return await storefront.customer.confirmCustomerEmail(...args)\n}\n\nexport async function resendCustomerVerification(...args: Parameters<typeof storefront.customer.resendCustomerVerification>) {\n return await storefront.customer.resendCustomerVerification(...args)\n}\n\nexport async function fetchCustomerPasswordPolicy(...args: Parameters<typeof storefront.customer.fetchCustomerPasswordPolicy>) {\n return await storefront.customer.fetchCustomerPasswordPolicy(...args)\n}\n\nexport async function updateCustomer(...args: Parameters<typeof storefront.customer.updateCustomer>) {\n return await storefront.customer.updateCustomer(...args)\n}\n\nexport async function createCustomerAddress(...args: Parameters<typeof storefront.customer.createCustomerAddress>) {\n return await storefront.customer.createCustomerAddress(...args)\n}\n\nexport async function saveFirstCheckoutAddresses(...args: Parameters<typeof storefront.customer.saveFirstCheckoutAddresses>) {\n return await storefront.customer.saveFirstCheckoutAddresses(...args)\n}\n\nexport async function updateCustomerAddress(...args: Parameters<typeof storefront.customer.updateCustomerAddress>) {\n return await storefront.customer.updateCustomerAddress(...args)\n}\n\nexport async function deleteCustomerAddress(...args: Parameters<typeof storefront.customer.deleteCustomerAddress>) {\n return await storefront.customer.deleteCustomerAddress(...args)\n}\n\nexport async function logoutCustomer(...args: Parameters<typeof storefront.customer.logoutCustomer>) {\n return await storefront.customer.logoutCustomer(...args)\n}\n\nexport async function listShippingOptions(...args: Parameters<typeof storefront.checkout.listShippingOptions>) {\n return await storefront.checkout.listShippingOptions(...args)\n}\n\nexport async function listPaymentProviders(...args: Parameters<typeof storefront.checkout.listPaymentProviders>) {\n return await storefront.checkout.listPaymentProviders(...args)\n}\n\nexport async function listRegions(...args: Parameters<typeof storefront.region.listRegions>) {\n return await storefront.region.listRegions(...args)\n}\n\nexport async function fetchPluginFeatures(...args: Parameters<typeof storefront.pluginFeatures.fetchPluginFeatures>) {\n return await storefront.pluginFeatures.fetchPluginFeatures(...args)\n}\n\nexport async function checkCartTaxIdentification(...args: Parameters<typeof storefront.taxCompliance.checkCartTaxIdentification>) {\n return await storefront.taxCompliance.checkCartTaxIdentification(...args)\n}\n\nexport async function listCustomerTaxIdentifications(...args: Parameters<typeof storefront.taxCompliance.listCustomerTaxIdentifications>) {\n return await storefront.taxCompliance.listCustomerTaxIdentifications(...args)\n}\n\nexport async function verifyCustomerAddressTaxIdentification(...args: Parameters<typeof storefront.taxCompliance.verifyCustomerAddressTaxIdentification>) {\n return await storefront.taxCompliance.verifyCustomerAddressTaxIdentification(...args)\n}\n\nexport async function submitAffiliateApplication(...args: Parameters<typeof storefront.affiliate.submitAffiliateApplication>) {\n return await storefront.affiliate.submitAffiliateApplication(...args)\n}\n\nexport async function applyAffiliateOwnOrderPromotion(...args: Parameters<typeof storefront.affiliate.applyAffiliateOwnOrderPromotion>) {\n return await storefront.affiliate.applyAffiliateOwnOrderPromotion(...args)\n}\n\nexport async function createAffiliateSlug(...args: Parameters<typeof storefront.affiliate.createAffiliateSlug>) {\n return await storefront.affiliate.createAffiliateSlug(...args)\n}\n\nexport async function updateAffiliateSlug(...args: Parameters<typeof storefront.affiliate.updateAffiliateSlug>) {\n return await storefront.affiliate.updateAffiliateSlug(...args)\n}\n\nexport async function createAffiliateCouponCode(...args: Parameters<typeof storefront.affiliate.createAffiliateCouponCode>) {\n return await storefront.affiliate.createAffiliateCouponCode(...args)\n}\n\nexport async function rotateAffiliateCouponCode(...args: Parameters<typeof storefront.affiliate.rotateAffiliateCouponCode>) {\n return await storefront.affiliate.rotateAffiliateCouponCode(...args)\n}\n\nexport async function revokeAffiliateCouponCode(...args: Parameters<typeof storefront.affiliate.revokeAffiliateCouponCode>) {\n return await storefront.affiliate.revokeAffiliateCouponCode(...args)\n}\n\nexport async function createConsignmentReport(...args: Parameters<typeof storefront.affiliate.createConsignmentReport>) {\n return await storefront.affiliate.createConsignmentReport(...args)\n}\n\nexport async function listOrders(...args: Parameters<typeof storefront.orders.listOrders>) {\n return await storefront.orders.listOrders(...args)\n}\n\nexport async function getOrder(...args: Parameters<typeof storefront.orders.getOrder>) {\n return await storefront.orders.getOrder(...args)\n}\n\nexport async function listDocuments(...args: Parameters<typeof storefront.documents.listDocuments>) {\n return await storefront.documents.listDocuments(...args)\n}\n"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"path": "registry/items/setup/lib/storefront/client.ts",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApplyOwnOrderPromotionResponse, CreatePartnerPortalSlugRequest, CreateStoreAffiliateCouponCodeRequest, RotateStoreAffiliateCouponCodeRequest, SubmitAffiliateApplicationRequest, SubmitConsignmentReportRequest, UpdatePartnerPortalSlugRequest } from "@hartl-services/medusa-contracts/types/affiliate-store";
|
|
1
|
+
import type { ApplyOwnOrderPromotionResponse, CreatePartnerPortalSlugRequest, CreateStoreAffiliateCouponCodeRequest, RotateStoreAffiliateCouponCodeRequest, StoreAffiliatePortalContextResponse, SubmitAffiliateApplicationRequest, SubmitConsignmentReportRequest, UpdatePartnerPortalSlugRequest } from "@hartl-services/medusa-contracts/types/affiliate-store";
|
|
2
2
|
import type { MedusaActionResult } from "../core/action-result.js";
|
|
3
3
|
import type { ServerContext } from "./context.js";
|
|
4
4
|
import type { ServerPluginFeatures } from "./plugin-features.js";
|
|
@@ -12,6 +12,9 @@ export interface AffiliateCouponRotationInput {
|
|
|
12
12
|
command: RotateStoreAffiliateCouponCodeRequest;
|
|
13
13
|
}
|
|
14
14
|
export declare function createAffiliate(context: ServerContext, pluginFeatures: ServerPluginFeatures, runMedusaAction: RunMedusaAction): {
|
|
15
|
+
loadPartnerPortalState: () => Promise<StoreAffiliatePortalContextResponse["portal_state"] | null>;
|
|
16
|
+
/** Whether the logged-in customer is an approved, active partner (fail-closed). */
|
|
17
|
+
isActivePartner(): Promise<boolean>;
|
|
15
18
|
submitAffiliateApplication(data: SubmitAffiliateApplicationRequest): Promise<MedusaActionResult<{
|
|
16
19
|
application: {
|
|
17
20
|
id: string;
|
package/dist/server/affiliate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cache } from "react";
|
|
1
2
|
import { affiliateStorePaths } from "@hartl-services/medusa-contracts/paths/affiliate";
|
|
2
3
|
import { isPluginFeatureEnabled } from "../core/plugin-features.js";
|
|
3
4
|
import { createMedusaErrorResponse } from "./route-response.js";
|
|
@@ -19,7 +20,35 @@ export function createAffiliate(context, pluginFeatures, runMedusaAction) {
|
|
|
19
20
|
return medusaErrorResponse(error);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The logged-in customer's partner state for server rendering (e.g. a
|
|
25
|
+
* therapist view): null when logged out, while the partner portal is off,
|
|
26
|
+
* or when the backend cannot answer - every partner view then stays hidden.
|
|
27
|
+
* Deduplicated per request via React cache().
|
|
28
|
+
*/
|
|
29
|
+
const loadPartnerPortalState = cache(async () => {
|
|
30
|
+
if (!(await context.session.getMedusaAuthToken())) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (!isPluginFeatureEnabled(await pluginFeatures.loadPluginFeatures(), "affiliate", "partner_portal")) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const sdk = await customerClient();
|
|
38
|
+
const response = await sdk.client.fetch(affiliateStorePaths.get.me, { method: "GET" });
|
|
39
|
+
return response.portal_state;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
context.reportError(error, { area: "affiliate", context: { step: "portal_state" } });
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
22
46
|
return {
|
|
47
|
+
loadPartnerPortalState,
|
|
48
|
+
/** Whether the logged-in customer is an approved, active partner (fail-closed). */
|
|
49
|
+
async isActivePartner() {
|
|
50
|
+
return (await loadPartnerPortalState()) === "active";
|
|
51
|
+
},
|
|
23
52
|
async submitAffiliateApplication(data) {
|
|
24
53
|
return runMedusaAction(async () => {
|
|
25
54
|
const sdk = await customerClient();
|
package/dist/server/catalog.d.ts
CHANGED
|
@@ -6,14 +6,28 @@ export interface CommerceProductListInput {
|
|
|
6
6
|
collectionId?: string;
|
|
7
7
|
countryCode: string;
|
|
8
8
|
handles?: string[];
|
|
9
|
+
/** Medusa's product search (title, description, handle, ...). */
|
|
10
|
+
q?: string;
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Medusa's half of a catalog: products priced for a country, categories and
|
|
14
|
+
* collections. Partner-only products and categories (see
|
|
15
|
+
* `isPartnerOnlyProduct`) are left out unless `isActivePartner` says the
|
|
16
|
+
* visitor is an active partner; the backend refuses them at checkout anyway.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCatalog(context: ServerContext, region: ServerRegion, isActivePartner?: () => Promise<boolean>): {
|
|
19
|
+
listCommerceProducts({ categoryId, collectionId, countryCode, handles, q }: CommerceProductListInput): Promise<HttpTypes.StoreProduct[] | null>;
|
|
13
20
|
commerceProductByHandle({ countryCode, handle }: {
|
|
14
21
|
countryCode: string;
|
|
15
22
|
handle: string;
|
|
16
23
|
}): Promise<HttpTypes.StoreProduct | null>;
|
|
24
|
+
/**
|
|
25
|
+
* The top-level categories with all descendants (e.g. "Anwendungsbereiche"
|
|
26
|
+
* and "Inhaltsstoffe" with their entries) - the filter trees of a product
|
|
27
|
+
* list; filter with `filterProductsByCategories` from /core. Partner-only
|
|
28
|
+
* categories only for an active partner.
|
|
29
|
+
*/
|
|
30
|
+
listCategoryTrees(): Promise<HttpTypes.StoreProductCategory[]>;
|
|
17
31
|
categoryByPath(categoryPath: string[]): Promise<HttpTypes.StoreProductCategory | null>;
|
|
18
32
|
collectionByHandle(handle: string): Promise<HttpTypes.StoreCollection | null>;
|
|
19
33
|
};
|