flowrix 1.0.1-beta.67 → 1.0.1-beta.68
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.json +1 -1
- package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
- package/dist/runtime/composables/Customer/useBillingAddress.js +93 -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/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 +118 -11
- package/dist/runtime/composables/Customer/useRegister.js +234 -34
- 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 +94 -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} +5 -18
- package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +19 -28
- package/dist/runtime/composables/index.d.ts +8 -1
- package/dist/runtime/composables/index.js +8 -1
- package/dist/runtime/server/api/catalog/categories.js +3 -2
- package/dist/runtime/server/api/catalog/categoriesall.js +3 -2
- package/dist/runtime/server/api/catalog/featured.js +3 -2
- package/dist/runtime/server/api/catalog/samples.js +3 -2
- package/dist/runtime/server/api/catalog/search.js +3 -2
- package/dist/runtime/server/api/category/[...slug].js +3 -2
- package/dist/runtime/server/api/cmspost/[...slug].js +3 -2
- package/dist/runtime/server/api/customer/address/delete.js +1 -1
- package/dist/runtime/server/api/customer/cards/delete.js +1 -1
- package/dist/runtime/server/api/customer/cards/get.js +1 -1
- package/dist/runtime/server/api/customer/change-password.js +1 -1
- package/dist/runtime/server/api/customer/orders.js +1 -1
- package/dist/runtime/server/api/customer/quotations.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/get.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +1 -1
- package/dist/runtime/server/api/featured.js +1 -1
- package/dist/runtime/server/api/page/[...slug].js +3 -2
- package/dist/runtime/server/api/product/[...slug].js +3 -2
- package/dist/runtime/server/api/service/[slug].js +3 -2
- package/dist/runtime/server/api/service/getall.js +3 -2
- package/dist/runtime/stores/auth.js +118 -3
- package/dist/runtime/stores/wishlists.d.ts +105 -5
- package/dist/runtime/stores/wishlists.js +200 -9
- package/dist/runtime/utils/htmlCache.d.ts +2 -2
- package/dist/runtime/utils/htmlCache.js +10 -9
- package/package.json +1 -1
- package/dist/runtime/composables/useQuotations.d.ts +0 -14
- package/dist/runtime/composables/useQuotations.js +0 -50
package/dist/module.json
CHANGED
|
@@ -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,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,75 @@
|
|
|
1
|
+
export declare function useProfile(): {
|
|
2
|
+
profile: import("vue").Ref<{
|
|
3
|
+
firstName: string;
|
|
4
|
+
lastName: string;
|
|
5
|
+
email: string;
|
|
6
|
+
phone: string;
|
|
7
|
+
mobile: string;
|
|
8
|
+
dateOfBirth: string;
|
|
9
|
+
}, {
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
email: string;
|
|
13
|
+
phone: string;
|
|
14
|
+
mobile: string;
|
|
15
|
+
dateOfBirth: string;
|
|
16
|
+
} | {
|
|
17
|
+
firstName: string;
|
|
18
|
+
lastName: string;
|
|
19
|
+
email: string;
|
|
20
|
+
phone: string;
|
|
21
|
+
mobile: string;
|
|
22
|
+
dateOfBirth: string;
|
|
23
|
+
}>;
|
|
24
|
+
isEditing: import("vue").Ref<boolean, boolean>;
|
|
25
|
+
loading: import("vue").Ref<boolean, boolean>;
|
|
26
|
+
errorMessage: import("vue").Ref<string, string>;
|
|
27
|
+
successMessage: import("vue").Ref<string, string>;
|
|
28
|
+
dobFormatted: import("vue").WritableComputedRef<string, string>;
|
|
29
|
+
user: import("vue").ComputedRef<{
|
|
30
|
+
id: number;
|
|
31
|
+
fullname: string;
|
|
32
|
+
firstname: string;
|
|
33
|
+
lastname: string;
|
|
34
|
+
email: string;
|
|
35
|
+
avatar: string;
|
|
36
|
+
country_id: number | null;
|
|
37
|
+
country: {
|
|
38
|
+
id: number;
|
|
39
|
+
name: string;
|
|
40
|
+
emoji: string;
|
|
41
|
+
} | null;
|
|
42
|
+
state_id: number | null;
|
|
43
|
+
state: string | null;
|
|
44
|
+
suburb: string | null;
|
|
45
|
+
dob: string | null;
|
|
46
|
+
phone: string | null;
|
|
47
|
+
address: string | null;
|
|
48
|
+
mobile: string | null;
|
|
49
|
+
company: string | null;
|
|
50
|
+
addresses: {
|
|
51
|
+
id: number;
|
|
52
|
+
fullname: string | null;
|
|
53
|
+
firstname: string;
|
|
54
|
+
middlename: string | null;
|
|
55
|
+
lastname: string;
|
|
56
|
+
address: string;
|
|
57
|
+
suburb: string;
|
|
58
|
+
state: string | null;
|
|
59
|
+
state_id: number | null;
|
|
60
|
+
country: string;
|
|
61
|
+
country_id: number;
|
|
62
|
+
postcode: string;
|
|
63
|
+
mobile: string;
|
|
64
|
+
shipping: number;
|
|
65
|
+
billing: number;
|
|
66
|
+
}[];
|
|
67
|
+
created_at: string;
|
|
68
|
+
} | null>;
|
|
69
|
+
formatDisplayDate: (dateString: string) => string;
|
|
70
|
+
clearMessages: () => void;
|
|
71
|
+
cancelEdit: () => void;
|
|
72
|
+
updateCustomerProfile: () => Promise<void>;
|
|
73
|
+
initializeProfile: () => void;
|
|
74
|
+
resetProfile: () => void;
|
|
75
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ref, computed } from "vue";
|
|
2
|
+
import { useAuthStore } from "../../stores/auth.js";
|
|
3
|
+
export function useProfile() {
|
|
4
|
+
const authStore = useAuthStore();
|
|
5
|
+
const user = computed(() => authStore.user);
|
|
6
|
+
const profile = ref({
|
|
7
|
+
firstName: user.value?.firstname || "",
|
|
8
|
+
lastName: user.value?.lastname || "",
|
|
9
|
+
email: user.value?.email || "",
|
|
10
|
+
phone: user.value?.phone || "",
|
|
11
|
+
mobile: user.value?.mobile || "",
|
|
12
|
+
dateOfBirth: user.value?.dob || ""
|
|
13
|
+
});
|
|
14
|
+
const isEditing = ref(false);
|
|
15
|
+
const loading = ref(false);
|
|
16
|
+
const errorMessage = ref("");
|
|
17
|
+
const successMessage = ref("");
|
|
18
|
+
const formatDisplayDate = (dateString) => {
|
|
19
|
+
if (!dateString) return "";
|
|
20
|
+
const date = new Date(dateString);
|
|
21
|
+
if (isNaN(date.getTime())) return dateString;
|
|
22
|
+
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
23
|
+
const day = date.getDate();
|
|
24
|
+
const month = months[date.getMonth()];
|
|
25
|
+
const year = date.getFullYear();
|
|
26
|
+
return `${month} ${day}, ${year}`;
|
|
27
|
+
};
|
|
28
|
+
const dobFormatted = computed({
|
|
29
|
+
get() {
|
|
30
|
+
return profile.value.dateOfBirth ? new Date(profile.value.dateOfBirth).toISOString().split("T")[0] : "";
|
|
31
|
+
},
|
|
32
|
+
set(value) {
|
|
33
|
+
profile.value.dateOfBirth = value;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const clearMessages = () => {
|
|
37
|
+
errorMessage.value = "";
|
|
38
|
+
successMessage.value = "";
|
|
39
|
+
};
|
|
40
|
+
const resetProfile = () => {
|
|
41
|
+
profile.value = {
|
|
42
|
+
firstName: user.value?.firstname || "",
|
|
43
|
+
lastName: user.value?.lastname || "",
|
|
44
|
+
email: user.value?.email || "",
|
|
45
|
+
phone: user.value?.phone || "",
|
|
46
|
+
mobile: user.value?.mobile || "",
|
|
47
|
+
dateOfBirth: user.value?.dob || ""
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const cancelEdit = () => {
|
|
51
|
+
isEditing.value = false;
|
|
52
|
+
resetProfile();
|
|
53
|
+
clearMessages();
|
|
54
|
+
};
|
|
55
|
+
const updateCustomerProfile = async () => {
|
|
56
|
+
if (!profile.value.firstName?.trim() || !profile.value.lastName?.trim() || !profile.value.mobile?.trim()) {
|
|
57
|
+
errorMessage.value = "First name, Last name and Mobile are required!";
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
loading.value = true;
|
|
61
|
+
errorMessage.value = "";
|
|
62
|
+
successMessage.value = "";
|
|
63
|
+
try {
|
|
64
|
+
const requestBody = {
|
|
65
|
+
firstname: profile.value.firstName.trim(),
|
|
66
|
+
lastname: profile.value.lastName.trim(),
|
|
67
|
+
phone: profile.value.phone?.trim() || "",
|
|
68
|
+
mobile: profile.value.mobile?.trim() || "",
|
|
69
|
+
dob: profile.value.dateOfBirth || ""
|
|
70
|
+
};
|
|
71
|
+
const response = await authStore.updateProfile(requestBody);
|
|
72
|
+
if (response.status === "Success") {
|
|
73
|
+
successMessage.value = response.message || "Profile updated successfully!";
|
|
74
|
+
isEditing.value = false;
|
|
75
|
+
} else {
|
|
76
|
+
errorMessage.value = response.message || "Failed to update profile. Please try again.";
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error("Update error:", err);
|
|
80
|
+
errorMessage.value = err.message || "Failed to update profile. Please try again.";
|
|
81
|
+
} finally {
|
|
82
|
+
loading.value = false;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const initializeProfile = () => {
|
|
86
|
+
resetProfile();
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
// State
|
|
90
|
+
profile,
|
|
91
|
+
isEditing,
|
|
92
|
+
loading,
|
|
93
|
+
errorMessage,
|
|
94
|
+
successMessage,
|
|
95
|
+
// Computed
|
|
96
|
+
dobFormatted,
|
|
97
|
+
user,
|
|
98
|
+
// Methods
|
|
99
|
+
formatDisplayDate,
|
|
100
|
+
clearMessages,
|
|
101
|
+
cancelEdit,
|
|
102
|
+
updateCustomerProfile,
|
|
103
|
+
initializeProfile,
|
|
104
|
+
resetProfile
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface Quotation {
|
|
2
|
+
quotation_no: string;
|
|
3
|
+
createddate: string;
|
|
4
|
+
quotestatus: string;
|
|
5
|
+
total: number;
|
|
6
|
+
expired?: boolean;
|
|
7
|
+
converted?: boolean;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export declare function useQuotations(): {
|
|
11
|
+
quotations: import("vue").Ref<{
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
quotation_no: string;
|
|
14
|
+
createddate: string;
|
|
15
|
+
quotestatus: string;
|
|
16
|
+
total: number;
|
|
17
|
+
expired?: boolean | undefined;
|
|
18
|
+
converted?: boolean | undefined;
|
|
19
|
+
}[], Quotation[] | {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
quotation_no: string;
|
|
22
|
+
createddate: string;
|
|
23
|
+
quotestatus: string;
|
|
24
|
+
total: number;
|
|
25
|
+
expired?: boolean | undefined;
|
|
26
|
+
converted?: boolean | undefined;
|
|
27
|
+
}[]>;
|
|
28
|
+
pending: import("vue").Ref<boolean, boolean>;
|
|
29
|
+
loadQuotations: () => Promise<void>;
|
|
30
|
+
hasQuotations: () => boolean;
|
|
31
|
+
getQuotationStatus: (quotation: Quotation) => string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useAuthStore } from "../../stores/auth.js";
|
|
3
|
+
export function useQuotations() {
|
|
4
|
+
const authStore = useAuthStore();
|
|
5
|
+
const quotations = ref([]);
|
|
6
|
+
const pending = ref(true);
|
|
7
|
+
const loadQuotations = async () => {
|
|
8
|
+
pending.value = true;
|
|
9
|
+
try {
|
|
10
|
+
const quotationsData = await authStore.fetchQuotations();
|
|
11
|
+
quotations.value = Array.isArray(quotationsData) ? quotationsData : [];
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error("Failed to load quotations:", error);
|
|
14
|
+
quotations.value = [];
|
|
15
|
+
} finally {
|
|
16
|
+
pending.value = false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const hasQuotations = () => {
|
|
20
|
+
return quotations.value && quotations.value.length > 0;
|
|
21
|
+
};
|
|
22
|
+
const getQuotationStatus = (quotation) => {
|
|
23
|
+
if (quotation.expired) {
|
|
24
|
+
return "Expired";
|
|
25
|
+
} else if (quotation.converted) {
|
|
26
|
+
return "Purchased";
|
|
27
|
+
} else {
|
|
28
|
+
return "Available";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
// State
|
|
33
|
+
quotations,
|
|
34
|
+
pending,
|
|
35
|
+
// Methods
|
|
36
|
+
loadQuotations,
|
|
37
|
+
hasQuotations,
|
|
38
|
+
getQuotationStatus
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,18 +1,125 @@
|
|
|
1
|
-
export default function (): {
|
|
1
|
+
export default function (countries: any): {
|
|
2
2
|
router: any;
|
|
3
3
|
route: any;
|
|
4
|
-
form_error: import("vue").Ref<string, string>;
|
|
5
4
|
inputData: import("vue").Ref<{
|
|
6
|
-
|
|
5
|
+
abn: string;
|
|
6
|
+
addresses: never[];
|
|
7
|
+
address: string;
|
|
8
|
+
postCode: string;
|
|
9
|
+
suburb: string;
|
|
10
|
+
billing_address: string;
|
|
11
|
+
businessAddress: string;
|
|
12
|
+
billing_country: string;
|
|
13
|
+
billing_firstname: string;
|
|
14
|
+
billing_lastname: string;
|
|
15
|
+
billing_mobile: string;
|
|
16
|
+
billing_postcode: string;
|
|
17
|
+
billing_state: string;
|
|
18
|
+
billing_suburb: string;
|
|
19
|
+
company_name: string;
|
|
20
|
+
email: string;
|
|
21
|
+
email_confirmation: string;
|
|
22
|
+
firstname: string;
|
|
23
|
+
lastname: string;
|
|
24
|
+
mobile: string;
|
|
25
|
+
newsletterSignup: boolean;
|
|
26
|
+
password: string;
|
|
27
|
+
password_confirmation: string;
|
|
28
|
+
recaptcha: string;
|
|
29
|
+
shipping_address: string;
|
|
30
|
+
shipping_country: string;
|
|
31
|
+
shipping_postcode: string;
|
|
32
|
+
shipping_state: string;
|
|
33
|
+
shipping_suburb: string;
|
|
34
|
+
shipping_town: string;
|
|
35
|
+
shipping_mobile: string;
|
|
36
|
+
subscribe: boolean;
|
|
7
37
|
}, {
|
|
8
|
-
|
|
38
|
+
abn: string;
|
|
39
|
+
addresses: never[];
|
|
40
|
+
address: string;
|
|
41
|
+
postCode: string;
|
|
42
|
+
suburb: string;
|
|
43
|
+
billing_address: string;
|
|
44
|
+
businessAddress: string;
|
|
45
|
+
billing_country: string;
|
|
46
|
+
billing_firstname: string;
|
|
47
|
+
billing_lastname: string;
|
|
48
|
+
billing_mobile: string;
|
|
49
|
+
billing_postcode: string;
|
|
50
|
+
billing_state: string;
|
|
51
|
+
billing_suburb: string;
|
|
52
|
+
company_name: string;
|
|
53
|
+
email: string;
|
|
54
|
+
email_confirmation: string;
|
|
55
|
+
firstname: string;
|
|
56
|
+
lastname: string;
|
|
57
|
+
mobile: string;
|
|
58
|
+
newsletterSignup: boolean;
|
|
59
|
+
password: string;
|
|
60
|
+
password_confirmation: string;
|
|
61
|
+
recaptcha: string;
|
|
62
|
+
shipping_address: string;
|
|
63
|
+
shipping_country: string;
|
|
64
|
+
shipping_postcode: string;
|
|
65
|
+
shipping_state: string;
|
|
66
|
+
shipping_suburb: string;
|
|
67
|
+
shipping_town: string;
|
|
68
|
+
shipping_mobile: string;
|
|
69
|
+
subscribe: boolean;
|
|
9
70
|
} | {
|
|
10
|
-
|
|
71
|
+
abn: string;
|
|
72
|
+
addresses: never[];
|
|
73
|
+
address: string;
|
|
74
|
+
postCode: string;
|
|
75
|
+
suburb: string;
|
|
76
|
+
billing_address: string;
|
|
77
|
+
businessAddress: string;
|
|
78
|
+
billing_country: string;
|
|
79
|
+
billing_firstname: string;
|
|
80
|
+
billing_lastname: string;
|
|
81
|
+
billing_mobile: string;
|
|
82
|
+
billing_postcode: string;
|
|
83
|
+
billing_state: string;
|
|
84
|
+
billing_suburb: string;
|
|
85
|
+
company_name: string;
|
|
86
|
+
email: string;
|
|
87
|
+
email_confirmation: string;
|
|
88
|
+
firstname: string;
|
|
89
|
+
lastname: string;
|
|
90
|
+
mobile: string;
|
|
91
|
+
newsletterSignup: boolean;
|
|
92
|
+
password: string;
|
|
93
|
+
password_confirmation: string;
|
|
94
|
+
recaptcha: string;
|
|
95
|
+
shipping_address: string;
|
|
96
|
+
shipping_country: string;
|
|
97
|
+
shipping_postcode: string;
|
|
98
|
+
shipping_state: string;
|
|
99
|
+
shipping_suburb: string;
|
|
100
|
+
shipping_town: string;
|
|
101
|
+
shipping_mobile: string;
|
|
102
|
+
subscribe: boolean;
|
|
11
103
|
}>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
104
|
+
CustomerRegister: (registerFields: any) => Promise<void>;
|
|
105
|
+
regResponse: import("vue").Ref<null, null>;
|
|
106
|
+
isBusinessAccount: import("vue").Ref<boolean, boolean>;
|
|
107
|
+
companyName: import("vue").Ref<string, string>;
|
|
108
|
+
abn: import("vue").Ref<string, string>;
|
|
109
|
+
address: import("vue").Ref<string, string>;
|
|
110
|
+
sameAsCustomerDetails: import("vue").Ref<boolean, boolean>;
|
|
111
|
+
showPassword: import("vue").Ref<boolean, boolean>;
|
|
112
|
+
showConfirmPassword: import("vue").Ref<boolean, boolean>;
|
|
113
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
114
|
+
getStates: (countryId: any) => any;
|
|
115
|
+
validateForm: () => true | "First Name is required" | "Last Name is required" | "Address is required" | "Country is required" | "State is required" | "Post Code is required" | "Suburb is required" | "Please enter a valid email address" | "Email addresses do not match" | "Password must be at least 6 characters" | "Passwords do not match" | "Mobile Number is required" | "Company Name is required" | "ABN is required" | "Business Address is required" | "Shipping Address is required" | "Shipping country is required." | "Shipping Town is required" | "Shipping State is required" | "Shipping Post Code is required" | "Shipping Mobile is required";
|
|
116
|
+
togglePassword: () => void;
|
|
117
|
+
toggleConfirmPassword: () => void;
|
|
118
|
+
handleSameAsCustomerDetails: () => void;
|
|
119
|
+
alertMessage: import("vue").Ref<string, string>;
|
|
120
|
+
alertType: import("vue").Ref<"success" | "danger", "success" | "danger">;
|
|
121
|
+
showAlert: import("vue").Ref<boolean, boolean>;
|
|
122
|
+
displayAlert: (message: string, type: "success" | "danger") => void;
|
|
123
|
+
dismissAlert: () => void;
|
|
124
|
+
handleSignup: () => Promise<void>;
|
|
18
125
|
};
|