flowrix 1.0.1-beta.155 → 1.0.1-beta.157
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/module.mjs +23 -192
- package/dist/runtime/components/Types/page/index.d.vue.ts +5 -4
- package/dist/runtime/components/Types/page/index.vue +7 -11
- package/dist/runtime/components/Types/page/index.vue.d.ts +5 -4
- package/dist/runtime/composables/Blog/useBlogSingle.js +4 -5
- package/dist/runtime/composables/Category/useCategoryIndex.js +5 -5
- package/dist/runtime/composables/Checkout/useCheckout.d.ts +4 -0
- package/dist/runtime/composables/Checkout/useCheckout.js +15 -3
- package/dist/runtime/composables/Customer/useBillingAddress.d.ts +3 -0
- package/dist/runtime/composables/Customer/useBillingAddress.js +2 -0
- package/dist/runtime/composables/Customer/useShippingAddress.d.ts +3 -0
- package/dist/runtime/composables/Customer/useShippingAddress.js +2 -1
- package/dist/runtime/composables/Customer/useWishlists.d.ts +1 -1
- package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.d.ts +4 -0
- package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.js +5 -11
- package/dist/runtime/composables/Product/useProductCard.d.ts +90 -9
- package/dist/runtime/composables/Product/useProductCard.js +257 -55
- package/dist/runtime/composables/Product/useProductComponent.js +3 -10
- package/dist/runtime/composables/Product/useQuickView.d.ts +1 -1
- package/dist/runtime/composables/Product/useService.d.ts +1 -12
- package/dist/runtime/composables/Product/useService.js +2 -2
- package/dist/runtime/composables/index.d.ts +1 -1
- package/dist/runtime/composables/index.js +1 -1
- package/dist/runtime/composables/useAddresses.js +27 -6
- package/dist/runtime/composables/useApp.js +3 -4
- package/dist/runtime/composables/useCards.js +0 -1
- package/dist/runtime/composables/useClientApi.d.ts +8 -8
- package/dist/runtime/composables/useClientApi.js +74 -30
- package/dist/runtime/composables/useLocation.d.ts +3 -15
- package/dist/runtime/composables/useLocation.js +6 -27
- package/dist/runtime/composables/usePriceCalculation.d.ts +33 -0
- package/dist/runtime/composables/usePriceCalculation.js +107 -0
- package/dist/runtime/composables/useQuotationCheckout.d.ts +1 -1
- package/dist/runtime/middleware/flowrix.d.ts +5 -5
- package/dist/runtime/middleware/flowrix.js +2 -2
- package/dist/runtime/middleware/flowrixs3.d.ts +3 -0
- package/dist/runtime/middleware/flowrixs3.js +65 -0
- package/dist/runtime/pages/flowrix-default.vue +62 -15
- package/dist/runtime/plugins/full-reload.client.d.ts +2 -0
- package/dist/runtime/plugins/full-reload.client.js +28 -0
- package/dist/runtime/server/api/albums.d.ts +0 -1
- package/dist/runtime/server/api/albums.js +13 -40
- package/dist/runtime/server/api/auth/login.d.ts +0 -18
- package/dist/runtime/server/api/auth/login.js +0 -57
- package/dist/runtime/server/api/banners.d.ts +0 -1
- package/dist/runtime/server/api/banners.js +13 -40
- package/dist/runtime/server/api/brand/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/brand/[...slug].js +14 -43
- package/dist/runtime/server/api/brand/index.d.ts +0 -1
- package/dist/runtime/server/api/brand/index.js +13 -39
- package/dist/runtime/server/api/cache/[...slug].delete.js +1 -2
- package/dist/runtime/server/api/cache/clean.get.js +1 -2
- package/dist/runtime/server/api/cart/[slug]/add.d.ts +0 -2
- package/dist/runtime/server/api/cart/[slug]/add.js +0 -21
- package/dist/runtime/server/api/cart/[slug]/update.d.ts +0 -2
- package/dist/runtime/server/api/cart/[slug]/update.js +0 -21
- package/dist/runtime/server/api/cart/related.d.ts +0 -2
- package/dist/runtime/server/api/cart/related.js +0 -34
- package/dist/runtime/server/api/cart/remove.d.ts +0 -2
- package/dist/runtime/server/api/cart/remove.js +0 -21
- package/dist/runtime/server/api/catalog/brands.d.ts +0 -1
- package/dist/runtime/server/api/catalog/brands.js +13 -45
- package/dist/runtime/server/api/catalog/categories.d.ts +0 -1
- package/dist/runtime/server/api/catalog/categories.js +13 -45
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +0 -1
- package/dist/runtime/server/api/catalog/categoriesall.js +13 -45
- package/dist/runtime/server/api/catalog/featured.d.ts +0 -1
- package/dist/runtime/server/api/catalog/featured.js +13 -45
- package/dist/runtime/server/api/catalog/posts.d.ts +0 -1
- package/dist/runtime/server/api/catalog/posts.js +13 -45
- package/dist/runtime/server/api/catalog/samples.d.ts +0 -1
- package/dist/runtime/server/api/catalog/samples.js +13 -46
- package/dist/runtime/server/api/catalog/search.d.ts +0 -1
- package/dist/runtime/server/api/catalog/search.js +13 -46
- package/dist/runtime/server/api/category/[...slug].d.ts +1 -2
- package/dist/runtime/server/api/category/[...slug].js +34 -49
- package/dist/runtime/server/api/checkout/applyCoupon.d.ts +0 -2
- package/dist/runtime/server/api/checkout/applyCoupon.js +0 -20
- package/dist/runtime/server/api/checkout/configs.d.ts +0 -2
- package/dist/runtime/server/api/checkout/configs.js +0 -20
- package/dist/runtime/server/api/checkout/countries.d.ts +0 -2
- package/dist/runtime/server/api/checkout/countries.js +0 -13
- package/dist/runtime/server/api/checkout/paymentmethod.d.ts +0 -2
- package/dist/runtime/server/api/checkout/paymentmethod.js +0 -25
- package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +0 -20
- package/dist/runtime/server/api/checkvariables.js +1 -2
- package/dist/runtime/server/api/cmspost/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/cmspost/[...slug].js +14 -44
- package/dist/runtime/server/api/cmspost/all.js +1 -2
- package/dist/runtime/server/api/company/profile.d.ts +1 -1
- package/dist/runtime/server/api/company/profile.js +13 -17
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +0 -3
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +0 -54
- package/dist/runtime/server/api/countries.js +13 -38
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +0 -45
- package/dist/runtime/server/api/featured.d.ts +0 -3
- package/dist/runtime/server/api/featured.js +0 -52
- package/dist/runtime/server/api/generate/robots.get.js +0 -2
- package/dist/runtime/server/api/generate/sitemap.get.d.ts +1 -1
- package/dist/runtime/server/api/generate/sitemap.get.js +8 -12
- package/dist/runtime/server/api/global/[...slug].js +20 -0
- package/dist/runtime/server/api/location.d.ts +0 -2
- package/dist/runtime/server/api/location.js +0 -25
- package/dist/runtime/server/api/nav/[id]/links.d.ts +0 -1
- package/dist/runtime/server/api/nav/[id]/links.js +13 -43
- package/dist/runtime/server/api/page/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/page/[...slug].js +14 -44
- package/dist/runtime/server/api/permalink/[...slug].get.js +31 -0
- package/dist/runtime/server/api/product/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/product/[...slug].js +14 -49
- package/dist/runtime/server/api/quickview/[slug].d.ts +1 -1
- package/dist/runtime/server/api/quickview/[slug].js +15 -16
- package/dist/runtime/server/api/reviews.d.ts +1 -1
- package/dist/runtime/server/api/reviews.js +1 -2
- package/dist/runtime/server/api/reviews3.js +19 -0
- package/dist/runtime/server/api/samples.d.ts +0 -1
- package/dist/runtime/server/api/samples.js +13 -46
- package/dist/runtime/server/api/search.d.ts +0 -1
- package/dist/runtime/server/api/search.js +13 -46
- package/dist/runtime/server/api/service/[slug].d.ts +0 -1
- package/dist/runtime/server/api/service/[slug].js +13 -44
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/getall.d.ts +0 -1
- package/dist/runtime/server/api/service/getall.js +13 -51
- package/dist/runtime/server/api/shop.d.ts +0 -1
- package/dist/runtime/server/api/shop.js +13 -46
- package/dist/runtime/server/api/subscribe.d.ts +0 -2
- package/dist/runtime/server/api/subscribe.js +0 -25
- package/dist/runtime/server/api/webform.d.ts +0 -3
- package/dist/runtime/server/api/webform.js +0 -54
- package/dist/runtime/server/middleware/powertools.d.ts +9 -0
- package/dist/runtime/server/middleware/powertools.js +30 -0
- package/dist/runtime/stores/Booking.js +23 -7
- package/dist/runtime/stores/Cart.js +18 -3
- package/dist/runtime/stores/Checkout.js +14 -3
- package/dist/runtime/stores/NavMenu.js +2 -4
- package/dist/runtime/stores/Search.js +9 -3
- package/dist/runtime/stores/auth.d.ts +28 -1
- package/dist/runtime/stores/auth.js +0 -5
- package/dist/runtime/stores/countries.js +1 -1
- package/dist/runtime/stores/index.d.ts +0 -1
- package/dist/runtime/stores/index.js +0 -1
- package/dist/runtime/stores/locations.d.ts +1 -5
- package/dist/runtime/stores/locations.js +8 -5
- package/dist/runtime/stores/product.js +9 -3
- package/dist/runtime/stores/promotions.d.ts +51 -0
- package/dist/runtime/stores/promotions.js +65 -0
- package/dist/runtime/stores/useCompanyProfile.js +5 -2
- package/dist/runtime/stores/wishlists.d.ts +1 -1
- package/dist/runtime/stores/wishlists.js +1 -1
- package/package.json +11 -3
- package/dist/runtime/composables/useLocations.d.ts +0 -12
- package/dist/runtime/composables/useLocations.js +0 -53
- package/dist/runtime/server/api/auth/forgot.d.ts +0 -5
- package/dist/runtime/server/api/auth/forgot.js +0 -43
- package/dist/runtime/server/api/auth/logout.d.ts +0 -5
- package/dist/runtime/server/api/auth/logout.js +0 -22
- package/dist/runtime/server/api/auth/register.js +0 -50
- package/dist/runtime/server/api/auth/session.get.js +0 -44
- package/dist/runtime/server/api/auth/user/reset-password.d.ts +0 -5
- package/dist/runtime/server/api/auth/user/reset-password.js +0 -39
- package/dist/runtime/server/api/auth/user/session.js +0 -42
- package/dist/runtime/server/api/auth/user/verify-token.d.ts +0 -6
- package/dist/runtime/server/api/auth/user/verify-token.js +0 -49
- package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +0 -2
- package/dist/runtime/server/api/cart/service/[slug]/add.js +0 -16
- package/dist/runtime/server/api/check-404.d.ts +0 -4
- package/dist/runtime/server/api/check-404.js +0 -8
- package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/[slug].js +0 -20
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +0 -35
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +0 -22
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +0 -2
- package/dist/runtime/server/api/contact-center/webforms/create.js +0 -20
- package/dist/runtime/server/api/customer/address/add.d.ts +0 -14
- package/dist/runtime/server/api/customer/address/add.js +0 -32
- package/dist/runtime/server/api/customer/address/delete.d.ts +0 -20
- package/dist/runtime/server/api/customer/address/delete.js +0 -36
- package/dist/runtime/server/api/customer/address/setshipping.d.ts +0 -20
- package/dist/runtime/server/api/customer/address/setshipping.js +0 -40
- package/dist/runtime/server/api/customer/address/update.d.ts +0 -20
- package/dist/runtime/server/api/customer/address/update.js +0 -41
- package/dist/runtime/server/api/customer/cards/delete.d.ts +0 -2
- package/dist/runtime/server/api/customer/cards/delete.js +0 -22
- package/dist/runtime/server/api/customer/cards/get.d.ts +0 -2
- package/dist/runtime/server/api/customer/cards/get.js +0 -16
- package/dist/runtime/server/api/customer/change-password.d.ts +0 -14
- package/dist/runtime/server/api/customer/change-password.js +0 -33
- package/dist/runtime/server/api/customer/checkout.d.ts +0 -2
- package/dist/runtime/server/api/customer/checkout.js +0 -19
- package/dist/runtime/server/api/customer/orders.d.ts +0 -2
- package/dist/runtime/server/api/customer/orders.js +0 -16
- package/dist/runtime/server/api/customer/profile/update.d.ts +0 -14
- package/dist/runtime/server/api/customer/profile/update.js +0 -33
- package/dist/runtime/server/api/customer/quotations.d.ts +0 -2
- package/dist/runtime/server/api/customer/quotations.js +0 -16
- package/dist/runtime/server/api/customer/search.d.ts +0 -2
- package/dist/runtime/server/api/customer/search.js +0 -14
- package/dist/runtime/server/api/customer/tax-invoice.d.ts +0 -8
- package/dist/runtime/server/api/customer/tax-invoice.js +0 -35
- package/dist/runtime/server/api/customer/wishlist/add.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/add.js +0 -29
- package/dist/runtime/server/api/customer/wishlist/createWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +0 -28
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +0 -29
- package/dist/runtime/server/api/customer/wishlist/get.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/get.js +0 -16
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +0 -20
- package/dist/runtime/server/api/customer/wishlist/updateWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +0 -29
- package/dist/runtime/server/api/v2/[...slug].get.d.ts +0 -2
- package/dist/runtime/server/api/v2/[...slug].get.js +0 -34
- package/dist/runtime/stores/IpLocation.d.ts +0 -109
- package/dist/runtime/stores/IpLocation.js +0 -107
- package/dist/runtime/utils/api.d.ts +0 -13
- package/dist/runtime/utils/api.js +0 -96
- /package/dist/runtime/server/api/{auth/register.d.ts → global/[...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/{auth/session.get.d.ts → permalink/[...slug].get.d.ts} +0 -0
- /package/dist/runtime/server/api/{auth/user/session.d.ts → reviews3.d.ts} +0 -0
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import { useLocationsStore } from "../stores/locations.js";
|
|
3
|
-
import { useApi } from "../utils/api.js";
|
|
4
|
-
function formatErrorMessage(message) {
|
|
5
|
-
if (!message) return "An error occurred";
|
|
6
|
-
if (typeof message === "string") {
|
|
7
|
-
return message;
|
|
8
|
-
}
|
|
9
|
-
const errorMessages = [];
|
|
10
|
-
for (const [field, errors] of Object.entries(message)) {
|
|
11
|
-
if (Array.isArray(errors)) {
|
|
12
|
-
errorMessages.push(...errors);
|
|
13
|
-
} else {
|
|
14
|
-
errorMessages.push(String(errors));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return errorMessages.join(", ");
|
|
18
|
-
}
|
|
19
|
-
export function useLocations() {
|
|
20
|
-
const store = useLocationsStore();
|
|
21
|
-
const { post } = useApi();
|
|
22
|
-
async function fetchLocation() {
|
|
23
|
-
if (store.location) {
|
|
24
|
-
return { status: "Success", message: null, data: store.location };
|
|
25
|
-
}
|
|
26
|
-
store.setLoading(true);
|
|
27
|
-
store.setError(null);
|
|
28
|
-
try {
|
|
29
|
-
const response = await post("/location", {});
|
|
30
|
-
if (response.status === "Success" && response.data) {
|
|
31
|
-
store.setLocation(response.data);
|
|
32
|
-
return response;
|
|
33
|
-
} else {
|
|
34
|
-
const errorMessage = formatErrorMessage(response.message);
|
|
35
|
-
store.setError(errorMessage);
|
|
36
|
-
throw new Error(errorMessage);
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error("Fetch location error:", error);
|
|
40
|
-
const errorMessage = error.data ? formatErrorMessage(error.data.message) : error.message || "Failed to fetch location";
|
|
41
|
-
store.setError(errorMessage);
|
|
42
|
-
throw new Error(errorMessage);
|
|
43
|
-
} finally {
|
|
44
|
-
store.setLoading(false);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
fetchLocation,
|
|
49
|
-
location: computed(() => store.location),
|
|
50
|
-
loading: computed(() => store.loading),
|
|
51
|
-
error: computed(() => store.error)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody, createError } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const body = await readBody(event);
|
|
4
|
-
const { email } = body;
|
|
5
|
-
try {
|
|
6
|
-
const response = await fetch(`${process.env.FLOWRIX_API_BASE}verify-email/`, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
headers: {
|
|
9
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
11
|
-
"Content-Type": "application/json"
|
|
12
|
-
},
|
|
13
|
-
body: JSON.stringify({ email })
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
let errorMessage = ``;
|
|
17
|
-
try {
|
|
18
|
-
const errorData = await response.json();
|
|
19
|
-
console.error("Error response data:", errorData.message);
|
|
20
|
-
if (errorData.message) {
|
|
21
|
-
errorMessage += errorData.message?.email || errorData.message;
|
|
22
|
-
}
|
|
23
|
-
} catch (parseError) {
|
|
24
|
-
errorMessage += "Failed to parse error details.";
|
|
25
|
-
}
|
|
26
|
-
throw createError({
|
|
27
|
-
status: 400,
|
|
28
|
-
statusMessage: "Bad Request",
|
|
29
|
-
message: "Invalid user input",
|
|
30
|
-
data: { field: "email" }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const data = await response.json();
|
|
34
|
-
return data;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw createError({
|
|
37
|
-
status: 400,
|
|
38
|
-
statusMessage: "Bad Request",
|
|
39
|
-
message: "Invalid user input",
|
|
40
|
-
data: { field: "email" }
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getCookie, deleteCookie } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const accessTok = getCookie(event, "auth.token");
|
|
4
|
-
try {
|
|
5
|
-
await $fetch(`${process.env.FLOWRIX_API_BASE}customer/logout`, {
|
|
6
|
-
method: "POST",
|
|
7
|
-
headers: {
|
|
8
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
9
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
|
-
"Authorization": `Bearer ${accessTok || ""}`
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
deleteCookie(event, "auth.token");
|
|
14
|
-
deleteCookie(event, "auth.refreshToken");
|
|
15
|
-
deleteCookie(event, "auth.user");
|
|
16
|
-
deleteCookie(event, "auth.session");
|
|
17
|
-
return { success: true, message: "Logout successful" };
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error("Error customer logout:", error);
|
|
20
|
-
return { success: false, message: "Logout failed" };
|
|
21
|
-
}
|
|
22
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const body = await readBody(event);
|
|
4
|
-
const { firstname, lastname, mobile, email, email_confirmation, password, password_confirmation } = body;
|
|
5
|
-
try {
|
|
6
|
-
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/create`, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
headers: {
|
|
9
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
11
|
-
"Content-Type": "application/json"
|
|
12
|
-
},
|
|
13
|
-
body: JSON.stringify({ firstname, lastname, mobile, email, email_confirmation, password, password_confirmation })
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
let errorMessage = {};
|
|
17
|
-
let errorData;
|
|
18
|
-
try {
|
|
19
|
-
errorData = await response.json();
|
|
20
|
-
console.error("Error response data:", errorData);
|
|
21
|
-
if (errorData.message) {
|
|
22
|
-
errorMessage = errorData.message?.email || errorData.message;
|
|
23
|
-
}
|
|
24
|
-
} catch (parseError) {
|
|
25
|
-
errorMessage = "Failed to parse error details.";
|
|
26
|
-
console.error("Error parsing JSON:", parseError);
|
|
27
|
-
errorData = { message: errorMessage };
|
|
28
|
-
}
|
|
29
|
-
throw createError({
|
|
30
|
-
status: response.status,
|
|
31
|
-
message: errorMessage,
|
|
32
|
-
// Use the more specific errorMessage
|
|
33
|
-
data: { message: errorMessage, errorData }
|
|
34
|
-
// Include both messages and the raw error
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
const data = await response.json();
|
|
38
|
-
return data.data;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
const statusCode = error.status || 500;
|
|
41
|
-
const message = error.message || "An unexpected error occurred";
|
|
42
|
-
const errorData = error.data || { message };
|
|
43
|
-
console.error("Final Error:", { statusCode, message, errorData });
|
|
44
|
-
throw createError({
|
|
45
|
-
status: statusCode,
|
|
46
|
-
message,
|
|
47
|
-
data: errorData
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getCookie, createError } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
try {
|
|
4
|
-
const authHeader = getHeader(event, "authorization");
|
|
5
|
-
const token = authHeader?.replace("Bearer ", "") || getCookie(event, "nuxt-auth.token");
|
|
6
|
-
if (!token) {
|
|
7
|
-
throw createError({
|
|
8
|
-
statusCode: 401,
|
|
9
|
-
statusMessage: "No token provided"
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
const config = useRuntimeConfig();
|
|
13
|
-
const apiBase = config.apiBase;
|
|
14
|
-
const apiKey = config.apiKey;
|
|
15
|
-
const apiOrigin = config.apiOrigin;
|
|
16
|
-
const response = await fetch(`${apiBase}user/session`, {
|
|
17
|
-
method: "GET",
|
|
18
|
-
headers: {
|
|
19
|
-
"x-public-key": apiKey,
|
|
20
|
-
"Origin": apiOrigin || "",
|
|
21
|
-
"Authorization": `Bearer ${token}`,
|
|
22
|
-
"Content-Type": "application/json",
|
|
23
|
-
"Accept": "application/json"
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
throw createError({
|
|
28
|
-
statusCode: response.status,
|
|
29
|
-
statusMessage: "Failed to get session"
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const data = await response.json();
|
|
33
|
-
return data.data || data.user || data;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error("Session error:", error);
|
|
36
|
-
if (error.statusCode || error.status) {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
throw createError({
|
|
40
|
-
statusCode: 401,
|
|
41
|
-
statusMessage: "Invalid session"
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody, getCookie, sendError } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const body = await readBody(event);
|
|
4
|
-
const { password, password_confirmation, token } = body;
|
|
5
|
-
try {
|
|
6
|
-
const auth_token = getCookie(event, "token");
|
|
7
|
-
const response = await fetch(`${process.env.FLOWRIX_API_BASE}reset-password/`, {
|
|
8
|
-
method: "POST",
|
|
9
|
-
headers: {
|
|
10
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
11
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
12
|
-
"Content-Type": "application/json",
|
|
13
|
-
// <--- CHANGE THIS
|
|
14
|
-
Authorization: `Bearer ${auth_token}`
|
|
15
|
-
// Use the token from the cookie
|
|
16
|
-
},
|
|
17
|
-
body: JSON.stringify({ "token": auth_token, password, password_confirmation })
|
|
18
|
-
});
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
let errorMessage = ``;
|
|
21
|
-
const errorData = await response.json();
|
|
22
|
-
errorMessage += errorData.message?.password || errorData.message.token;
|
|
23
|
-
throw sendError(event, {
|
|
24
|
-
statusCode: 400,
|
|
25
|
-
statusMessage: errorMessage,
|
|
26
|
-
data: errorMessage
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const data = await response.json();
|
|
30
|
-
return data;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return sendError(event, {
|
|
33
|
-
statusCode: 500,
|
|
34
|
-
statusMessage: `Login failed: ${error.message || "An unexpected error occurred"}`,
|
|
35
|
-
data: { message: error.message || "An unexpected error occurred" }
|
|
36
|
-
// Include in data as well
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getHeader, createError } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const authHeader = getHeader(event, "authorization");
|
|
4
|
-
try {
|
|
5
|
-
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/profile`, {
|
|
6
|
-
method: "GET",
|
|
7
|
-
headers: {
|
|
8
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
9
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
|
-
Authorization: authHeader
|
|
11
|
-
// Use the authorization header if available
|
|
12
|
-
}
|
|
13
|
-
// body: JSON.stringify({ email, password }),
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
let errorMessage = ``;
|
|
17
|
-
try {
|
|
18
|
-
const errorData = await response.json();
|
|
19
|
-
if (errorData.message) {
|
|
20
|
-
errorMessage += errorData.message?.email || errorData.message;
|
|
21
|
-
}
|
|
22
|
-
} catch (parseError) {
|
|
23
|
-
errorMessage += "Failed to parse error details.";
|
|
24
|
-
}
|
|
25
|
-
throw createError({
|
|
26
|
-
status: 400,
|
|
27
|
-
statusMessage: "Bad Request",
|
|
28
|
-
message: "Invalid user input",
|
|
29
|
-
data: { field: "email" }
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const data = await response.json();
|
|
33
|
-
return data.data;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw createError({
|
|
36
|
-
status: 400,
|
|
37
|
-
statusMessage: "Bad Request",
|
|
38
|
-
message: "Invalid user input",
|
|
39
|
-
data: { field: "email" }
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody, setCookie, createError } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const body = await readBody(event);
|
|
4
|
-
const { email, token } = body;
|
|
5
|
-
try {
|
|
6
|
-
const response = await fetch(`${process.env.FLOWRIX_API_BASE}verify-token/`, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
headers: {
|
|
9
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
11
|
-
"Content-Type": "application/json"
|
|
12
|
-
},
|
|
13
|
-
body: JSON.stringify({ email, token })
|
|
14
|
-
});
|
|
15
|
-
if (!response.ok) {
|
|
16
|
-
let errorMessage = ``;
|
|
17
|
-
try {
|
|
18
|
-
const errorData = await response.json();
|
|
19
|
-
console.error("Error response data:", errorData.message);
|
|
20
|
-
if (errorData.message) {
|
|
21
|
-
errorMessage += errorData.message?.email || errorData.message;
|
|
22
|
-
}
|
|
23
|
-
} catch (parseError) {
|
|
24
|
-
errorMessage += "Failed to parse error details.";
|
|
25
|
-
}
|
|
26
|
-
throw createError({
|
|
27
|
-
status: 400,
|
|
28
|
-
statusMessage: "Bad Request",
|
|
29
|
-
message: "Invalid user input",
|
|
30
|
-
data: { field: "email" }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const data = await response.json();
|
|
34
|
-
setCookie(event, "token", data?.data, {
|
|
35
|
-
httpOnly: true,
|
|
36
|
-
secure: process.env.NODE_ENV === "production",
|
|
37
|
-
path: "/",
|
|
38
|
-
sameSite: "lax"
|
|
39
|
-
});
|
|
40
|
-
return data;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
throw createError({
|
|
43
|
-
status: 400,
|
|
44
|
-
statusMessage: "Bad Request",
|
|
45
|
-
message: "Invalid user input",
|
|
46
|
-
data: { field: "email" }
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam, readBody } from "h3";
|
|
2
|
-
import { flowrixApi } from "../../../../../middleware/flowrix.js";
|
|
3
|
-
import { useRuntimeConfig } from "#imports";
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
const slug = getRouterParam(event, "slug");
|
|
6
|
-
const body = await readBody(event);
|
|
7
|
-
const config = useRuntimeConfig();
|
|
8
|
-
const response = await flowrixApi.post(
|
|
9
|
-
`cart/service/${slug}/add`,
|
|
10
|
-
config,
|
|
11
|
-
{
|
|
12
|
-
body
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
return response;
|
|
16
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "fs";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import { defineEventHandler } from "h3";
|
|
4
|
-
export default defineEventHandler(() => {
|
|
5
|
-
const filePath = resolve(process.cwd(), "pages/404.vue");
|
|
6
|
-
const exists = existsSync(filePath);
|
|
7
|
-
return { exists };
|
|
8
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, setResponseStatus, getRouterParam, getCookie } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
export default defineEventHandler(async (event) => {
|
|
4
|
-
const slug = getRouterParam(event, "slug");
|
|
5
|
-
const accessTok = getCookie(event, "authToken");
|
|
6
|
-
try {
|
|
7
|
-
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}mystore/customer/quotations/${slug}`, {
|
|
8
|
-
method: "GET",
|
|
9
|
-
headers: {
|
|
10
|
-
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
11
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
12
|
-
"Authorization": `Bearer ${accessTok || ""}`
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return response;
|
|
16
|
-
} catch (error) {
|
|
17
|
-
setResponseStatus(event, error.statusCode || 500);
|
|
18
|
-
return { success: false, error: error.message, data: error.data };
|
|
19
|
-
}
|
|
20
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, setResponseStatus, getRouterParam, readBody, getMethod, getQuery } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
export default defineEventHandler(async (event) => {
|
|
4
|
-
const slug = getRouterParam(event, "slug");
|
|
5
|
-
const method = getMethod(event);
|
|
6
|
-
const query = getQuery(event);
|
|
7
|
-
try {
|
|
8
|
-
if (method === "GET") {
|
|
9
|
-
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}quotations/${slug}`, {
|
|
10
|
-
method: "GET",
|
|
11
|
-
headers: {
|
|
12
|
-
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
13
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN || ""
|
|
14
|
-
},
|
|
15
|
-
query
|
|
16
|
-
});
|
|
17
|
-
return response;
|
|
18
|
-
} else if (method === "POST") {
|
|
19
|
-
const body = await readBody(event);
|
|
20
|
-
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}quotations/${slug}`, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: {
|
|
23
|
-
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
24
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN || ""
|
|
25
|
-
},
|
|
26
|
-
body,
|
|
27
|
-
query
|
|
28
|
-
});
|
|
29
|
-
return response;
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
setResponseStatus(event, error.statusCode || 500);
|
|
33
|
-
return { success: false, error: error.message, data: error.data };
|
|
34
|
-
}
|
|
35
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, setResponseStatus, readBody, getCookie, getRouterParam } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
export default defineEventHandler(async (event) => {
|
|
4
|
-
const slug = getRouterParam(event, "slug");
|
|
5
|
-
const body = await readBody(event);
|
|
6
|
-
const accessTok = getCookie(event, "authToken");
|
|
7
|
-
try {
|
|
8
|
-
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}mystore/customer/checkout/quotation/${slug}`, {
|
|
9
|
-
method: "POST",
|
|
10
|
-
headers: {
|
|
11
|
-
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
12
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
13
|
-
"Authorization": `Bearer ${accessTok || ""}`
|
|
14
|
-
},
|
|
15
|
-
body
|
|
16
|
-
});
|
|
17
|
-
return response;
|
|
18
|
-
} catch (error) {
|
|
19
|
-
setResponseStatus(event, error.statusCode || 500);
|
|
20
|
-
return { success: false, error: error.message, data: error.data };
|
|
21
|
-
}
|
|
22
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody } from "h3";
|
|
2
|
-
import { flowrixApi } from "../../../../middleware/flowrix.js";
|
|
3
|
-
import { useRuntimeConfig } from "#imports";
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
const body = await readBody(event);
|
|
6
|
-
const config = useRuntimeConfig();
|
|
7
|
-
const rawCookies = event.req.headers.cookie || "";
|
|
8
|
-
const apiConfig = {
|
|
9
|
-
...config,
|
|
10
|
-
cookies: rawCookies
|
|
11
|
-
};
|
|
12
|
-
const options = {
|
|
13
|
-
headers: {
|
|
14
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
15
|
-
},
|
|
16
|
-
body
|
|
17
|
-
};
|
|
18
|
-
const webform = await flowrixApi.post(`posts`, apiConfig, options);
|
|
19
|
-
return webform;
|
|
20
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
2
|
-
status: string;
|
|
3
|
-
statusCode: number;
|
|
4
|
-
data: unknown;
|
|
5
|
-
message: string;
|
|
6
|
-
error?: undefined;
|
|
7
|
-
} | {
|
|
8
|
-
status: string;
|
|
9
|
-
statusCode: any;
|
|
10
|
-
message: any;
|
|
11
|
-
error: any;
|
|
12
|
-
data?: undefined;
|
|
13
|
-
}>>;
|
|
14
|
-
export default _default;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody, getCookie } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const accessTok = getCookie(event, "auth.token");
|
|
4
|
-
const body = await readBody(event);
|
|
5
|
-
try {
|
|
6
|
-
const responseData = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/address/add`, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
headers: {
|
|
9
|
-
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
10
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
11
|
-
"Authorization": `Bearer ${accessTok || ""}`,
|
|
12
|
-
"Content-Type": "application/json",
|
|
13
|
-
"Accept": "application/json"
|
|
14
|
-
},
|
|
15
|
-
body
|
|
16
|
-
});
|
|
17
|
-
return {
|
|
18
|
-
status: "Success",
|
|
19
|
-
statusCode: 200,
|
|
20
|
-
data: responseData,
|
|
21
|
-
message: "Address added successfully"
|
|
22
|
-
};
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error("Error in add address:", error);
|
|
25
|
-
return {
|
|
26
|
-
status: "Error",
|
|
27
|
-
statusCode: error?.statusCode || 500,
|
|
28
|
-
message: error?.data?.message || "Failed to add address",
|
|
29
|
-
error: error.message
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
2
|
-
status: string;
|
|
3
|
-
statusCode: number;
|
|
4
|
-
message: string;
|
|
5
|
-
data?: undefined;
|
|
6
|
-
error?: undefined;
|
|
7
|
-
} | {
|
|
8
|
-
status: string;
|
|
9
|
-
statusCode: number;
|
|
10
|
-
data: unknown;
|
|
11
|
-
message: string;
|
|
12
|
-
error?: undefined;
|
|
13
|
-
} | {
|
|
14
|
-
status: string;
|
|
15
|
-
statusCode: number;
|
|
16
|
-
message: string;
|
|
17
|
-
error: any;
|
|
18
|
-
data?: undefined;
|
|
19
|
-
}>>;
|
|
20
|
-
export default _default;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, getCookie } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const accessTok = getCookie(event, "auth.token");
|
|
4
|
-
const { addressId } = getQuery(event);
|
|
5
|
-
if (!addressId) {
|
|
6
|
-
return {
|
|
7
|
-
status: "Error",
|
|
8
|
-
statusCode: 400,
|
|
9
|
-
message: "Address ID is required"
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/address/${addressId}/delete`, {
|
|
14
|
-
method: "PATCH",
|
|
15
|
-
headers: {
|
|
16
|
-
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
17
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
18
|
-
"Authorization": `Bearer ${accessTok || ""}`
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
status: "Success",
|
|
23
|
-
statusCode: 200,
|
|
24
|
-
data: response,
|
|
25
|
-
message: "Address deleted successfully"
|
|
26
|
-
};
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error("Error deleting address:", error);
|
|
29
|
-
return {
|
|
30
|
-
status: "Error",
|
|
31
|
-
statusCode: 500,
|
|
32
|
-
message: "Failed to delete address",
|
|
33
|
-
error: error.message
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
2
|
-
status: string;
|
|
3
|
-
statusCode: number;
|
|
4
|
-
message: string;
|
|
5
|
-
data?: undefined;
|
|
6
|
-
error?: undefined;
|
|
7
|
-
} | {
|
|
8
|
-
status: string;
|
|
9
|
-
statusCode: number;
|
|
10
|
-
data: unknown;
|
|
11
|
-
message: string;
|
|
12
|
-
error?: undefined;
|
|
13
|
-
} | {
|
|
14
|
-
status: string;
|
|
15
|
-
statusCode: number;
|
|
16
|
-
message: string;
|
|
17
|
-
error: any;
|
|
18
|
-
data?: undefined;
|
|
19
|
-
}>>;
|
|
20
|
-
export default _default;
|