flowrix 1.0.1-beta.14 → 1.0.1-beta.141
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/module.d.mts +1 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +169 -30
- package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
- package/dist/runtime/composables/Blog/useBlogSingle.js +2 -4
- package/dist/runtime/composables/Brand/brand.d.ts +1 -1
- package/dist/runtime/composables/Brand/brand.js +30 -2
- package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
- package/dist/runtime/composables/Cart/useCart.js +10 -0
- package/dist/runtime/composables/Cart/useCartComponent.d.ts +1 -0
- package/dist/runtime/composables/Cart/useCartComponent.js +11 -0
- package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
- package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
- package/dist/runtime/composables/Category/useCategoryIndex.d.ts +25 -32
- package/dist/runtime/composables/Category/useCategoryIndex.js +63 -44
- package/dist/runtime/composables/Checkout/PaymentMethods/useDirectDeposit.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useEway.js +16 -6
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +10 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +10 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaypal.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useZippay.js +8 -0
- package/dist/runtime/composables/Checkout/useCheckout.d.ts +85 -73
- package/dist/runtime/composables/Checkout/useCheckout.js +84 -53
- package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.d.ts +43 -0
- package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.js +84 -0
- package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.d.ts +55 -0
- package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.js +196 -0
- package/dist/runtime/composables/Checkout/useCreateAccount.d.ts +7 -7
- package/dist/runtime/composables/Checkout/useCreateAccount.js +3 -1
- package/dist/runtime/composables/Checkout/useDeliveryMethod.d.ts +2 -2
- package/dist/runtime/composables/Checkout/useDeliveryMethod.js +18 -11
- package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
- package/dist/runtime/composables/Customer/useBillingAddress.js +93 -0
- package/dist/runtime/composables/Customer/useLogin.d.ts +9 -0
- package/dist/runtime/composables/Customer/useLogin.js +34 -0
- package/dist/runtime/composables/Customer/useOrders.d.ts +29 -0
- package/dist/runtime/composables/Customer/useOrders.js +56 -0
- package/dist/runtime/composables/Customer/usePasswordReset.d.ts +26 -0
- package/dist/runtime/composables/Customer/usePasswordReset.js +258 -0
- package/dist/runtime/composables/Customer/useProfile.d.ts +75 -0
- package/dist/runtime/composables/Customer/useProfile.js +106 -0
- package/dist/runtime/composables/Customer/useQuotations.d.ts +32 -0
- package/dist/runtime/composables/Customer/useQuotations.js +40 -0
- package/dist/runtime/composables/Customer/useRegister.d.ts +121 -13
- package/dist/runtime/composables/Customer/useRegister.js +310 -35
- package/dist/runtime/composables/Customer/useShippingAddress.d.ts +121 -0
- package/dist/runtime/composables/Customer/useShippingAddress.js +145 -0
- package/dist/runtime/composables/Customer/useUpdatePassword.d.ts +21 -0
- package/dist/runtime/composables/Customer/useUpdatePassword.js +130 -0
- package/dist/runtime/composables/Customer/useUserCards.d.ts +22 -0
- package/dist/runtime/composables/Customer/useUserCards.js +65 -0
- package/dist/runtime/composables/{useWishlists.d.ts → Customer/useWishlists.d.ts} +7 -20
- package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -30
- package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
- package/dist/runtime/composables/Extras/useCountry.js +5 -4
- package/dist/runtime/composables/Footer/useFooter.d.ts +4 -4
- package/dist/runtime/composables/Footer/useFooter.js +12 -8
- package/dist/runtime/composables/Header/useHeader.d.ts +6 -20
- package/dist/runtime/composables/Header/useHeader.js +3 -2
- package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.js +4 -5
- package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
- package/dist/runtime/composables/Product/useProductComponent.js +110 -0
- package/dist/runtime/composables/Product/useProductSlug.d.ts +8 -1
- package/dist/runtime/composables/Product/useQuickView.d.ts +8 -0
- package/dist/runtime/composables/Product/useQuickView.js +27 -0
- package/dist/runtime/composables/Product/useService.d.ts +42 -15
- package/dist/runtime/composables/Product/useService.js +137 -48
- package/dist/runtime/composables/Samples/useSamples.d.ts +5 -6
- package/dist/runtime/composables/Samples/useSamples.js +19 -15
- package/dist/runtime/composables/SideBar/Filters/useFilters.d.ts +2 -2
- package/dist/runtime/composables/SideBar/Filters/useSorting.d.ts +2 -2
- package/dist/runtime/composables/index.d.ts +18 -12
- package/dist/runtime/composables/index.js +18 -12
- package/dist/runtime/composables/useAddresses.js +6 -6
- package/dist/runtime/composables/useApp.d.ts +1 -0
- package/dist/runtime/composables/useApp.js +88 -0
- package/dist/runtime/composables/useCards.js +2 -2
- package/dist/runtime/composables/useDataLayer.js +1 -1
- package/dist/runtime/composables/useDotDigital.d.ts +3 -0
- package/dist/runtime/composables/useDotDigital.js +122 -0
- package/dist/runtime/composables/useLocation.d.ts +61 -19
- package/dist/runtime/composables/useLocation.js +353 -25
- package/dist/runtime/composables/useMetaLayer.js +11 -11
- package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
- package/dist/runtime/composables/useQuotationCheckout.js +137 -0
- package/dist/runtime/composables/useSubscriptions.d.ts +17 -10
- package/dist/runtime/composables/useSubscriptions.js +68 -33
- package/dist/runtime/composables/useTikTokDatalayer.js +7 -7
- package/dist/runtime/composables/useWebforms.d.ts +38 -9
- package/dist/runtime/composables/useWebforms.js +93 -60
- package/dist/runtime/middleware/flowrix.d.ts +5 -4
- package/dist/runtime/middleware/flowrix.js +40 -22
- package/dist/runtime/pages/404.d.vue.ts +3 -0
- package/dist/runtime/pages/404.vue +6 -0
- package/dist/runtime/pages/404.vue.d.ts +3 -0
- package/dist/runtime/pages/flowrix-default.d.vue.ts +3 -0
- package/dist/runtime/pages/flowrix-default.vue +42 -0
- package/dist/runtime/pages/flowrix-default.vue.d.ts +3 -0
- package/dist/runtime/plugin.d.ts +1 -1
- package/dist/runtime/plugins/router.d.ts +2 -0
- package/dist/runtime/plugins/router.js +11 -0
- package/dist/runtime/server/api/albums.d.ts +1 -0
- package/dist/runtime/server/api/albums.js +35 -7
- package/dist/runtime/server/api/auth/forgot.js +1 -2
- package/dist/runtime/server/api/auth/login.d.ts +7 -0
- package/dist/runtime/server/api/auth/login.js +4 -16
- package/dist/runtime/server/api/auth/logout.js +1 -2
- package/dist/runtime/server/api/auth/register.js +1 -2
- package/dist/runtime/server/api/auth/session.get.js +1 -3
- package/dist/runtime/server/api/auth/user/reset-password.js +1 -2
- package/dist/runtime/server/api/auth/user/session.js +1 -2
- package/dist/runtime/server/api/auth/user/verify-token.js +1 -2
- package/dist/runtime/server/api/banners.js +20 -15
- package/dist/runtime/server/api/brand/[...slug].js +55 -0
- package/dist/runtime/server/api/brand/index.d.ts +3 -0
- package/dist/runtime/server/api/brand/index.js +46 -0
- package/dist/runtime/server/api/cache/[...slug].delete.d.ts +4 -1
- package/dist/runtime/server/api/cache/[...slug].delete.js +4 -7
- package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
- package/dist/runtime/server/api/cache/clean.get.js +4 -7
- package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
- package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
- package/dist/runtime/server/api/{v2/[...slug].d.ts → cart/related.d.ts} +0 -1
- package/dist/runtime/server/api/cart/related.js +21 -0
- package/dist/runtime/server/api/cart/remove.d.ts +1 -1
- package/dist/runtime/server/api/cart/remove.js +10 -10
- package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
- package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
- package/dist/runtime/server/api/catalog/brands.js +52 -0
- package/dist/runtime/server/api/catalog/categories.js +28 -19
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
- package/dist/runtime/server/api/catalog/categoriesall.js +52 -0
- package/dist/runtime/server/api/catalog/featured.js +28 -17
- package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
- package/dist/runtime/server/api/catalog/posts.js +52 -0
- package/dist/runtime/server/api/catalog/samples.js +28 -19
- package/dist/runtime/server/api/catalog/search.js +28 -19
- package/dist/runtime/server/api/category/[...slug].js +31 -20
- package/dist/runtime/server/api/check-404.d.ts +4 -0
- package/dist/runtime/server/api/check-404.js +8 -0
- package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
- package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
- package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
- package/dist/runtime/server/api/checkout/configs.js +11 -11
- package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
- package/dist/runtime/server/api/checkout/countries.js +5 -9
- package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
- package/dist/runtime/server/api/checkout/paymentmethod.js +16 -11
- package/dist/runtime/server/api/{blog/blog.d.ts → checkout/quotation/[slug].d.ts} +0 -1
- package/dist/runtime/server/api/checkout/quotation/[slug].js +20 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +35 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +20 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +22 -0
- package/dist/runtime/server/api/checkvariables.d.ts +3 -0
- package/dist/runtime/server/api/checkvariables.js +37 -0
- package/dist/runtime/server/api/cmspost/[...slug].js +54 -0
- package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
- package/dist/runtime/server/api/cmspost/all.js +52 -0
- package/dist/runtime/server/api/company/profile.d.ts +1 -1
- package/dist/runtime/server/api/company/profile.js +12 -7
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +50 -15
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +13 -9
- package/dist/runtime/server/api/countries.d.ts +2 -0
- package/dist/runtime/server/api/countries.js +44 -0
- package/dist/runtime/server/api/customer/address/add.js +1 -2
- package/dist/runtime/server/api/customer/address/delete.js +2 -3
- package/dist/runtime/server/api/customer/address/setshipping.js +1 -2
- package/dist/runtime/server/api/customer/address/update.js +1 -2
- package/dist/runtime/server/api/customer/cards/delete.js +2 -3
- package/dist/runtime/server/api/customer/cards/get.js +2 -3
- package/dist/runtime/server/api/customer/change-password.js +2 -3
- package/dist/runtime/server/api/customer/checkout.js +1 -2
- package/dist/runtime/server/api/customer/orders.js +2 -3
- package/dist/runtime/server/api/customer/profile/update.js +1 -2
- package/dist/runtime/server/api/customer/quotations.js +2 -3
- package/dist/runtime/server/api/customer/search.js +1 -2
- package/dist/runtime/server/api/customer/tax-invoice.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/add.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/get.js +2 -3
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -3
- package/dist/runtime/server/api/featured.d.ts +3 -0
- package/dist/runtime/server/api/featured.js +52 -0
- package/dist/runtime/server/api/generate/robots.get.d.ts +2 -0
- package/dist/runtime/server/api/generate/robots.get.js +20 -0
- package/dist/runtime/server/api/generate/sitemap.get.d.ts +2 -0
- package/dist/runtime/server/api/generate/sitemap.get.js +32 -0
- package/dist/runtime/server/api/location.d.ts +1 -1
- package/dist/runtime/server/api/location.js +24 -12
- package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
- package/dist/runtime/server/api/nav/[id]/links.js +46 -10
- package/dist/runtime/server/api/page/[...slug].js +54 -0
- package/dist/runtime/server/api/product/[...slug].js +28 -13
- package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
- package/dist/runtime/server/api/quickview/[slug].js +21 -0
- package/dist/runtime/server/api/reviews.d.ts +2 -0
- package/dist/runtime/server/api/reviews.js +23 -0
- package/dist/runtime/server/api/samples.d.ts +3 -0
- package/dist/runtime/server/api/samples.js +53 -0
- package/dist/runtime/server/api/search.d.ts +3 -0
- package/dist/runtime/server/api/search.js +53 -0
- package/dist/runtime/server/api/service/[slug].js +22 -16
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/availability.js +14 -12
- package/dist/runtime/server/api/service/getall.d.ts +3 -0
- package/dist/runtime/server/api/service/getall.js +57 -0
- package/dist/runtime/server/api/shop.d.ts +3 -0
- package/dist/runtime/server/api/shop.js +53 -0
- package/dist/runtime/server/api/subscribe.d.ts +1 -1
- package/dist/runtime/server/api/subscribe.js +23 -14
- package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
- package/dist/runtime/server/api/v2/[...slug].get.js +32 -0
- package/dist/runtime/server/api/webform.d.ts +3 -0
- package/dist/runtime/server/api/webform.js +54 -0
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/stores/Cart.d.ts +12 -0
- package/dist/runtime/stores/Cart.js +62 -17
- package/dist/runtime/stores/Checkout.d.ts +9 -15
- package/dist/runtime/stores/Checkout.js +38 -45
- package/dist/runtime/stores/IpLocation.d.ts +95 -4
- package/dist/runtime/stores/IpLocation.js +93 -15
- package/dist/runtime/stores/Search.d.ts +1 -1
- package/dist/runtime/stores/Services.d.ts +5 -0
- package/dist/runtime/stores/Services.js +59 -8
- package/dist/runtime/stores/auth.d.ts +8 -11
- package/dist/runtime/stores/auth.js +385 -8
- package/dist/runtime/stores/countries.d.ts +1 -3
- package/dist/runtime/stores/countries.js +4 -8
- package/dist/runtime/stores/product/README.md +6 -6
- package/dist/runtime/stores/product/slug.d.ts +1 -17
- package/dist/runtime/stores/webforms.d.ts +24 -9
- package/dist/runtime/stores/webforms.js +105 -5
- package/dist/runtime/stores/wishlists.d.ts +125 -8
- package/dist/runtime/stores/wishlists.js +212 -20
- package/dist/runtime/utils/api.js +7 -13
- package/dist/runtime/utils/htmlCache.d.ts +2 -2
- package/dist/runtime/utils/htmlCache.js +23 -13
- package/dist/types.d.mts +6 -2
- package/package.json +16 -5
- package/dist/runtime/composables/Checkout/useBillingAddress.d.ts +0 -19
- package/dist/runtime/composables/Checkout/useBillingAddress.js +0 -82
- package/dist/runtime/composables/Checkout/useShippingAddress.d.ts +0 -9
- package/dist/runtime/composables/Checkout/useShippingAddress.js +0 -121
- package/dist/runtime/composables/useAuth.d.ts +0 -45
- package/dist/runtime/composables/useAuth.js +0 -180
- package/dist/runtime/composables/useCountries.d.ts +0 -12
- package/dist/runtime/composables/useCountries.js +0 -50
- package/dist/runtime/composables/useOrders.d.ts +0 -21
- package/dist/runtime/composables/useOrders.js +0 -82
- package/dist/runtime/composables/useQuotations.d.ts +0 -14
- package/dist/runtime/composables/useQuotations.js +0 -50
- package/dist/runtime/server/api/blog/[slug].js +0 -51
- package/dist/runtime/server/api/blog/blog.js +0 -17
- package/dist/runtime/server/api/brand/[slug].js +0 -58
- package/dist/runtime/server/api/page/[slug].js +0 -51
- package/dist/runtime/server/api/v2/[...slug].js +0 -9
- /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { useCheckoutStore } from "../../stores/Checkout.js";
|
|
2
|
+
import { GTM_add_shipping_info } from "../useDataLayer.js";
|
|
3
|
+
import { META_add_shipping_info } from "../useMetaLayer.js";
|
|
4
|
+
import useStripe from "./PaymentMethods/useStripe.js";
|
|
5
|
+
export default function(inputData) {
|
|
3
6
|
const checkoutStore = useCheckoutStore();
|
|
4
|
-
const updateDeliveryMethod = (async (
|
|
5
|
-
await checkoutStore.saveToCheckoutSession(
|
|
6
|
-
const { getpaymentMethod } =
|
|
7
|
+
const updateDeliveryMethod = (async (inputData2) => {
|
|
8
|
+
await checkoutStore.saveToCheckoutSession(inputData2);
|
|
9
|
+
const { getpaymentMethod } = useStripe();
|
|
7
10
|
const totalPrice = checkoutStore.config ? checkoutStore.config.calculations.total : checkoutStore.config.total;
|
|
8
|
-
if (
|
|
9
|
-
getpaymentMethod("web-stripe",
|
|
11
|
+
if (inputData2.paymentmethod && inputData2.paymentmethod == "web-stripe") {
|
|
12
|
+
getpaymentMethod("web-stripe", inputData2, totalPrice);
|
|
10
13
|
}
|
|
11
14
|
const cart = [];
|
|
12
15
|
cart.items = checkoutStore.config.cart;
|
|
@@ -15,10 +18,7 @@ export default function() {
|
|
|
15
18
|
let shipping_method = shippingmethods.filter((method) => method.selected == true)[0];
|
|
16
19
|
let deliverymethods = checkoutStore.config.preferences;
|
|
17
20
|
let delivery_method = deliverymethods.filter((method) => method.selected == true)[0];
|
|
18
|
-
if (delivery_method.id ==
|
|
19
|
-
if (shipping_method) {
|
|
20
|
-
}
|
|
21
|
-
} else if (delivery_method.id == 2) {
|
|
21
|
+
if (delivery_method.id == 2) {
|
|
22
22
|
shipping_method = {
|
|
23
23
|
"id": 0,
|
|
24
24
|
"title": "Click and Collect",
|
|
@@ -27,6 +27,13 @@ export default function() {
|
|
|
27
27
|
"price": 0,
|
|
28
28
|
"selected": true
|
|
29
29
|
};
|
|
30
|
+
GTM_add_shipping_info(cart, shipping_method);
|
|
31
|
+
META_add_shipping_info(cart, shipping_method);
|
|
32
|
+
} else {
|
|
33
|
+
if (shipping_method) {
|
|
34
|
+
GTM_add_shipping_info(cart, shipping_method);
|
|
35
|
+
META_add_shipping_info(cart, shipping_method);
|
|
36
|
+
}
|
|
30
37
|
}
|
|
31
38
|
});
|
|
32
39
|
return {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export interface BillingForm {
|
|
2
|
+
id: string | number;
|
|
3
|
+
firstname: string;
|
|
4
|
+
lastname: string;
|
|
5
|
+
saddress: string;
|
|
6
|
+
suburb: string;
|
|
7
|
+
state: string;
|
|
8
|
+
state_id: string | number;
|
|
9
|
+
country: string;
|
|
10
|
+
country_id: string | number;
|
|
11
|
+
postcode: string;
|
|
12
|
+
mobile: string;
|
|
13
|
+
shipping: string | number;
|
|
14
|
+
billing: string | number;
|
|
15
|
+
}
|
|
16
|
+
export declare function useBillingAddress(): {
|
|
17
|
+
billingForm: import("vue").Ref<{
|
|
18
|
+
id: string | number;
|
|
19
|
+
firstname: string;
|
|
20
|
+
lastname: string;
|
|
21
|
+
saddress: string;
|
|
22
|
+
suburb: string;
|
|
23
|
+
state: string;
|
|
24
|
+
state_id: string | number;
|
|
25
|
+
country: string;
|
|
26
|
+
country_id: string | number;
|
|
27
|
+
postcode: string;
|
|
28
|
+
mobile: string;
|
|
29
|
+
shipping: string | number;
|
|
30
|
+
billing: string | number;
|
|
31
|
+
}, BillingForm | {
|
|
32
|
+
id: string | number;
|
|
33
|
+
firstname: string;
|
|
34
|
+
lastname: string;
|
|
35
|
+
saddress: string;
|
|
36
|
+
suburb: string;
|
|
37
|
+
state: string;
|
|
38
|
+
state_id: string | number;
|
|
39
|
+
country: string;
|
|
40
|
+
country_id: string | number;
|
|
41
|
+
postcode: string;
|
|
42
|
+
mobile: string;
|
|
43
|
+
shipping: string | number;
|
|
44
|
+
billing: string | number;
|
|
45
|
+
}>;
|
|
46
|
+
successMessage: import("vue").Ref<string, string>;
|
|
47
|
+
errorMessage: import("vue").Ref<string, string>;
|
|
48
|
+
isEditing: import("vue").Ref<boolean, boolean>;
|
|
49
|
+
loading: import("vue").Ref<boolean, boolean>;
|
|
50
|
+
submitAddressReturn: import("vue").Ref<any, any>;
|
|
51
|
+
user: import("vue").ComputedRef<{
|
|
52
|
+
id: number;
|
|
53
|
+
fullname: string;
|
|
54
|
+
firstname: string;
|
|
55
|
+
lastname: string;
|
|
56
|
+
email: string;
|
|
57
|
+
avatar: string;
|
|
58
|
+
country_id: number | null;
|
|
59
|
+
country: {
|
|
60
|
+
id: number;
|
|
61
|
+
name: string;
|
|
62
|
+
emoji: string;
|
|
63
|
+
} | null;
|
|
64
|
+
state_id: number | null;
|
|
65
|
+
state: string | null;
|
|
66
|
+
suburb: string | null;
|
|
67
|
+
dob: string | null;
|
|
68
|
+
phone: string | null;
|
|
69
|
+
address: string | null;
|
|
70
|
+
mobile: string | null;
|
|
71
|
+
company: string | null;
|
|
72
|
+
addresses: {
|
|
73
|
+
id: number;
|
|
74
|
+
fullname: string | null;
|
|
75
|
+
firstname: string;
|
|
76
|
+
middlename: string | null;
|
|
77
|
+
lastname: string;
|
|
78
|
+
address: string;
|
|
79
|
+
suburb: string;
|
|
80
|
+
state: string | null;
|
|
81
|
+
state_id: number | null;
|
|
82
|
+
country: string;
|
|
83
|
+
country_id: number;
|
|
84
|
+
postcode: string;
|
|
85
|
+
mobile: string;
|
|
86
|
+
shipping: number;
|
|
87
|
+
billing: number;
|
|
88
|
+
}[];
|
|
89
|
+
created_at: string;
|
|
90
|
+
} | null>;
|
|
91
|
+
userBillingAddress: import("vue").ComputedRef<{
|
|
92
|
+
id: number;
|
|
93
|
+
fullname: string | null;
|
|
94
|
+
firstname: string;
|
|
95
|
+
middlename: string | null;
|
|
96
|
+
lastname: string;
|
|
97
|
+
address: string;
|
|
98
|
+
suburb: string;
|
|
99
|
+
state: string | null;
|
|
100
|
+
state_id: number | null;
|
|
101
|
+
country: string;
|
|
102
|
+
country_id: number;
|
|
103
|
+
postcode: string;
|
|
104
|
+
mobile: string;
|
|
105
|
+
shipping: number;
|
|
106
|
+
billing: number;
|
|
107
|
+
} | undefined>;
|
|
108
|
+
clearMessages: () => void;
|
|
109
|
+
cancelEdit: () => void;
|
|
110
|
+
submitAddress: () => Promise<void>;
|
|
111
|
+
resetForm: () => void;
|
|
112
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ref, computed } from "vue";
|
|
2
|
+
import { useAuthStore } from "../../stores/auth.js";
|
|
3
|
+
export function useBillingAddress() {
|
|
4
|
+
const authStore = useAuthStore();
|
|
5
|
+
const user = computed(() => authStore.user);
|
|
6
|
+
const userBillingAddress = computed(
|
|
7
|
+
() => user.value?.addresses?.find((address) => address.billing == 1)
|
|
8
|
+
);
|
|
9
|
+
const billingForm = ref({
|
|
10
|
+
id: userBillingAddress.value?.id || "",
|
|
11
|
+
firstname: userBillingAddress.value?.firstname || "",
|
|
12
|
+
lastname: userBillingAddress.value?.lastname || "",
|
|
13
|
+
saddress: userBillingAddress.value?.address || "",
|
|
14
|
+
suburb: userBillingAddress.value?.suburb || "",
|
|
15
|
+
state: userBillingAddress.value?.state || "",
|
|
16
|
+
state_id: userBillingAddress.value?.state_id || "",
|
|
17
|
+
country: userBillingAddress.value?.country || "",
|
|
18
|
+
country_id: userBillingAddress.value?.country_id || "",
|
|
19
|
+
postcode: userBillingAddress.value?.postcode || "",
|
|
20
|
+
mobile: userBillingAddress.value?.mobile || "",
|
|
21
|
+
shipping: userBillingAddress.value?.shipping || "",
|
|
22
|
+
billing: userBillingAddress.value?.billing || 1
|
|
23
|
+
});
|
|
24
|
+
const successMessage = ref("");
|
|
25
|
+
const errorMessage = ref("");
|
|
26
|
+
const isEditing = ref(false);
|
|
27
|
+
const loading = ref(false);
|
|
28
|
+
const submitAddressReturn = ref(null);
|
|
29
|
+
const clearMessages = () => {
|
|
30
|
+
successMessage.value = "";
|
|
31
|
+
errorMessage.value = "";
|
|
32
|
+
submitAddressReturn.value = null;
|
|
33
|
+
};
|
|
34
|
+
const resetForm = () => {
|
|
35
|
+
billingForm.value = {
|
|
36
|
+
id: userBillingAddress.value?.id || "",
|
|
37
|
+
firstname: userBillingAddress.value?.firstname || "",
|
|
38
|
+
lastname: userBillingAddress.value?.lastname || "",
|
|
39
|
+
saddress: userBillingAddress.value?.address || "",
|
|
40
|
+
suburb: userBillingAddress.value?.suburb || "",
|
|
41
|
+
state: userBillingAddress.value?.state || "",
|
|
42
|
+
state_id: userBillingAddress.value?.state_id || "",
|
|
43
|
+
country: userBillingAddress.value?.country || "",
|
|
44
|
+
country_id: userBillingAddress.value?.country_id || "",
|
|
45
|
+
postcode: userBillingAddress.value?.postcode || "",
|
|
46
|
+
mobile: userBillingAddress.value?.mobile || "",
|
|
47
|
+
shipping: userBillingAddress.value?.shipping || "",
|
|
48
|
+
billing: userBillingAddress.value?.billing || 1
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const cancelEdit = () => {
|
|
52
|
+
resetForm();
|
|
53
|
+
isEditing.value = false;
|
|
54
|
+
clearMessages();
|
|
55
|
+
};
|
|
56
|
+
const submitAddress = async () => {
|
|
57
|
+
loading.value = true;
|
|
58
|
+
clearMessages();
|
|
59
|
+
try {
|
|
60
|
+
const method = billingForm.value.id ? "update" : "add";
|
|
61
|
+
submitAddressReturn.value = await authStore.setAddress(billingForm.value, method);
|
|
62
|
+
if (submitAddressReturn.value?.status === "Success") {
|
|
63
|
+
await authStore.fetchProfile();
|
|
64
|
+
isEditing.value = false;
|
|
65
|
+
successMessage.value = billingForm.value.id ? "Billing Address updated successfully" : "Billing Address created successfully";
|
|
66
|
+
} else {
|
|
67
|
+
errorMessage.value = submitAddressReturn.value?.message || "Failed to save address";
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error("Address submission error:", error);
|
|
71
|
+
errorMessage.value = error.message || "Failed to save address. Please try again.";
|
|
72
|
+
} finally {
|
|
73
|
+
loading.value = false;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
// State
|
|
78
|
+
billingForm,
|
|
79
|
+
successMessage,
|
|
80
|
+
errorMessage,
|
|
81
|
+
isEditing,
|
|
82
|
+
loading,
|
|
83
|
+
submitAddressReturn,
|
|
84
|
+
// Computed
|
|
85
|
+
user,
|
|
86
|
+
userBillingAddress,
|
|
87
|
+
// Methods
|
|
88
|
+
clearMessages,
|
|
89
|
+
cancelEdit,
|
|
90
|
+
submitAddress,
|
|
91
|
+
resetForm
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function (): {
|
|
2
|
+
router: any;
|
|
3
|
+
route: any;
|
|
4
|
+
email: import("vue").Ref<string, string>;
|
|
5
|
+
password: import("vue").Ref<string, string>;
|
|
6
|
+
CustomerLogin: () => Promise<void>;
|
|
7
|
+
logResponse: import("vue").Ref<any, any>;
|
|
8
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useRouter, useRoute } from "#vue-router";
|
|
3
|
+
import { useAuthStore } from "../../stores/auth.js";
|
|
4
|
+
export default function() {
|
|
5
|
+
const router = useRouter();
|
|
6
|
+
const route = useRoute();
|
|
7
|
+
const email = ref("");
|
|
8
|
+
const password = ref("");
|
|
9
|
+
const logResponse = ref(null);
|
|
10
|
+
const isLoading = ref(false);
|
|
11
|
+
const CustomerLogin = async () => {
|
|
12
|
+
isLoading.value = true;
|
|
13
|
+
try {
|
|
14
|
+
const loginFields = {
|
|
15
|
+
email: email.value,
|
|
16
|
+
password: password.value
|
|
17
|
+
};
|
|
18
|
+
logResponse.value = await useAuthStore().userLogin(loginFields);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
logResponse.value = { status: "Error", message: "Login failed" };
|
|
21
|
+
} finally {
|
|
22
|
+
isLoading.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
router,
|
|
27
|
+
route,
|
|
28
|
+
email,
|
|
29
|
+
password,
|
|
30
|
+
CustomerLogin,
|
|
31
|
+
logResponse,
|
|
32
|
+
isLoading
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface Order {
|
|
2
|
+
order_no: string;
|
|
3
|
+
order_status: string;
|
|
4
|
+
payment_method: string;
|
|
5
|
+
grandtotal: number;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export declare function useOrders(): {
|
|
9
|
+
orders: import("vue").Ref<{
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
order_no: string;
|
|
12
|
+
order_status: string;
|
|
13
|
+
payment_method: string;
|
|
14
|
+
grandtotal: number;
|
|
15
|
+
}[], Order[] | {
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
order_no: string;
|
|
18
|
+
order_status: string;
|
|
19
|
+
payment_method: string;
|
|
20
|
+
grandtotal: number;
|
|
21
|
+
}[]>;
|
|
22
|
+
pending: import("vue").Ref<boolean, boolean>;
|
|
23
|
+
loadingInvoice: import("vue").Ref<string, string>;
|
|
24
|
+
downloadError: import("vue").Ref<string, string>;
|
|
25
|
+
loadOrders: () => Promise<void>;
|
|
26
|
+
generateInvoice: (invoiceNumber: string) => Promise<void>;
|
|
27
|
+
clearError: () => void;
|
|
28
|
+
hasOrders: () => boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useAuthStore } from "../../stores/auth.js";
|
|
3
|
+
export function useOrders() {
|
|
4
|
+
const authStore = useAuthStore();
|
|
5
|
+
const orders = ref([]);
|
|
6
|
+
const pending = ref(true);
|
|
7
|
+
const loadingInvoice = ref("");
|
|
8
|
+
const downloadError = ref("");
|
|
9
|
+
const loadOrders = async () => {
|
|
10
|
+
pending.value = true;
|
|
11
|
+
downloadError.value = "";
|
|
12
|
+
try {
|
|
13
|
+
const ordersData = await authStore.fetchOrders();
|
|
14
|
+
orders.value = Array.isArray(ordersData) ? ordersData : [];
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Failed to load orders:", error);
|
|
17
|
+
orders.value = [];
|
|
18
|
+
downloadError.value = "Failed to load orders. Please try again.";
|
|
19
|
+
} finally {
|
|
20
|
+
pending.value = false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const generateInvoice = async (invoiceNumber) => {
|
|
24
|
+
loadingInvoice.value = invoiceNumber;
|
|
25
|
+
downloadError.value = "";
|
|
26
|
+
try {
|
|
27
|
+
const response = await authStore.downloadInvoice(invoiceNumber);
|
|
28
|
+
if (response && response.type === void 0) {
|
|
29
|
+
downloadError.value = "Invoice cannot be downloaded. Please try again...";
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Invoice download error:", error);
|
|
33
|
+
downloadError.value = error.message || "Invoice cannot be downloaded. Please try again...";
|
|
34
|
+
} finally {
|
|
35
|
+
loadingInvoice.value = "";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const clearError = () => {
|
|
39
|
+
downloadError.value = "";
|
|
40
|
+
};
|
|
41
|
+
const hasOrders = () => {
|
|
42
|
+
return orders.value && orders.value.length > 0;
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
// State
|
|
46
|
+
orders,
|
|
47
|
+
pending,
|
|
48
|
+
loadingInvoice,
|
|
49
|
+
downloadError,
|
|
50
|
+
// Methods
|
|
51
|
+
loadOrders,
|
|
52
|
+
generateInvoice,
|
|
53
|
+
clearError,
|
|
54
|
+
hasOrders
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default function (timerDuration?: number): {
|
|
2
|
+
email: import("vue").Ref<string, string>;
|
|
3
|
+
resetCode: import("vue").Ref<string, string>;
|
|
4
|
+
newPassword: import("vue").Ref<string, string>;
|
|
5
|
+
confirmPassword: import("vue").Ref<string, string>;
|
|
6
|
+
showPassword: import("vue").Ref<boolean, boolean>;
|
|
7
|
+
showConfirmPassword: import("vue").Ref<boolean, boolean>;
|
|
8
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
9
|
+
errorMessage: import("vue").Ref<string, string>;
|
|
10
|
+
successMessage: import("vue").Ref<string, string>;
|
|
11
|
+
isCodeSent: import("vue").Ref<boolean, boolean>;
|
|
12
|
+
isCodeVerified: import("vue").Ref<boolean, boolean>;
|
|
13
|
+
currentStep: import("vue").Ref<number, number>;
|
|
14
|
+
timerCount: import("vue").Ref<number, number>;
|
|
15
|
+
isTimerActive: import("vue").Ref<boolean, boolean>;
|
|
16
|
+
formatTime: (seconds: number) => string;
|
|
17
|
+
togglePassword: (field: "newPassword" | "confirmPassword") => void;
|
|
18
|
+
handleSubmit: () => Promise<void>;
|
|
19
|
+
resetForm: () => void;
|
|
20
|
+
resendCode: () => Promise<void>;
|
|
21
|
+
startTimer: (duration?: number) => void;
|
|
22
|
+
stopTimer: () => void;
|
|
23
|
+
resetTimer: (duration?: number) => void;
|
|
24
|
+
cleanup: () => void;
|
|
25
|
+
router: any;
|
|
26
|
+
};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useRouter, useRoute } from "#vue-router";
|
|
3
|
+
import { useAuthStore } from "../../stores/auth.js";
|
|
4
|
+
export default function(timerDuration = 60) {
|
|
5
|
+
const router = useRouter();
|
|
6
|
+
const route = useRoute();
|
|
7
|
+
const authStore = useAuthStore();
|
|
8
|
+
const email = ref("");
|
|
9
|
+
const resetCode = ref("");
|
|
10
|
+
const newPassword = ref("");
|
|
11
|
+
const confirmPassword = ref("");
|
|
12
|
+
const showPassword = ref(false);
|
|
13
|
+
const showConfirmPassword = ref(false);
|
|
14
|
+
const isLoading = ref(false);
|
|
15
|
+
const errorMessage = ref("");
|
|
16
|
+
const successMessage = ref("");
|
|
17
|
+
const isCodeSent = ref(false);
|
|
18
|
+
const isCodeVerified = ref(false);
|
|
19
|
+
const currentStep = ref(1);
|
|
20
|
+
const verifiedToken = ref("");
|
|
21
|
+
const timerCount = ref(timerDuration);
|
|
22
|
+
const isTimerActive = ref(false);
|
|
23
|
+
const timerInterval = ref(null);
|
|
24
|
+
const validateEmail = (email2) => {
|
|
25
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email2);
|
|
26
|
+
};
|
|
27
|
+
const togglePassword = (field) => {
|
|
28
|
+
if (field === "newPassword") {
|
|
29
|
+
showPassword.value = !showPassword.value;
|
|
30
|
+
} else {
|
|
31
|
+
showConfirmPassword.value = !showConfirmPassword.value;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const startTimer = (duration = timerDuration) => {
|
|
35
|
+
isTimerActive.value = true;
|
|
36
|
+
timerCount.value = duration;
|
|
37
|
+
timerInterval.value = setInterval(() => {
|
|
38
|
+
timerCount.value--;
|
|
39
|
+
if (timerCount.value <= 0) {
|
|
40
|
+
clearInterval(timerInterval.value);
|
|
41
|
+
isTimerActive.value = false;
|
|
42
|
+
}
|
|
43
|
+
}, 1e3);
|
|
44
|
+
};
|
|
45
|
+
const stopTimer = () => {
|
|
46
|
+
if (timerInterval.value) {
|
|
47
|
+
clearInterval(timerInterval.value);
|
|
48
|
+
timerInterval.value = null;
|
|
49
|
+
}
|
|
50
|
+
isTimerActive.value = false;
|
|
51
|
+
};
|
|
52
|
+
const resetTimer = (duration = timerDuration) => {
|
|
53
|
+
stopTimer();
|
|
54
|
+
timerCount.value = duration;
|
|
55
|
+
};
|
|
56
|
+
const formatTime = (seconds) => {
|
|
57
|
+
const mins = Math.floor(seconds / 60);
|
|
58
|
+
const secs = seconds % 60;
|
|
59
|
+
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
|
60
|
+
};
|
|
61
|
+
const resendCode = async () => {
|
|
62
|
+
if (!validateEmail(email.value)) {
|
|
63
|
+
errorMessage.value = "Please enter a valid email address";
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
isLoading.value = true;
|
|
67
|
+
errorMessage.value = "";
|
|
68
|
+
successMessage.value = "";
|
|
69
|
+
try {
|
|
70
|
+
const response = await authStore.verifyEmail(email.value.trim());
|
|
71
|
+
if (response.status === "Success") {
|
|
72
|
+
successMessage.value = "Reset code sent to your email again!";
|
|
73
|
+
errorMessage.value = "";
|
|
74
|
+
startTimer();
|
|
75
|
+
} else {
|
|
76
|
+
errorMessage.value = formatErrorMessage(response.message) || "Failed to resend reset code. Please try again.";
|
|
77
|
+
successMessage.value = "";
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
errorMessage.value = "An error occurred while resending code. Please try again.";
|
|
81
|
+
successMessage.value = "";
|
|
82
|
+
} finally {
|
|
83
|
+
isLoading.value = false;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const sendResetCode = async () => {
|
|
87
|
+
if (!validateEmail(email.value)) {
|
|
88
|
+
errorMessage.value = "Please enter a valid email address";
|
|
89
|
+
successMessage.value = "";
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
isLoading.value = true;
|
|
93
|
+
errorMessage.value = "";
|
|
94
|
+
successMessage.value = "";
|
|
95
|
+
try {
|
|
96
|
+
const response = await authStore.verifyEmail(email.value.trim());
|
|
97
|
+
if (response.status === "Success") {
|
|
98
|
+
successMessage.value = "Reset code sent to your email!";
|
|
99
|
+
errorMessage.value = "";
|
|
100
|
+
isCodeSent.value = true;
|
|
101
|
+
currentStep.value = 2;
|
|
102
|
+
startTimer();
|
|
103
|
+
} else {
|
|
104
|
+
errorMessage.value = formatErrorMessage(response.message) || "Failed to send reset code. Please try again.";
|
|
105
|
+
successMessage.value = "";
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
errorMessage.value = "An error occurred while sending reset code. Please try again.";
|
|
109
|
+
successMessage.value = "";
|
|
110
|
+
} finally {
|
|
111
|
+
isLoading.value = false;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const verifyResetCode = async () => {
|
|
115
|
+
if (!resetCode.value) {
|
|
116
|
+
errorMessage.value = "Please enter the reset code";
|
|
117
|
+
successMessage.value = "";
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
isLoading.value = true;
|
|
121
|
+
errorMessage.value = "";
|
|
122
|
+
successMessage.value = "";
|
|
123
|
+
try {
|
|
124
|
+
const response = await authStore.verifyToken(email.value.trim(), resetCode.value.trim());
|
|
125
|
+
if (response.status === "Success") {
|
|
126
|
+
verifiedToken.value = response.data?.token || response.data;
|
|
127
|
+
successMessage.value = "Code verified successfully!";
|
|
128
|
+
errorMessage.value = "";
|
|
129
|
+
isCodeVerified.value = true;
|
|
130
|
+
currentStep.value = 3;
|
|
131
|
+
stopTimer();
|
|
132
|
+
} else {
|
|
133
|
+
errorMessage.value = formatErrorMessage(response.message) || "Invalid reset code. Please try again.";
|
|
134
|
+
successMessage.value = "";
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
errorMessage.value = "An error occurred while verifying code. Please try again.";
|
|
138
|
+
successMessage.value = "";
|
|
139
|
+
} finally {
|
|
140
|
+
isLoading.value = false;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const resetPasswordFunc = async () => {
|
|
144
|
+
if (newPassword.value !== confirmPassword.value) {
|
|
145
|
+
errorMessage.value = "Passwords do not match";
|
|
146
|
+
successMessage.value = "";
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (newPassword.value.length < 8) {
|
|
150
|
+
errorMessage.value = "Password must be at least 8 characters long";
|
|
151
|
+
successMessage.value = "";
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
isLoading.value = true;
|
|
155
|
+
errorMessage.value = "";
|
|
156
|
+
successMessage.value = "";
|
|
157
|
+
try {
|
|
158
|
+
const response = await authStore.resetPassword(
|
|
159
|
+
verifiedToken.value,
|
|
160
|
+
newPassword.value.trim(),
|
|
161
|
+
confirmPassword.value.trim()
|
|
162
|
+
);
|
|
163
|
+
if (response.status === "Success") {
|
|
164
|
+
const loginResponse = await authStore.userLogin({
|
|
165
|
+
email: email.value.trim(),
|
|
166
|
+
password: newPassword.value.trim()
|
|
167
|
+
});
|
|
168
|
+
if (loginResponse.status === "Success") {
|
|
169
|
+
resetForm();
|
|
170
|
+
successMessage.value = formatErrorMessage(response.message) || "Password reset successfully!";
|
|
171
|
+
errorMessage.value = "";
|
|
172
|
+
router.push("dashboard/profile");
|
|
173
|
+
} else {
|
|
174
|
+
successMessage.value = formatErrorMessage(response.message) || "Password reset successfully!";
|
|
175
|
+
errorMessage.value = "Password reset successful, but login failed. Please login manually.";
|
|
176
|
+
resetCode.value = "";
|
|
177
|
+
verifiedToken.value = "";
|
|
178
|
+
isCodeSent.value = false;
|
|
179
|
+
isCodeVerified.value = false;
|
|
180
|
+
currentStep.value = 1;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
errorMessage.value = formatErrorMessage(response.message) || "Failed to reset password. Please try again.";
|
|
184
|
+
successMessage.value = "";
|
|
185
|
+
}
|
|
186
|
+
} catch (error) {
|
|
187
|
+
errorMessage.value = "An error occurred while resetting password. Please try again.";
|
|
188
|
+
successMessage.value = "";
|
|
189
|
+
} finally {
|
|
190
|
+
isLoading.value = false;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const handleSubmit = async () => {
|
|
194
|
+
if (currentStep.value === 1) {
|
|
195
|
+
await sendResetCode();
|
|
196
|
+
} else if (currentStep.value === 2) {
|
|
197
|
+
await verifyResetCode();
|
|
198
|
+
} else {
|
|
199
|
+
await resetPasswordFunc();
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const formatErrorMessage = (message) => {
|
|
203
|
+
if (Array.isArray(message)) {
|
|
204
|
+
return message.join(", ");
|
|
205
|
+
}
|
|
206
|
+
return message;
|
|
207
|
+
};
|
|
208
|
+
const resetForm = () => {
|
|
209
|
+
email.value = "";
|
|
210
|
+
resetCode.value = "";
|
|
211
|
+
newPassword.value = "";
|
|
212
|
+
confirmPassword.value = "";
|
|
213
|
+
showPassword.value = false;
|
|
214
|
+
showConfirmPassword.value = false;
|
|
215
|
+
isLoading.value = false;
|
|
216
|
+
errorMessage.value = "";
|
|
217
|
+
successMessage.value = "";
|
|
218
|
+
isCodeSent.value = false;
|
|
219
|
+
isCodeVerified.value = false;
|
|
220
|
+
currentStep.value = 1;
|
|
221
|
+
verifiedToken.value = "";
|
|
222
|
+
stopTimer();
|
|
223
|
+
};
|
|
224
|
+
const cleanup = () => {
|
|
225
|
+
stopTimer();
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
// State
|
|
229
|
+
email,
|
|
230
|
+
resetCode,
|
|
231
|
+
newPassword,
|
|
232
|
+
confirmPassword,
|
|
233
|
+
showPassword,
|
|
234
|
+
showConfirmPassword,
|
|
235
|
+
isLoading,
|
|
236
|
+
errorMessage,
|
|
237
|
+
successMessage,
|
|
238
|
+
isCodeSent,
|
|
239
|
+
isCodeVerified,
|
|
240
|
+
currentStep,
|
|
241
|
+
timerCount,
|
|
242
|
+
isTimerActive,
|
|
243
|
+
formatTime,
|
|
244
|
+
// Methods
|
|
245
|
+
togglePassword,
|
|
246
|
+
handleSubmit,
|
|
247
|
+
resetForm,
|
|
248
|
+
resendCode,
|
|
249
|
+
startTimer,
|
|
250
|
+
// Export startTimer for external control
|
|
251
|
+
stopTimer,
|
|
252
|
+
// Export stopTimer for external control
|
|
253
|
+
resetTimer,
|
|
254
|
+
// Export resetTimer for external control
|
|
255
|
+
cleanup,
|
|
256
|
+
router
|
|
257
|
+
};
|
|
258
|
+
}
|