@raxonltd/raxon-core 1.0.0
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/core/component/general.image.d.ts +25 -0
- package/dist/core/component/general.image.d.ts.map +1 -0
- package/dist/core/component/general.image.js +30 -0
- package/dist/core/context/cart.context.d.ts +25 -0
- package/dist/core/context/cart.context.d.ts.map +1 -0
- package/dist/core/context/cart.context.js +339 -0
- package/dist/core/context/security.context.d.ts +15 -0
- package/dist/core/context/security.context.d.ts.map +1 -0
- package/dist/core/context/security.context.js +130 -0
- package/dist/core/feature/address/form/address-search-input.d.ts +17 -0
- package/dist/core/feature/address/form/address-search-input.d.ts.map +1 -0
- package/dist/core/feature/address/form/address-search-input.js +30 -0
- package/dist/core/feature/address/hook/use.addres.d.ts +10 -0
- package/dist/core/feature/address/hook/use.addres.d.ts.map +1 -0
- package/dist/core/feature/address/hook/use.addres.js +57 -0
- package/dist/core/feature/address/hook/use.address-autocomplete.d.ts +13 -0
- package/dist/core/feature/address/hook/use.address-autocomplete.d.ts.map +1 -0
- package/dist/core/feature/address/hook/use.address-autocomplete.js +105 -0
- package/dist/core/feature/address/util/address.types.d.ts +37 -0
- package/dist/core/feature/address/util/address.types.d.ts.map +1 -0
- package/dist/core/feature/address/util/address.types.js +1 -0
- package/dist/core/feature/address/util/parse-google-place.d.ts +13 -0
- package/dist/core/feature/address/util/parse-google-place.d.ts.map +1 -0
- package/dist/core/feature/address/util/parse-google-place.js +49 -0
- package/dist/core/feature/analytic-event/analytic.event.context.d.ts +19 -0
- package/dist/core/feature/analytic-event/analytic.event.context.d.ts.map +1 -0
- package/dist/core/feature/analytic-event/analytic.event.context.js +151 -0
- package/dist/core/feature/article/hook/use.article.d.ts +7 -0
- package/dist/core/feature/article/hook/use.article.d.ts.map +1 -0
- package/dist/core/feature/article/hook/use.article.js +28 -0
- package/dist/core/feature/attribute/hook/use.attribute.d.ts +10 -0
- package/dist/core/feature/attribute/hook/use.attribute.d.ts.map +1 -0
- package/dist/core/feature/attribute/hook/use.attribute.js +21 -0
- package/dist/core/feature/auth/hook/use.auth.d.ts +29 -0
- package/dist/core/feature/auth/hook/use.auth.d.ts.map +1 -0
- package/dist/core/feature/auth/hook/use.auth.js +122 -0
- package/dist/core/feature/auth/modal/modal.auth.d.ts +9 -0
- package/dist/core/feature/auth/modal/modal.auth.d.ts.map +1 -0
- package/dist/core/feature/auth/modal/modal.auth.js +34 -0
- package/dist/core/feature/auth/view/view.login.d.ts +8 -0
- package/dist/core/feature/auth/view/view.login.d.ts.map +1 -0
- package/dist/core/feature/auth/view/view.login.js +45 -0
- package/dist/core/feature/auth/view/view.register.d.ts +8 -0
- package/dist/core/feature/auth/view/view.register.d.ts.map +1 -0
- package/dist/core/feature/auth/view/view.register.js +83 -0
- package/dist/core/feature/bank-account/hook/use.bank.account.d.ts +12 -0
- package/dist/core/feature/bank-account/hook/use.bank.account.d.ts.map +1 -0
- package/dist/core/feature/bank-account/hook/use.bank.account.js +38 -0
- package/dist/core/feature/cart/component/cart.order.summary.d.ts +8 -0
- package/dist/core/feature/cart/component/cart.order.summary.d.ts.map +1 -0
- package/dist/core/feature/cart/component/cart.order.summary.js +8 -0
- package/dist/core/feature/cart/component/cart.promo.code.section.d.ts +6 -0
- package/dist/core/feature/cart/component/cart.promo.code.section.d.ts.map +1 -0
- package/dist/core/feature/cart/component/cart.promo.code.section.js +109 -0
- package/dist/core/feature/cart/hook/use.cart.d.ts +67 -0
- package/dist/core/feature/cart/hook/use.cart.d.ts.map +1 -0
- package/dist/core/feature/cart/hook/use.cart.js +196 -0
- package/dist/core/feature/cart/util/basket-pay.response.d.ts +20 -0
- package/dist/core/feature/cart/util/basket-pay.response.d.ts.map +1 -0
- package/dist/core/feature/cart/util/basket-pay.response.js +40 -0
- package/dist/core/feature/cart/util/cart-optimistic.d.ts +36 -0
- package/dist/core/feature/cart/util/cart-optimistic.d.ts.map +1 -0
- package/dist/core/feature/cart/util/cart-optimistic.js +320 -0
- package/dist/core/feature/cart/util/garanti-payment.d.ts +4 -0
- package/dist/core/feature/cart/util/garanti-payment.d.ts.map +1 -0
- package/dist/core/feature/cart/util/garanti-payment.js +26 -0
- package/dist/core/feature/collection/hook/use.collection.d.ts +7 -0
- package/dist/core/feature/collection/hook/use.collection.d.ts.map +1 -0
- package/dist/core/feature/collection/hook/use.collection.js +27 -0
- package/dist/core/feature/delivery-method/hook/use.delivery.method.d.ts +10 -0
- package/dist/core/feature/delivery-method/hook/use.delivery.method.d.ts.map +1 -0
- package/dist/core/feature/delivery-method/hook/use.delivery.method.js +33 -0
- package/dist/core/feature/delivery-method/util/checkout.delivery.method.d.ts +5 -0
- package/dist/core/feature/delivery-method/util/checkout.delivery.method.d.ts.map +1 -0
- package/dist/core/feature/delivery-method/util/checkout.delivery.method.js +8 -0
- package/dist/core/feature/faq/hook/use.faq.d.ts +9 -0
- package/dist/core/feature/faq/hook/use.faq.d.ts.map +1 -0
- package/dist/core/feature/faq/hook/use.faq.js +20 -0
- package/dist/core/feature/favorite/hook/use.favorite.d.ts +17 -0
- package/dist/core/feature/favorite/hook/use.favorite.d.ts.map +1 -0
- package/dist/core/feature/favorite/hook/use.favorite.js +35 -0
- package/dist/core/feature/form-submit/form/form.contact.d.ts +6 -0
- package/dist/core/feature/form-submit/form/form.contact.d.ts.map +1 -0
- package/dist/core/feature/form-submit/form/form.contact.js +8 -0
- package/dist/core/feature/form-submit/hook/use.form.submit.d.ts +4 -0
- package/dist/core/feature/form-submit/hook/use.form.submit.d.ts.map +1 -0
- package/dist/core/feature/form-submit/hook/use.form.submit.js +13 -0
- package/dist/core/feature/invoice/hook/use.invoice.d.ts +9 -0
- package/dist/core/feature/invoice/hook/use.invoice.d.ts.map +1 -0
- package/dist/core/feature/invoice/hook/use.invoice.js +46 -0
- package/dist/core/feature/newsletter/hook/use.newsletter.d.ts +13 -0
- package/dist/core/feature/newsletter/hook/use.newsletter.d.ts.map +1 -0
- package/dist/core/feature/newsletter/hook/use.newsletter.js +21 -0
- package/dist/core/feature/newsletter/modal/modal.newsletter.product.d.ts +27 -0
- package/dist/core/feature/newsletter/modal/modal.newsletter.product.d.ts.map +1 -0
- package/dist/core/feature/newsletter/modal/modal.newsletter.product.js +77 -0
- package/dist/core/feature/order/hook/use.order.d.ts +7 -0
- package/dist/core/feature/order/hook/use.order.d.ts.map +1 -0
- package/dist/core/feature/order/hook/use.order.js +26 -0
- package/dist/core/feature/payment-method/checkout.payment.options.d.ts +18 -0
- package/dist/core/feature/payment-method/checkout.payment.options.d.ts.map +1 -0
- package/dist/core/feature/payment-method/checkout.payment.options.js +74 -0
- package/dist/core/feature/payment-method/hook/use.payment.method.d.ts +8 -0
- package/dist/core/feature/payment-method/hook/use.payment.method.d.ts.map +1 -0
- package/dist/core/feature/payment-method/hook/use.payment.method.js +36 -0
- package/dist/core/feature/product/hook/use.product.d.ts +62 -0
- package/dist/core/feature/product/hook/use.product.d.ts.map +1 -0
- package/dist/core/feature/product/hook/use.product.js +60 -0
- package/dist/core/feature/profile/hook/use.profile.d.ts +26 -0
- package/dist/core/feature/profile/hook/use.profile.d.ts.map +1 -0
- package/dist/core/feature/profile/hook/use.profile.js +83 -0
- package/dist/core/feature/promo-code/hook/use.promo.code.d.ts +8 -0
- package/dist/core/feature/promo-code/hook/use.promo.code.d.ts.map +1 -0
- package/dist/core/feature/promo-code/hook/use.promo.code.js +24 -0
- package/dist/core/interface/basket.interface.d.ts +347 -0
- package/dist/core/interface/basket.interface.d.ts.map +1 -0
- package/dist/core/interface/basket.interface.js +1 -0
- package/dist/core/interface/inventory.interface.d.ts +87 -0
- package/dist/core/interface/inventory.interface.d.ts.map +1 -0
- package/dist/core/interface/inventory.interface.js +1 -0
- package/dist/core/interface/nexine.interface.d.ts +5 -0
- package/dist/core/interface/nexine.interface.d.ts.map +1 -0
- package/dist/core/interface/nexine.interface.js +1 -0
- package/dist/core/interface/prisma.interface.d.ts +8404 -0
- package/dist/core/interface/prisma.interface.d.ts.map +1 -0
- package/dist/core/interface/prisma.interface.js +1227 -0
- package/dist/core/interface/product.interface.d.ts +100 -0
- package/dist/core/interface/product.interface.d.ts.map +1 -0
- package/dist/core/interface/product.interface.js +1 -0
- package/dist/core/raxon.context.d.ts +44 -0
- package/dist/core/raxon.context.d.ts.map +1 -0
- package/dist/core/raxon.context.js +90 -0
- package/dist/core/schema/checkout.schema.d.ts +46 -0
- package/dist/core/schema/checkout.schema.d.ts.map +1 -0
- package/dist/core/schema/checkout.schema.js +83 -0
- package/dist/core/util/basket.item.display.d.ts +3 -0
- package/dist/core/util/basket.item.display.d.ts.map +1 -0
- package/dist/core/util/basket.item.display.js +18 -0
- package/dist/core/util/category.nav.d.ts +9 -0
- package/dist/core/util/category.nav.d.ts.map +1 -0
- package/dist/core/util/category.nav.js +37 -0
- package/dist/core/util/client-ip.d.ts +2 -0
- package/dist/core/util/client-ip.d.ts.map +1 -0
- package/dist/core/util/client-ip.js +32 -0
- package/dist/core/util/collection.util.d.ts +31 -0
- package/dist/core/util/collection.util.d.ts.map +1 -0
- package/dist/core/util/collection.util.js +167 -0
- package/dist/core/util/garanti-payment.d.ts +2 -0
- package/dist/core/util/garanti-payment.d.ts.map +1 -0
- package/dist/core/util/garanti-payment.js +1 -0
- package/dist/core/util/nexine.axios.d.ts +2 -0
- package/dist/core/util/nexine.axios.d.ts.map +1 -0
- package/dist/core/util/nexine.axios.js +62 -0
- package/dist/core/util/no-cache.d.ts +6 -0
- package/dist/core/util/no-cache.d.ts.map +1 -0
- package/dist/core/util/no-cache.js +6 -0
- package/dist/core/util/util.d.ts +18 -0
- package/dist/core/util/util.d.ts.map +1 -0
- package/dist/core/util/util.js +163 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export function getCollectionLabel(tags) {
|
|
2
|
+
const ignored = new Set(['banner', 'subhero', 'web', 'homepage', 'anasayfa']);
|
|
3
|
+
const tag = tags?.find((t) => t && !ignored.has(String(t).toLowerCase()));
|
|
4
|
+
return tag ? String(tag).toUpperCase() : 'KOLEKSİYON';
|
|
5
|
+
}
|
|
6
|
+
function normalizeText(value) {
|
|
7
|
+
return value
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.normalize('NFD')
|
|
10
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
11
|
+
.replace(/ı/g, 'i')
|
|
12
|
+
.replace(/ğ/g, 'g')
|
|
13
|
+
.replace(/ü/g, 'u')
|
|
14
|
+
.replace(/ş/g, 's')
|
|
15
|
+
.replace(/ö/g, 'o')
|
|
16
|
+
.replace(/ç/g, 'c')
|
|
17
|
+
.replace(/[^a-z0-9]+/g, ' ')
|
|
18
|
+
.trim();
|
|
19
|
+
}
|
|
20
|
+
function tokensSimilar(a, b) {
|
|
21
|
+
if (a.length < 4 || b.length < 4)
|
|
22
|
+
return false;
|
|
23
|
+
const prefixLength = Math.min(6, a.length, b.length);
|
|
24
|
+
const prefixA = a.slice(0, prefixLength);
|
|
25
|
+
const prefixB = b.slice(0, prefixLength);
|
|
26
|
+
return prefixA === prefixB || a.includes(b) || b.includes(a);
|
|
27
|
+
}
|
|
28
|
+
export function isBrandCollectionTitle(title) {
|
|
29
|
+
if (!title)
|
|
30
|
+
return false;
|
|
31
|
+
const normalizedTitle = normalizeText(title);
|
|
32
|
+
return /kesfet|markasinin|marka urun/.test(normalizedTitle);
|
|
33
|
+
}
|
|
34
|
+
export function matchDirectBrandIdFromCollectionTitle(title, brands) {
|
|
35
|
+
if (!title || !brands?.length)
|
|
36
|
+
return null;
|
|
37
|
+
const normalizedTitle = normalizeText(title);
|
|
38
|
+
if (!normalizedTitle)
|
|
39
|
+
return null;
|
|
40
|
+
for (const brand of brands) {
|
|
41
|
+
const brandName = brand.name?.trim();
|
|
42
|
+
if (!brandName)
|
|
43
|
+
continue;
|
|
44
|
+
const normalizedBrand = normalizeText(brandName);
|
|
45
|
+
if (normalizedBrand && normalizedTitle === normalizedBrand) {
|
|
46
|
+
return brand.id;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
export function matchBrandIdFromCollectionTitle(title, brands) {
|
|
52
|
+
if (!title || !brands?.length)
|
|
53
|
+
return null;
|
|
54
|
+
const directBrandId = matchDirectBrandIdFromCollectionTitle(title, brands);
|
|
55
|
+
if (directBrandId)
|
|
56
|
+
return directBrandId;
|
|
57
|
+
if (!isBrandCollectionTitle(title))
|
|
58
|
+
return null;
|
|
59
|
+
const normalizedTitle = normalizeText(title);
|
|
60
|
+
if (!normalizedTitle)
|
|
61
|
+
return null;
|
|
62
|
+
const titleTokens = normalizedTitle.split(' ').filter((token) => token.length >= 4);
|
|
63
|
+
let bestMatch = null;
|
|
64
|
+
for (const brand of brands) {
|
|
65
|
+
const brandName = brand.name?.trim();
|
|
66
|
+
if (!brandName)
|
|
67
|
+
continue;
|
|
68
|
+
const normalizedBrand = normalizeText(brandName);
|
|
69
|
+
if (!normalizedBrand || normalizedBrand.length < 3)
|
|
70
|
+
continue;
|
|
71
|
+
const isMatch = tokensSimilar(normalizedTitle, normalizedBrand) ||
|
|
72
|
+
titleTokens.some((token) => tokensSimilar(token, normalizedBrand));
|
|
73
|
+
if (!isMatch)
|
|
74
|
+
continue;
|
|
75
|
+
const score = normalizedBrand.length;
|
|
76
|
+
if (!bestMatch || score > bestMatch.score) {
|
|
77
|
+
bestMatch = { id: brand.id, score };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return bestMatch?.id ?? null;
|
|
81
|
+
}
|
|
82
|
+
function getCategoryName(category) {
|
|
83
|
+
if (!category?.name)
|
|
84
|
+
return '';
|
|
85
|
+
if (Array.isArray(category.name)) {
|
|
86
|
+
const first = category.name[0];
|
|
87
|
+
return first?.value || '';
|
|
88
|
+
}
|
|
89
|
+
return String(category.name);
|
|
90
|
+
}
|
|
91
|
+
const COLLECTION_CATEGORY_HINTS = [
|
|
92
|
+
{ titlePattern: /saclar|sacini|sac bakim/, categoryPattern: /sac bakim urunleri/ },
|
|
93
|
+
{ titlePattern: /gunes|tatilde/, categoryPattern: /gunes/ },
|
|
94
|
+
{ titlePattern: /makyaj/, categoryPattern: /makyaj urunleri/ },
|
|
95
|
+
];
|
|
96
|
+
const COLLECTION_SEARCH_HINTS = [
|
|
97
|
+
{ titlePattern: /saclar|sacini|sac bakim/, searchQuery: 'sac bakim' },
|
|
98
|
+
];
|
|
99
|
+
export function matchSearchQueryFromCollectionTitle(title) {
|
|
100
|
+
if (!title)
|
|
101
|
+
return null;
|
|
102
|
+
const normalizedTitle = normalizeText(title);
|
|
103
|
+
if (!normalizedTitle)
|
|
104
|
+
return null;
|
|
105
|
+
for (const hint of COLLECTION_SEARCH_HINTS) {
|
|
106
|
+
if (hint.titlePattern.test(normalizedTitle)) {
|
|
107
|
+
return hint.searchQuery;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
export function shouldPreferThematicCategoryFallback(title) {
|
|
113
|
+
if (!title)
|
|
114
|
+
return false;
|
|
115
|
+
const normalizedTitle = normalizeText(title);
|
|
116
|
+
return COLLECTION_CATEGORY_HINTS.some((hint) => hint.titlePattern.test(normalizedTitle));
|
|
117
|
+
}
|
|
118
|
+
export function matchCategoryIdFromCollectionTitle(title, categories) {
|
|
119
|
+
if (!title || !categories?.length || !shouldPreferThematicCategoryFallback(title))
|
|
120
|
+
return null;
|
|
121
|
+
const normalizedTitle = normalizeText(title);
|
|
122
|
+
if (!normalizedTitle)
|
|
123
|
+
return null;
|
|
124
|
+
for (const hint of COLLECTION_CATEGORY_HINTS) {
|
|
125
|
+
if (!hint.titlePattern.test(normalizedTitle))
|
|
126
|
+
continue;
|
|
127
|
+
const match = categories.find((category) => hint.categoryPattern.test(normalizeText(getCategoryName(category))));
|
|
128
|
+
if (match)
|
|
129
|
+
return match.id;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const MAX_SANE_COLLECTION_COUNT = 200;
|
|
134
|
+
const MIN_COMPLETE_BRAND_COLLECTION_PRODUCTS = 10;
|
|
135
|
+
export function resolveCollectionProductSource(params) {
|
|
136
|
+
const { apiCount, detailCount, title, brandId, categoryId, searchQuery, isDirectBrandCollection, isCollectionProductsSettled, } = params;
|
|
137
|
+
if (!isCollectionProductsSettled)
|
|
138
|
+
return null;
|
|
139
|
+
if (apiCount > 0 && apiCount <= MAX_SANE_COLLECTION_COUNT) {
|
|
140
|
+
if (apiCount < 3 && shouldPreferThematicCategoryFallback(title)) {
|
|
141
|
+
if (searchQuery)
|
|
142
|
+
return 'search';
|
|
143
|
+
if (categoryId)
|
|
144
|
+
return 'category';
|
|
145
|
+
}
|
|
146
|
+
if (isDirectBrandCollection &&
|
|
147
|
+
brandId &&
|
|
148
|
+
apiCount < MIN_COMPLETE_BRAND_COLLECTION_PRODUCTS) {
|
|
149
|
+
return 'brand';
|
|
150
|
+
}
|
|
151
|
+
return 'collection';
|
|
152
|
+
}
|
|
153
|
+
if (detailCount > 0)
|
|
154
|
+
return 'detail';
|
|
155
|
+
if (brandId)
|
|
156
|
+
return 'brand';
|
|
157
|
+
if (searchQuery)
|
|
158
|
+
return 'search';
|
|
159
|
+
if (categoryId)
|
|
160
|
+
return 'category';
|
|
161
|
+
return 'empty';
|
|
162
|
+
}
|
|
163
|
+
export function filterProductsByCollectionAllowlist(products, allowlistIds) {
|
|
164
|
+
if (allowlistIds.size === 0)
|
|
165
|
+
return products;
|
|
166
|
+
return products.filter((product) => product.id && allowlistIds.has(product.id));
|
|
167
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"garanti-payment.d.ts","sourceRoot":"","sources":["../../../core/util/garanti-payment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,0CAA0C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { storeGarantiPaymentHtml, consumeGarantiPaymentHtml, submitGarantiPaymentHtml, } from '@/core/feature/cart/util/garanti-payment';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexine.axios.d.ts","sourceRoot":"","sources":["../../../core/util/nexine.axios.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,+BAMtB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { toast } from 'react-hot-toast';
|
|
3
|
+
export const nexineAxios = axios.create({
|
|
4
|
+
baseURL: typeof window !== 'undefined' ? window.__RAXON_API_URL__ : process.env.NEXT_PUBLIC_API_URL,
|
|
5
|
+
headers: {
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
'x-api-key': typeof window !== 'undefined' ? window.__RAXON_API_KEY__ : (process.env.NEXT_PUBLIC_API_KEY || ''),
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
nexineAxios.interceptors.request.use(config => {
|
|
11
|
+
if (typeof window !== 'undefined') {
|
|
12
|
+
const token = localStorage.getItem('koksal-token');
|
|
13
|
+
if (token) {
|
|
14
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
15
|
+
}
|
|
16
|
+
console.log(document.cookie
|
|
17
|
+
.split('; ').find(row => row.startsWith('_fbp='))?.split('=')[1]);
|
|
18
|
+
const fbc = document.cookie
|
|
19
|
+
.split('; ')
|
|
20
|
+
.find(row => row.startsWith('_fbc='))
|
|
21
|
+
?.split('=')[1];
|
|
22
|
+
const fbp = document.cookie
|
|
23
|
+
.split('; ')
|
|
24
|
+
.find(row => row.startsWith('_fbp='))
|
|
25
|
+
?.split('=')[1];
|
|
26
|
+
if (fbc) {
|
|
27
|
+
config.headers['x-fbc'] = fbc;
|
|
28
|
+
}
|
|
29
|
+
if (fbp) {
|
|
30
|
+
config.headers['x-fbp'] = fbp;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return config;
|
|
34
|
+
});
|
|
35
|
+
nexineAxios.interceptors.response.use(response => {
|
|
36
|
+
var excludeArray = ['/auth/register'];
|
|
37
|
+
if (response.config.method != 'get' && response.data.info && response.data.info.message && !excludeArray.includes(response.config.url || '')) {
|
|
38
|
+
toast.success(response.data.info.message);
|
|
39
|
+
}
|
|
40
|
+
return response;
|
|
41
|
+
}, error => {
|
|
42
|
+
// 401 Unauthorized hatası yakalandığında sadece token'ı temizle
|
|
43
|
+
if (error.response?.status === 401) {
|
|
44
|
+
const requestUrl = error.config?.url || '';
|
|
45
|
+
const requestMethod = error.config?.method || '';
|
|
46
|
+
// Token'ı temizle
|
|
47
|
+
if (typeof window !== 'undefined') {
|
|
48
|
+
localStorage.removeItem('koksal-token');
|
|
49
|
+
}
|
|
50
|
+
// /auth/me endpoint'inde toast gösterme (SecurityContext yönetiyor)
|
|
51
|
+
if (!requestUrl.includes('/auth/me')) {
|
|
52
|
+
// Sadece POST, PUT, DELETE işlemlerinde toast göster
|
|
53
|
+
if (requestMethod !== 'get') {
|
|
54
|
+
toast.error('Oturum süreniz dolmuş. Lütfen tekrar giriş yapın.');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (error.response?.data.info && error.response?.data.info.message) {
|
|
59
|
+
toast.error(error.response?.data.info.message ?? error.response?.data.info.title);
|
|
60
|
+
}
|
|
61
|
+
return Promise.reject(error);
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-cache.d.ts","sourceRoot":"","sources":["../../../core/util/no-cache.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare class GlobalEventEmitter {
|
|
2
|
+
private events;
|
|
3
|
+
on(event: string, callback: Function): void;
|
|
4
|
+
off(event: string, callback: Function): void;
|
|
5
|
+
emit(event: string, data?: any): void;
|
|
6
|
+
clear(event?: string): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const globalEmitter: GlobalEventEmitter;
|
|
9
|
+
export declare const GLOBAL_EVENTS: {
|
|
10
|
+
readonly SHOW_LOGIN_MODAL: "show_login_modal";
|
|
11
|
+
readonly HIDE_LOGIN_MODAL: "hide_login_modal";
|
|
12
|
+
readonly UNAUTHORIZED_ERROR: "unauthorized_error";
|
|
13
|
+
readonly TOKEN_EXPIRED: "token_expired";
|
|
14
|
+
};
|
|
15
|
+
export declare const cn: (...inputs: any[]) => string;
|
|
16
|
+
export declare const getSafeImageUrl: (path: string | undefined, type?: "product" | "category" | "brand" | "banner") => string;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../core/util/util.ts"],"names":[],"mappings":"AAgHA,cAAM,kBAAkB;IACtB,OAAO,CAAC,MAAM,CAAqC;IAGnD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;IAQpC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;IAMrC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAM9B,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM;CAOrB;AAGD,eAAO,MAAM,aAAa,oBAA2B,CAAC;AAGtD,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAGX,eAAO,MAAM,EAAE,GAAI,GAAG,QAAQ,GAAG,EAAE,WAElC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,GAAG,SAAS,EAAE,OAAM,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,QAAoB,WA6BtH,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { WeightType } from "../interface/prisma.interface";
|
|
2
|
+
String.prototype.toTry = function () {
|
|
3
|
+
return Number(this).toTry();
|
|
4
|
+
};
|
|
5
|
+
String.prototype.storageUrl = function () {
|
|
6
|
+
return `${process.env.NEXT_PUBLIC_STORAGE_URL}/${this}`;
|
|
7
|
+
};
|
|
8
|
+
String.prototype.letterInitial = function () {
|
|
9
|
+
return this.substring(0, 2).toUpperCase();
|
|
10
|
+
};
|
|
11
|
+
String.prototype.weightTypeToText = function () {
|
|
12
|
+
if (this == WeightType.GR)
|
|
13
|
+
return "gr";
|
|
14
|
+
if (this == WeightType.ML)
|
|
15
|
+
return "ml";
|
|
16
|
+
if (this == WeightType.PIECE)
|
|
17
|
+
return "adet";
|
|
18
|
+
return "---";
|
|
19
|
+
};
|
|
20
|
+
Number.prototype.toTry = function () {
|
|
21
|
+
return this.toLocaleString('tr-TR', {
|
|
22
|
+
style: 'currency',
|
|
23
|
+
currency: 'TRY',
|
|
24
|
+
minimumFractionDigits: 2,
|
|
25
|
+
maximumFractionDigits: 2,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
Date.prototype.ddMMyyyy = function () {
|
|
29
|
+
return this.toLocaleDateString('tr-TR', {
|
|
30
|
+
day: '2-digit',
|
|
31
|
+
month: '2-digit',
|
|
32
|
+
year: 'numeric'
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
String.prototype.ddMMyyyy = function () {
|
|
36
|
+
return new Date(this.toString()).toLocaleDateString('tr-TR', {
|
|
37
|
+
day: '2-digit',
|
|
38
|
+
month: '2-digit',
|
|
39
|
+
year: 'numeric'
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
Array.prototype.getName = function () {
|
|
43
|
+
var selectedLanguage = 'TR';
|
|
44
|
+
if (this.length > 0) {
|
|
45
|
+
var findGerman = this.find(item => item.language === 'DE');
|
|
46
|
+
var findTurkish = this.find(item => item.language === 'TR');
|
|
47
|
+
var findEnglish = this.find(item => item.language === 'EN');
|
|
48
|
+
var findSelectedLanguage = this.find(item => item.language.toLowerCase() === selectedLanguage.toLowerCase());
|
|
49
|
+
if (findSelectedLanguage) {
|
|
50
|
+
return findSelectedLanguage.value ?? findSelectedLanguage.name;
|
|
51
|
+
}
|
|
52
|
+
if (findGerman) {
|
|
53
|
+
return findGerman.value ?? findGerman.name;
|
|
54
|
+
}
|
|
55
|
+
if (findTurkish) {
|
|
56
|
+
return findTurkish.value ?? findTurkish.name;
|
|
57
|
+
}
|
|
58
|
+
if (findEnglish) {
|
|
59
|
+
return findEnglish.value ?? findEnglish.name;
|
|
60
|
+
}
|
|
61
|
+
return this[0].value ?? this[0].value;
|
|
62
|
+
}
|
|
63
|
+
return '----';
|
|
64
|
+
};
|
|
65
|
+
Array.prototype.getSlug = function () {
|
|
66
|
+
var selectedLanguage = 'TR';
|
|
67
|
+
if (this.length > 0) {
|
|
68
|
+
var findGerman = this.find(item => item.language === 'DE');
|
|
69
|
+
var findTurkish = this.find(item => item.language === 'TR');
|
|
70
|
+
var findEnglish = this.find(item => item.language === 'EN');
|
|
71
|
+
var dt = {
|
|
72
|
+
"de": findGerman,
|
|
73
|
+
"tr": findTurkish,
|
|
74
|
+
"en": findEnglish
|
|
75
|
+
};
|
|
76
|
+
var find = dt[selectedLanguage];
|
|
77
|
+
if (find) {
|
|
78
|
+
return find.slug ?? find.value;
|
|
79
|
+
}
|
|
80
|
+
if (findGerman) {
|
|
81
|
+
return findGerman.slug ?? findGerman.value;
|
|
82
|
+
}
|
|
83
|
+
if (findTurkish) {
|
|
84
|
+
return findTurkish.slug ?? findTurkish.value;
|
|
85
|
+
}
|
|
86
|
+
if (findEnglish) {
|
|
87
|
+
return findEnglish.slug ?? findEnglish.value;
|
|
88
|
+
}
|
|
89
|
+
return this[0].slug ?? this[0].value;
|
|
90
|
+
}
|
|
91
|
+
return '----';
|
|
92
|
+
};
|
|
93
|
+
// Global Event Emitter sistemi
|
|
94
|
+
class GlobalEventEmitter {
|
|
95
|
+
events = {};
|
|
96
|
+
// Event dinleyici ekle
|
|
97
|
+
on(event, callback) {
|
|
98
|
+
if (!this.events[event]) {
|
|
99
|
+
this.events[event] = [];
|
|
100
|
+
}
|
|
101
|
+
this.events[event].push(callback);
|
|
102
|
+
}
|
|
103
|
+
// Event dinleyici kaldır
|
|
104
|
+
off(event, callback) {
|
|
105
|
+
if (!this.events[event])
|
|
106
|
+
return;
|
|
107
|
+
this.events[event] = this.events[event].filter(cb => cb !== callback);
|
|
108
|
+
}
|
|
109
|
+
// Event tetikle
|
|
110
|
+
emit(event, data) {
|
|
111
|
+
if (!this.events[event])
|
|
112
|
+
return;
|
|
113
|
+
this.events[event].forEach(callback => callback(data));
|
|
114
|
+
}
|
|
115
|
+
// Tüm dinleyicileri temizle
|
|
116
|
+
clear(event) {
|
|
117
|
+
if (event) {
|
|
118
|
+
delete this.events[event];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.events = {};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Global emitter instance
|
|
126
|
+
export const globalEmitter = new GlobalEventEmitter();
|
|
127
|
+
// Event türleri
|
|
128
|
+
export const GLOBAL_EVENTS = {
|
|
129
|
+
SHOW_LOGIN_MODAL: 'show_login_modal',
|
|
130
|
+
HIDE_LOGIN_MODAL: 'hide_login_modal',
|
|
131
|
+
UNAUTHORIZED_ERROR: 'unauthorized_error',
|
|
132
|
+
TOKEN_EXPIRED: 'token_expired',
|
|
133
|
+
};
|
|
134
|
+
export const cn = (...inputs) => {
|
|
135
|
+
return inputs.filter(Boolean).join(" ");
|
|
136
|
+
};
|
|
137
|
+
export const getSafeImageUrl = (path, type = 'product') => {
|
|
138
|
+
let storageUrl = process.env.NEXT_PUBLIC_STORAGE_URL || 'https://cdn.bonero.tr';
|
|
139
|
+
if (storageUrl.startsWith('http://cdn.bonero.tr')) {
|
|
140
|
+
storageUrl = storageUrl.replace('http://', 'https://');
|
|
141
|
+
}
|
|
142
|
+
if (!path || path === 'null' || path === 'undefined') {
|
|
143
|
+
if (type === 'product')
|
|
144
|
+
return 'https://placehold.co/400x600?text=Urun+Gorseli';
|
|
145
|
+
if (type === 'category')
|
|
146
|
+
return 'https://placehold.co/300x300?text=Kategori';
|
|
147
|
+
if (type === 'brand')
|
|
148
|
+
return 'https://placehold.co/200x100?text=Marka';
|
|
149
|
+
return 'https://placehold.co/800x400?text=Banner';
|
|
150
|
+
}
|
|
151
|
+
if (path.startsWith('http')) {
|
|
152
|
+
return path.replace('http://', 'https://');
|
|
153
|
+
}
|
|
154
|
+
// Yerel dosyalar (public klasörü altındakiler) için storage URL ekleme
|
|
155
|
+
if (path.startsWith('/images/') || path.startsWith('/logo/')) {
|
|
156
|
+
return path;
|
|
157
|
+
}
|
|
158
|
+
const cleanPath = path.startsWith('/') ? path.substring(1) : path;
|
|
159
|
+
const finalPath = (storageUrl.endsWith('/bonero') && cleanPath.startsWith('bonero/'))
|
|
160
|
+
? cleanPath.replace('bonero/', '')
|
|
161
|
+
: cleanPath;
|
|
162
|
+
return `${storageUrl}/${finalPath}`;
|
|
163
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from '@/core/raxon.context';
|
|
2
|
+
export * from '@/core/context/security.context';
|
|
3
|
+
export * from '@/core/context/cart.context';
|
|
4
|
+
export * from '@/core/feature/auth/hook/use.auth';
|
|
5
|
+
export * from '@/core/feature/cart/hook/use.cart';
|
|
6
|
+
export * from '@/core/feature/product/hook/use.product';
|
|
7
|
+
export * from '@/core/feature/address/hook/use.addres';
|
|
8
|
+
export * from '@/core/feature/collection/hook/use.collection';
|
|
9
|
+
export * from '@/core/feature/bank-account/hook/use.bank.account';
|
|
10
|
+
export * from '@/core/feature/delivery-method/hook/use.delivery.method';
|
|
11
|
+
export * from '@/core/feature/payment-method/hook/use.payment.method';
|
|
12
|
+
export * from '@/core/feature/order/hook/use.order';
|
|
13
|
+
export * from '@/core/feature/profile/hook/use.profile';
|
|
14
|
+
export * from '@/core/feature/favorite/hook/use.favorite';
|
|
15
|
+
export * from '@/core/feature/newsletter/hook/use.newsletter';
|
|
16
|
+
export * from '@/core/feature/article/hook/use.article';
|
|
17
|
+
export * from '@/core/feature/faq/hook/use.faq';
|
|
18
|
+
export * from '@/core/feature/form-submit/hook/use.form.submit';
|
|
19
|
+
export * from '@/core/feature/promo-code/hook/use.promo.code';
|
|
20
|
+
export * from '@/core/feature/attribute/hook/use.attribute';
|
|
21
|
+
export * from '@/core/feature/invoice/hook/use.invoice';
|
|
22
|
+
export { nexineAxios } from '@/core/util/nexine.axios';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,yDAAyD,CAAC;AACxE,cAAc,uDAAuD,CAAC;AACtE,cAAc,qCAAqC,CAAC;AACpD,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iDAAiD,CAAC;AAChE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from '@/core/raxon.context';
|
|
2
|
+
export * from '@/core/context/security.context';
|
|
3
|
+
export * from '@/core/context/cart.context';
|
|
4
|
+
export * from '@/core/feature/auth/hook/use.auth';
|
|
5
|
+
export * from '@/core/feature/cart/hook/use.cart';
|
|
6
|
+
export * from '@/core/feature/product/hook/use.product';
|
|
7
|
+
export * from '@/core/feature/address/hook/use.addres';
|
|
8
|
+
export * from '@/core/feature/collection/hook/use.collection';
|
|
9
|
+
export * from '@/core/feature/bank-account/hook/use.bank.account';
|
|
10
|
+
export * from '@/core/feature/delivery-method/hook/use.delivery.method';
|
|
11
|
+
export * from '@/core/feature/payment-method/hook/use.payment.method';
|
|
12
|
+
export * from '@/core/feature/order/hook/use.order';
|
|
13
|
+
export * from '@/core/feature/profile/hook/use.profile';
|
|
14
|
+
export * from '@/core/feature/favorite/hook/use.favorite';
|
|
15
|
+
export * from '@/core/feature/newsletter/hook/use.newsletter';
|
|
16
|
+
export * from '@/core/feature/article/hook/use.article';
|
|
17
|
+
export * from '@/core/feature/faq/hook/use.faq';
|
|
18
|
+
export * from '@/core/feature/form-submit/hook/use.form.submit';
|
|
19
|
+
export * from '@/core/feature/promo-code/hook/use.promo.code';
|
|
20
|
+
export * from '@/core/feature/attribute/hook/use.attribute';
|
|
21
|
+
export * from '@/core/feature/invoice/hook/use.invoice';
|
|
22
|
+
export { nexineAxios } from '@/core/util/nexine.axios';
|