diff --git a/components/section/InvestmentZone.vue b/components/section/InvestmentZone.vue
index afb53b6..78fe65a 100644
--- a/components/section/InvestmentZone.vue
+++ b/components/section/InvestmentZone.vue
@@ -28,7 +28,7 @@
]">
-
diff --git a/components/section/MainProducts.vue b/components/section/MainProducts.vue
index 35d4d2c..409fa30 100644
--- a/components/section/MainProducts.vue
+++ b/components/section/MainProducts.vue
@@ -7,7 +7,7 @@
-
diff --git a/components/section/Product.vue b/components/section/Product.vue
index 7b2f3b1..848eda6 100644
--- a/components/section/Product.vue
+++ b/components/section/Product.vue
@@ -1,7 +1,7 @@
-
![Product Image]()
diff --git a/components/section/RegistrationMain.vue b/components/section/RegistrationMain.vue
index 76823dc..90c2d54 100644
--- a/components/section/RegistrationMain.vue
+++ b/components/section/RegistrationMain.vue
@@ -61,7 +61,7 @@
{{ menuStore.selectedPhoneCountry.call_prefix
- }}
+ }}
@@ -112,14 +112,15 @@
- {{ $t('login') }}
+ {{ $t('sign_up') }}
{{
$t('is_account')
- }}
-
{{
- $t('login')
+ }}
+
item.id === 11))"
+ class="text-button cursor-pointer hover:text-button-hover">{{
+ $t('login')
}}
diff --git a/stores/checkoutStore.ts b/stores/checkoutStore.ts
index 1ae5593..003e4a1 100644
--- a/stores/checkoutStore.ts
+++ b/stores/checkoutStore.ts
@@ -1,12 +1,14 @@
-import type { GenericResponse } from "~/types";
+import type { GenericResponse, GenericResponseItems, UserCart } from "~/types";
import type { AddressesList, UserAddressOfficial } from "~/types/checkout";
import { validation } from "../utils/validation";
import { REGEX_PHONE } from "../utils/regex";
+import type { CartProduct } from "~/types/product";
export const useCheckoutStore = defineStore("checkoutStore", () => {
const { $toast } = useNuxtApp();
const menuStore = useMenuStore();
const selectedIso = ref(menuStore.selectedCountry);
+ const showSummary = ref(false);
// get address list
const addressesList = ref
();
@@ -185,6 +187,7 @@ export const useCheckoutStore = defineStore("checkoutStore", () => {
dangerouslyHTMLString: true,
});
// redirectToSummary();
+ showSummary.value = true;
} else {
$toast.error("Failed to send form. Please try again.", {
autoClose: 5000,
@@ -222,6 +225,108 @@ export const useCheckoutStore = defineStore("checkoutStore", () => {
}
}
+ // get user cart
+ const products = ref();
+ const fullPrice = ref();
+ const fullProductsPrice = ref();
+ async function getUserCart() {
+ try {
+ const { data } = await useMyFetch>(
+ `/api/public/user/cart`,
+ {
+ headers: {
+ "Content-Type": "application/json",
+ },
+ onErrorOccured: async (_, status) => {
+ throw createError({
+ statusCode: status,
+ statusMessage: `HTTP error: ${status}`,
+ });
+ },
+ }
+ );
+
+ products.value = data.cart_items;
+ fullPrice.value = data.total_value;
+ fullProductsPrice.value = data.total_value;
+ fullPrice.value = Number(fullPrice.value) + Number(shippingPrice.value);
+ } catch (error) {
+ console.error("getUserCart error:", error);
+ }
+ }
+
+ // get delivery options
+ const deliveryOption = ref();
+ const currentDelivery = ref();
+ const shippingPrice = ref();
+ async function getDeliveryOptions() {
+ try {
+ const { data } = await useMyFetch<
+ GenericResponseItems<{
+ items: [
+ {
+ country_iso: string;
+ country_name: string;
+ delivery_supplier_id: number;
+ delivery_supplier_name: string;
+ id: number;
+ shippment_price: string;
+ }
+ ];
+ }>
+ >(`/api/restricted/cart/checkout/delivery-options`, {
+ headers: {
+ "Content-Type": "application/json",
+ },
+ onErrorOccured: async (_, status) => {
+ throw createError({
+ statusCode: status,
+ statusMessage: `HTTP error: ${status}`,
+ });
+ },
+ });
+
+ console.log(data);
+ deliveryOption.value = data.items;
+ currentDelivery.value = data.items[0];
+ shippingPrice.value = data.items[0].shippment_price;
+ fullPrice.value = Number(fullPrice.value) + Number(shippingPrice.value);
+ } catch (error) {
+ console.error("getUserCart error:", error);
+ }
+ }
+
+ const defaultAddress = ref();
+ async function getDefAddress() {
+ try {
+ const { data } = await useMyFetch<
+ GenericResponse<{
+ addresses: [
+ {
+ is_default: string;
+ }
+ ];
+ }>
+ >(`/api/public/user`, {
+ headers: {
+ "Content-Type": "application/json",
+ },
+ onErrorOccured: async (_, status) => {
+ throw createError({
+ statusCode: status,
+ statusMessage: `HTTP error: ${status}`,
+ });
+ },
+ });
+
+ defaultAddress.value = data.addresses.find(
+ (el: any) => el.is_default === true
+ );
+ } catch (error) {
+ console.error("getUserCart error:", error);
+ }
+ }
+
return {
addressesList,
activeAddress,
@@ -246,6 +351,15 @@ export const useCheckoutStore = defineStore("checkoutStore", () => {
vNewAddressCode,
vNewAddressCity,
vNewAddressCountry,
+ showSummary,
+
+ products,
+ fullPrice,
+ fullProductsPrice,
+ deliveryOption,
+ currentDelivery,
+ shippingPrice,
+ defaultAddress,
changePrefix,
getCheckout,
@@ -254,5 +368,8 @@ export const useCheckoutStore = defineStore("checkoutStore", () => {
changeActive,
uploadAddress,
sendForm,
+ getUserCart,
+ getDeliveryOptions,
+ getDefAddress,
};
});
diff --git a/types/product.ts b/types/product.ts
index 2c362be..a0d9347 100644
--- a/types/product.ts
+++ b/types/product.ts
@@ -11,3 +11,22 @@ export interface Product {
applied_tax_rate: number;
tax_name: string;
}
+
+export interface CartProduct {
+ cart_item_id: number;
+ link_rewrite: string;
+ name: string;
+ picture_uuid: string;
+ product_id: number;
+ quantity: number;
+ single_item_price: number;
+ total_price: number;
+}
+
+export interface UserCart {
+ cart_items: CartProduct[];
+ checkout_in_progress: boolean;
+ currency_iso: string;
+ id: number;
+ total_value: number;
+}