@betterstore/react 0.3.12 → 0.3.14
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/CHANGELOG.md
CHANGED
|
@@ -19,3 +19,4 @@ export declare const useFormStore: import("zustand").UseBoundStore<Omit<import("
|
|
|
19
19
|
getOptions: () => Partial<import("zustand/middleware").PersistOptions<FormStore, FormStore>>;
|
|
20
20
|
};
|
|
21
21
|
}>;
|
|
22
|
+
export declare const resetFormStore: (formData: Partial<CheckoutFormData>) => void;
|
package/dist/index.cjs.js
CHANGED
|
@@ -3286,7 +3286,8 @@ const CheckoutEmbed$2 = {
|
|
|
3286
3286
|
title: "Přeprava",
|
|
3287
3287
|
description: {
|
|
3288
3288
|
other: "Váš balíček bude doručen kurýrem.",
|
|
3289
|
-
zasilkovna: "Váš balíček bude doručen do bodu vyzvednutí."
|
|
3289
|
+
zasilkovna: "Váš balíček bude doručen do bodu vyzvednutí.",
|
|
3290
|
+
shippedTo: "Doručeno do:"
|
|
3290
3291
|
}
|
|
3291
3292
|
}
|
|
3292
3293
|
};
|
|
@@ -35439,6 +35440,10 @@ const useFormStore = create()(persist((set) => ({
|
|
|
35439
35440
|
checkoutId: "",
|
|
35440
35441
|
setCheckoutId: (checkoutId) => set({ checkoutId }),
|
|
35441
35442
|
}), { name: `checkout` }));
|
|
35443
|
+
const resetFormStore = (formData) => {
|
|
35444
|
+
const currentState = JSON.parse(localStorage.getItem("checkout") || "{}");
|
|
35445
|
+
localStorage.setItem("checkout", JSON.stringify(Object.assign(Object.assign({}, currentState), { state: Object.assign(Object.assign({}, currentState.state), { step: "customer", formData: { customer: formData.customer } }) })));
|
|
35446
|
+
};
|
|
35442
35447
|
|
|
35443
35448
|
const motionSettings = {
|
|
35444
35449
|
initial: { opacity: 0 },
|
|
@@ -35878,17 +35883,13 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
35878
35883
|
};
|
|
35879
35884
|
}, [checkoutId]); // Only re-run if checkoutId changes
|
|
35880
35885
|
const onSuccess = () => {
|
|
35881
|
-
|
|
35882
|
-
useFormStore.getState().setStep("customer");
|
|
35883
|
-
useFormStore.getState().setFormData({ customer: formData.customer });
|
|
35886
|
+
resetFormStore(formData);
|
|
35884
35887
|
if (successUrl) {
|
|
35885
35888
|
window.location.href = successUrl;
|
|
35886
35889
|
}
|
|
35887
35890
|
};
|
|
35888
35891
|
const onCancel = () => {
|
|
35889
|
-
|
|
35890
|
-
useFormStore.getState().setStep("customer");
|
|
35891
|
-
useFormStore.getState().setFormData({ customer: formData.customer });
|
|
35892
|
+
resetFormStore(formData);
|
|
35892
35893
|
if (cancelUrl) {
|
|
35893
35894
|
window.location.href = cancelUrl;
|
|
35894
35895
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3263,7 +3263,8 @@ const CheckoutEmbed$2 = {
|
|
|
3263
3263
|
title: "Přeprava",
|
|
3264
3264
|
description: {
|
|
3265
3265
|
other: "Váš balíček bude doručen kurýrem.",
|
|
3266
|
-
zasilkovna: "Váš balíček bude doručen do bodu vyzvednutí."
|
|
3266
|
+
zasilkovna: "Váš balíček bude doručen do bodu vyzvednutí.",
|
|
3267
|
+
shippedTo: "Doručeno do:"
|
|
3267
3268
|
}
|
|
3268
3269
|
}
|
|
3269
3270
|
};
|
|
@@ -35416,6 +35417,10 @@ const useFormStore = create()(persist((set) => ({
|
|
|
35416
35417
|
checkoutId: "",
|
|
35417
35418
|
setCheckoutId: (checkoutId) => set({ checkoutId }),
|
|
35418
35419
|
}), { name: `checkout` }));
|
|
35420
|
+
const resetFormStore = (formData) => {
|
|
35421
|
+
const currentState = JSON.parse(localStorage.getItem("checkout") || "{}");
|
|
35422
|
+
localStorage.setItem("checkout", JSON.stringify(Object.assign(Object.assign({}, currentState), { state: Object.assign(Object.assign({}, currentState.state), { step: "customer", formData: { customer: formData.customer } }) })));
|
|
35423
|
+
};
|
|
35419
35424
|
|
|
35420
35425
|
const motionSettings = {
|
|
35421
35426
|
initial: { opacity: 0 },
|
|
@@ -35855,17 +35860,13 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
35855
35860
|
};
|
|
35856
35861
|
}, [checkoutId]); // Only re-run if checkoutId changes
|
|
35857
35862
|
const onSuccess = () => {
|
|
35858
|
-
|
|
35859
|
-
useFormStore.getState().setStep("customer");
|
|
35860
|
-
useFormStore.getState().setFormData({ customer: formData.customer });
|
|
35863
|
+
resetFormStore(formData);
|
|
35861
35864
|
if (successUrl) {
|
|
35862
35865
|
window.location.href = successUrl;
|
|
35863
35866
|
}
|
|
35864
35867
|
};
|
|
35865
35868
|
const onCancel = () => {
|
|
35866
|
-
|
|
35867
|
-
useFormStore.getState().setStep("customer");
|
|
35868
|
-
useFormStore.getState().setFormData({ customer: formData.customer });
|
|
35869
|
+
resetFormStore(formData);
|
|
35869
35870
|
if (cancelUrl) {
|
|
35870
35871
|
window.location.href = cancelUrl;
|
|
35871
35872
|
}
|