@raxonltd/raxon-core 1.1.7 → 1.1.8
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/core/component/general.image.tsx +86 -0
- package/core/context/cart.context.tsx +446 -0
- package/core/context/security.context.tsx +151 -0
- package/core/feature/address/api/places.api.ts +76 -0
- package/core/feature/address/form/address-search-input.tsx +125 -0
- package/core/feature/address/hook/use.addres.tsx +63 -0
- package/core/feature/address/hook/use.address-autocomplete.ts +116 -0
- package/core/feature/address/util/address.types.ts +38 -0
- package/core/feature/address/util/parse-google-place.ts +66 -0
- package/core/feature/analytic-event/analytic.event.api.ts +27 -0
- package/core/feature/analytic-event/analytic.event.context.tsx +180 -0
- package/core/feature/analytic-event/analytic.event.util.ts +42 -0
- package/core/feature/analytic-event/use.analytic.auto.tsx +114 -0
- package/core/feature/article/hook/use.article.tsx +33 -0
- package/core/feature/attribute/hook/use.attribute.tsx +24 -0
- package/core/feature/auth/hook/use.auth.tsx +141 -0
- package/core/feature/auth/modal/modal.auth.tsx +80 -0
- package/core/feature/auth/view/view.login.tsx +199 -0
- package/core/feature/auth/view/view.register.tsx +333 -0
- package/core/feature/bank-account/hook/use.bank.account.tsx +47 -0
- package/core/feature/brand/hook/use.brand.tsx +24 -0
- package/core/feature/cart/component/cart.order.summary.tsx +89 -0
- package/core/feature/cart/component/cart.promo.code.section.tsx +208 -0
- package/core/feature/cart/hook/use.cart.tsx +267 -0
- package/core/feature/cart/util/basket-pay.response.ts +67 -0
- package/core/feature/cart/util/cart-optimistic.ts +425 -0
- package/core/feature/cart/util/garanti-payment.ts +27 -0
- package/core/feature/collection/hook/use.collection.tsx +32 -0
- package/core/feature/delivery-method/hook/use.delivery.method.tsx +40 -0
- package/core/feature/delivery-method/util/checkout.delivery.method.ts +11 -0
- package/core/feature/faq/hook/use.faq.tsx +23 -0
- package/core/feature/favorite/hook/use.favorite.tsx +48 -0
- package/core/feature/form-submit/form/form.contact.tsx +118 -0
- package/core/feature/form-submit/hook/use.form.submit.tsx +16 -0
- package/core/feature/invoice/hook/use.invoice.tsx +51 -0
- package/core/feature/newsletter/hook/use.newsletter.tsx +124 -0
- package/core/feature/newsletter/modal/modal.newsletter.product.tsx +163 -0
- package/core/feature/order/hook/use.order.tsx +31 -0
- package/core/feature/payment-method/checkout.payment.options.ts +117 -0
- package/core/feature/payment-method/hook/use.payment.method.tsx +44 -0
- package/core/feature/product/hook/use.product.tsx +122 -0
- package/core/feature/profile/hook/use.profile.tsx +126 -0
- package/core/feature/promo-code/hook/use.promo.code.tsx +27 -0
- package/core/interface/basket.interface.ts +360 -0
- package/core/interface/bootstrap.interface.ts +39 -0
- package/core/interface/context.interface.ts +9 -0
- package/core/interface/inventory.interface.ts +88 -0
- package/core/interface/nexine.interface.ts +4 -0
- package/core/interface/prisma.interface.ts +8844 -0
- package/core/interface/product.interface.ts +111 -0
- package/core/raxon.context.tsx +256 -0
- package/core/schema/checkout.schema.ts +103 -0
- package/core/util/basket.item.display.ts +19 -0
- package/core/util/category.nav.ts +46 -0
- package/core/util/client-ip.ts +35 -0
- package/core/util/collection.util.ts +433 -0
- package/core/util/fetch.bootstrap.ts +21 -0
- package/core/util/garanti-payment.ts +5 -0
- package/core/util/nexine.axios.tsx +104 -0
- package/core/util/no-cache.ts +6 -0
- package/core/util/util.ts +191 -0
- package/core/view/view.checkout.tsx +1964 -0
- package/dist/core/view/view.checkout.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -3
- package/tailwind.css +11 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Dictionary, WeightType } from "../interface/prisma.interface";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
String.prototype.toTry = function () {
|
|
5
|
+
return Number(this).toTry();
|
|
6
|
+
};
|
|
7
|
+
String.prototype.storageUrl = function () {
|
|
8
|
+
return `${process.env.NEXT_PUBLIC_STORAGE_URL}/${this}`;
|
|
9
|
+
};
|
|
10
|
+
String.prototype.letterInitial = function () {
|
|
11
|
+
return this.substring(0, 2).toUpperCase();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
String.prototype.weightTypeToText = function (): string {
|
|
15
|
+
if (this == WeightType.GR) return "gr";
|
|
16
|
+
if (this == WeightType.ML) return "ml";
|
|
17
|
+
if (this == WeightType.PIECE) return "adet";
|
|
18
|
+
return "---";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Number.prototype.toTry = function () {
|
|
22
|
+
return this.toLocaleString('tr-TR', {
|
|
23
|
+
style: 'currency',
|
|
24
|
+
currency: 'TRY',
|
|
25
|
+
minimumFractionDigits: 2,
|
|
26
|
+
maximumFractionDigits: 2,
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Date.prototype.ddMMyyyy = function () {
|
|
31
|
+
return this.toLocaleDateString('tr-TR', {
|
|
32
|
+
day: '2-digit',
|
|
33
|
+
month: '2-digit',
|
|
34
|
+
year: 'numeric'
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
String.prototype.ddMMyyyy = function () {
|
|
38
|
+
return new Date(this.toString()).toLocaleDateString('tr-TR', {
|
|
39
|
+
day: '2-digit',
|
|
40
|
+
month: '2-digit',
|
|
41
|
+
year: 'numeric'
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Array.prototype.getName = function (this: Array<Dictionary>): string {
|
|
47
|
+
|
|
48
|
+
var selectedLanguage = 'TR';
|
|
49
|
+
|
|
50
|
+
if (this.length > 0) {
|
|
51
|
+
var findGerman = this.find(item => item.language === 'DE');
|
|
52
|
+
var findTurkish = this.find(item => item.language === 'TR');
|
|
53
|
+
var findEnglish = this.find(item => item.language === 'EN');
|
|
54
|
+
|
|
55
|
+
var findSelectedLanguage = this.find(item => item.language.toLowerCase() === selectedLanguage.toLowerCase());
|
|
56
|
+
|
|
57
|
+
if (findSelectedLanguage) {
|
|
58
|
+
return findSelectedLanguage.value ?? findSelectedLanguage.name;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (findGerman) {
|
|
62
|
+
return findGerman.value ?? findGerman.name;
|
|
63
|
+
}
|
|
64
|
+
if (findTurkish) {
|
|
65
|
+
return findTurkish.value ?? findTurkish.name;
|
|
66
|
+
}
|
|
67
|
+
if (findEnglish) {
|
|
68
|
+
return findEnglish.value ?? findEnglish.name;
|
|
69
|
+
}
|
|
70
|
+
return this[0].value ?? this[0].value;
|
|
71
|
+
}
|
|
72
|
+
return '----';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Array.prototype.getSlug = function (this: Array<Dictionary>): string {
|
|
76
|
+
|
|
77
|
+
var selectedLanguage = 'TR';
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if (this.length > 0) {
|
|
81
|
+
var findGerman = this.find(item => item.language === 'DE');
|
|
82
|
+
var findTurkish = this.find(item => item.language === 'TR');
|
|
83
|
+
var findEnglish = this.find(item => item.language === 'EN');
|
|
84
|
+
|
|
85
|
+
var dt = {
|
|
86
|
+
"de": findGerman,
|
|
87
|
+
"tr": findTurkish,
|
|
88
|
+
"en": findEnglish
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var find = dt[selectedLanguage as keyof typeof dt];
|
|
93
|
+
|
|
94
|
+
if (find) {
|
|
95
|
+
return find.slug ?? find.value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (findGerman) {
|
|
99
|
+
return findGerman.slug ?? findGerman.value;
|
|
100
|
+
}
|
|
101
|
+
if (findTurkish) {
|
|
102
|
+
return findTurkish.slug ?? findTurkish.value;
|
|
103
|
+
}
|
|
104
|
+
if (findEnglish) {
|
|
105
|
+
return findEnglish.slug ?? findEnglish.value;
|
|
106
|
+
}
|
|
107
|
+
return this[0].slug ?? this[0].value;
|
|
108
|
+
}
|
|
109
|
+
return '----';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Global Event Emitter sistemi
|
|
113
|
+
class GlobalEventEmitter {
|
|
114
|
+
private events: { [key: string]: Function[] } = {};
|
|
115
|
+
|
|
116
|
+
// Event dinleyici ekle
|
|
117
|
+
on(event: string, callback: Function) {
|
|
118
|
+
if (!this.events[event]) {
|
|
119
|
+
this.events[event] = [];
|
|
120
|
+
}
|
|
121
|
+
this.events[event].push(callback);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Event dinleyici kaldır
|
|
125
|
+
off(event: string, callback: Function) {
|
|
126
|
+
if (!this.events[event]) return;
|
|
127
|
+
this.events[event] = this.events[event].filter(cb => cb !== callback);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Event tetikle
|
|
131
|
+
emit(event: string, data?: any) {
|
|
132
|
+
if (!this.events[event]) return;
|
|
133
|
+
this.events[event].forEach(callback => callback(data));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Tüm dinleyicileri temizle
|
|
137
|
+
clear(event?: string) {
|
|
138
|
+
if (event) {
|
|
139
|
+
delete this.events[event];
|
|
140
|
+
} else {
|
|
141
|
+
this.events = {};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Global emitter instance
|
|
147
|
+
export const globalEmitter = new GlobalEventEmitter();
|
|
148
|
+
|
|
149
|
+
// Event türleri
|
|
150
|
+
export const GLOBAL_EVENTS = {
|
|
151
|
+
SHOW_LOGIN_MODAL: 'show_login_modal',
|
|
152
|
+
HIDE_LOGIN_MODAL: 'hide_login_modal',
|
|
153
|
+
UNAUTHORIZED_ERROR: 'unauthorized_error',
|
|
154
|
+
TOKEN_EXPIRED: 'token_expired',
|
|
155
|
+
} as const;
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
export const cn = (...inputs: any[]) => {
|
|
159
|
+
return inputs.filter(Boolean).join(" ");
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const getSafeImageUrl = (path: string | undefined, type: 'product' | 'category' | 'brand' | 'banner' = 'product') => {
|
|
163
|
+
let storageUrl = process.env.NEXT_PUBLIC_STORAGE_URL || 'https://cdn.bonero.tr';
|
|
164
|
+
|
|
165
|
+
if (storageUrl.startsWith('http://cdn.bonero.tr')) {
|
|
166
|
+
storageUrl = storageUrl.replace('http://', 'https://');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!path || path === 'null' || path === 'undefined') {
|
|
170
|
+
if (type === 'product') return 'https://placehold.co/400x600?text=Urun+Gorseli';
|
|
171
|
+
if (type === 'category') return 'https://placehold.co/300x300?text=Kategori';
|
|
172
|
+
if (type === 'brand') return 'https://placehold.co/200x100?text=Marka';
|
|
173
|
+
return 'https://placehold.co/800x400?text=Banner';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (path.startsWith('http')) {
|
|
177
|
+
return path.replace('http://', 'https://');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Yerel dosyalar (public klasörü altındakiler) için storage URL ekleme
|
|
181
|
+
if (path.startsWith('/images/') || path.startsWith('/logo/')) {
|
|
182
|
+
return path;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const cleanPath = path.startsWith('/') ? path.substring(1) : path;
|
|
186
|
+
const finalPath = (storageUrl.endsWith('/bonero') && cleanPath.startsWith('bonero/'))
|
|
187
|
+
? cleanPath.replace('bonero/', '')
|
|
188
|
+
: cleanPath;
|
|
189
|
+
|
|
190
|
+
return `${storageUrl}/${finalPath}`;
|
|
191
|
+
};
|