@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,122 @@
|
|
|
1
|
+
import { nexineAxios } from "@/core/util/nexine.axios";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
// Auth event'leri için custom eventler
|
|
4
|
+
export const LOGOUT_EVENT = 'intermarkt-logout';
|
|
5
|
+
export const LOGIN_SUCCESS_EVENT = 'intermarkt-login-success';
|
|
6
|
+
export const useAuth = () => {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
return {
|
|
9
|
+
profile: ({ isEnabled = false }) => {
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: ["profile"],
|
|
12
|
+
enabled: isEnabled,
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
var response = await nexineAxios.get('/customer/profile');
|
|
15
|
+
return response.data.data;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
token: () => {
|
|
20
|
+
return useMutation({
|
|
21
|
+
mutationFn: async () => {
|
|
22
|
+
var response = await nexineAxios.get('/auth/token');
|
|
23
|
+
return response.data.data;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
loginEmail: () => {
|
|
28
|
+
return useMutation({
|
|
29
|
+
mutationFn: (data) => {
|
|
30
|
+
return nexineAxios.post('/auth/login/email', data);
|
|
31
|
+
},
|
|
32
|
+
onSuccess: (response) => {
|
|
33
|
+
localStorage.setItem("koksal-token", response.data.token);
|
|
34
|
+
queryClient.invalidateQueries({ queryKey: ["user"] });
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: ["profile"] });
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: ["cart"] });
|
|
37
|
+
// Login success event'ini tetikle
|
|
38
|
+
if (typeof window !== 'undefined') {
|
|
39
|
+
window.dispatchEvent(new Event(LOGIN_SUCCESS_EVENT));
|
|
40
|
+
window.dispatchEvent(new Event('koksal-token-changed'));
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
loginGuest: () => {
|
|
46
|
+
return useMutation({
|
|
47
|
+
mutationFn: () => {
|
|
48
|
+
return nexineAxios.post('/auth/login/guest');
|
|
49
|
+
},
|
|
50
|
+
onSuccess: (response) => {
|
|
51
|
+
localStorage.setItem("koksal-token", response.data.token);
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: ["user"] });
|
|
53
|
+
queryClient.invalidateQueries({ queryKey: ["profile"] });
|
|
54
|
+
queryClient.invalidateQueries({ queryKey: ["cart"] });
|
|
55
|
+
// Login success event'ini tetikle
|
|
56
|
+
if (typeof window !== 'undefined') {
|
|
57
|
+
window.dispatchEvent(new Event(LOGIN_SUCCESS_EVENT));
|
|
58
|
+
window.dispatchEvent(new Event('koksal-token-changed'));
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
loginSocial: () => {
|
|
64
|
+
return useMutation({
|
|
65
|
+
mutationFn: async (data) => {
|
|
66
|
+
var response = await nexineAxios.get(`/auth/login/social`, { params: { platform: data.platform, returnUrl: data.returnUrl } });
|
|
67
|
+
return response.data.url;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
register: () => {
|
|
72
|
+
return useMutation({
|
|
73
|
+
mutationFn: (data) => {
|
|
74
|
+
return nexineAxios.post('/auth/register', data);
|
|
75
|
+
},
|
|
76
|
+
onSuccess: () => {
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
// Şifremi unuttum - E-posta gönderme
|
|
81
|
+
codeSend: () => {
|
|
82
|
+
return useMutation({
|
|
83
|
+
mutationFn: (data) => {
|
|
84
|
+
return nexineAxios.post('/auth/code-send', data);
|
|
85
|
+
},
|
|
86
|
+
onSuccess: () => {
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
// Doğrulama kodu kontrol etme
|
|
91
|
+
verifyCode: () => {
|
|
92
|
+
return useMutation({
|
|
93
|
+
mutationFn: (data) => {
|
|
94
|
+
return nexineAxios.post('/auth/code-verify', data);
|
|
95
|
+
},
|
|
96
|
+
onSuccess: () => {
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
// Şifre sıfırlama
|
|
101
|
+
resetPassword: () => {
|
|
102
|
+
return useMutation({
|
|
103
|
+
mutationFn: (data) => {
|
|
104
|
+
return nexineAxios.post('/auth/reset-password', data);
|
|
105
|
+
},
|
|
106
|
+
onSuccess: () => {
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
logout: () => {
|
|
111
|
+
localStorage.removeItem("koksal-token");
|
|
112
|
+
queryClient.invalidateQueries({ queryKey: ["user"] });
|
|
113
|
+
queryClient.invalidateQueries({ queryKey: ["profile"] });
|
|
114
|
+
// Logout event'ini tetikle
|
|
115
|
+
if (typeof window !== 'undefined') {
|
|
116
|
+
window.dispatchEvent(new Event(LOGOUT_EVENT));
|
|
117
|
+
window.dispatchEvent(new Event('koksal-token-changed'));
|
|
118
|
+
window.location.reload();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ModalAuthProps {
|
|
3
|
+
}
|
|
4
|
+
export interface ModalAuthRef {
|
|
5
|
+
open: (defaultTab?: 'login' | 'register', queries?: any) => void;
|
|
6
|
+
close: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ModalAuth: React.ForwardRefExoticComponent<ModalAuthProps & React.RefAttributes<ModalAuthRef>>;
|
|
9
|
+
//# sourceMappingURL=modal.auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.auth.d.ts","sourceRoot":"","sources":["../../../../../core/feature/auth/modal/modal.auth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAUtE,MAAM,WAAW,cAAc;CAAG;AAClC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,UAAU,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACjE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,qFA+DpB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useImperativeHandle, useMemo, useState } from 'react';
|
|
3
|
+
import { Modal } from 'rizzui';
|
|
4
|
+
import { X } from 'lucide-react';
|
|
5
|
+
import ViewLogin from '@/core/feature/auth/view/view.login';
|
|
6
|
+
import ViewRegister from '@/core/feature/auth/view/view.register';
|
|
7
|
+
import { useRaxon } from '@/core/raxon.context';
|
|
8
|
+
import { GeneralImage } from '@/core/component/general.image';
|
|
9
|
+
import { usePathname } from 'next/navigation';
|
|
10
|
+
import queryString from 'query-string';
|
|
11
|
+
export const ModalAuth = React.forwardRef((props, ref) => {
|
|
12
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
13
|
+
const [activeTab, setActiveTab] = useState('login');
|
|
14
|
+
const [queries, setQueries] = useState({});
|
|
15
|
+
const { branch } = useRaxon();
|
|
16
|
+
const pathname = usePathname();
|
|
17
|
+
const returnUrl = useMemo(() => {
|
|
18
|
+
return queryString.stringify(queries);
|
|
19
|
+
}, [pathname, queries]);
|
|
20
|
+
useImperativeHandle(ref, () => ({
|
|
21
|
+
open: (defaultTab = 'login', queries) => {
|
|
22
|
+
setActiveTab(defaultTab);
|
|
23
|
+
setQueries(queries ?? {});
|
|
24
|
+
setIsOpen(true);
|
|
25
|
+
},
|
|
26
|
+
close: () => {
|
|
27
|
+
setIsOpen(false);
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
const handleClose = () => {
|
|
31
|
+
setIsOpen(false);
|
|
32
|
+
};
|
|
33
|
+
return (_jsx(Modal, { isOpen: isOpen, onClose: handleClose, customSize: 400, overlayClassName: "backdrop-blur-sm", children: _jsxs("div", { className: "relative bg-white rounded-lg shadow-2xl", children: [_jsx("button", { onClick: handleClose, className: "absolute top-4 right-4 p-2 text-gray-400 hover:text-gray-600 transition-colors z-10", children: _jsx(X, { className: "w-5 h-5" }) }), _jsxs("div", { className: "text-center pt-8 pb-6 px-8", children: [_jsx("div", { className: "flex justify-center mb-4", children: _jsx(GeneralImage, { quality: 85, src: branch?.logoMedia?.relativePath ? `${process.env.NEXT_PUBLIC_STORAGE_URL}/${branch?.logoMedia?.relativePath}` : '', alt: "logo", width: 180, height: 40, className: "h-8 w-auto object-contain" }) }), _jsx("p", { className: "text-black/80 text-sm font-light uppercase tracking-wider", children: activeTab === 'login' ? 'Hesabınıza giriş yapın' : 'Yeni hesap oluşturun' })] }), _jsxs("div", { className: "flex border-b border-black/10 mx-8", children: [_jsx("button", { onClick: () => setActiveTab('login'), className: `flex-1 py-3 text-sm font-black uppercase tracking-wider transition-colors border-b-2 ${activeTab === 'login' ? 'border-black text-black' : 'border-transparent text-black/80 hover:text-black'}`, children: "Giri\u015F Yap" }), _jsx("button", { onClick: () => setActiveTab('register'), className: `flex-1 py-3 text-sm font-black uppercase tracking-wider transition-colors border-b-2 ${activeTab === 'register' ? 'border-black text-black' : 'border-transparent text-black/80 hover:text-black'}`, children: "Kay\u0131t Ol" })] }), _jsxs("div", { className: "p-8", children: [activeTab === 'login' && _jsx(ViewLogin, { onClose: handleClose, returnUrl: returnUrl }), activeTab === 'register' && _jsx(ViewRegister, { onClose: handleClose, onSwitchToLogin: () => setActiveTab('login') })] })] }) }));
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.login.d.ts","sourceRoot":"","sources":["../../../../../core/feature/auth/view/view.login.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,cAAc,qBAwLvE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Eye, EyeOff } from 'lucide-react';
|
|
5
|
+
import { useAuth } from '@/core/feature/auth/hook/use.auth';
|
|
6
|
+
import { useForm } from 'react-hook-form';
|
|
7
|
+
import toast from 'react-hot-toast';
|
|
8
|
+
export default function ViewLogin({ onClose, returnUrl }) {
|
|
9
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
10
|
+
const { mutate: login } = useAuth().loginEmail();
|
|
11
|
+
const { mutate: loginGuest } = useAuth().loginGuest();
|
|
12
|
+
const { mutate: loginSocial } = useAuth().loginSocial();
|
|
13
|
+
const form = useForm();
|
|
14
|
+
const handleSubmitGuest = (e) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
loginGuest({}, {
|
|
17
|
+
onSuccess: () => {
|
|
18
|
+
onClose?.();
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const handleLoginSocial = (provider) => {
|
|
23
|
+
loginSocial({ platform: provider, returnUrl: returnUrl }, {
|
|
24
|
+
onSuccess: (url) => {
|
|
25
|
+
if (typeof window !== 'undefined') {
|
|
26
|
+
window.location.href = url;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const handleSubmit = (e) => {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
form.handleSubmit(data => {
|
|
34
|
+
login(data, {
|
|
35
|
+
onSuccess: () => {
|
|
36
|
+
onClose?.();
|
|
37
|
+
},
|
|
38
|
+
onError: (error) => {
|
|
39
|
+
toast.error(error?.response?.data?.info?.title || 'Giriş başarısız');
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
})();
|
|
43
|
+
};
|
|
44
|
+
return (_jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [_jsx("div", { children: _jsx("input", { type: "email", ...form.register('email'), placeholder: "E-posta adresinizi girin *", className: "w-full px-0 py-5 text-lg font-medium border-0 border-b-2 border-gray-300 bg-transparent focus:outline-none focus:border-black transition-colors placeholder-gray-500", required: true }) }), _jsxs("div", { className: "relative", children: [_jsx("input", { type: showPassword ? 'text' : 'password', ...form.register('password'), placeholder: "\u015Eifre *", className: "w-full px-0 py-5 pr-10 text-lg font-medium border-0 border-b-2 border-gray-300 bg-transparent focus:outline-none focus:border-black transition-colors placeholder-gray-500", required: true }), _jsx("button", { type: "button", className: "absolute right-0 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600", onClick: () => setShowPassword(!showPassword), children: showPassword ? _jsx(EyeOff, { className: "w-5 h-5" }) : _jsx(Eye, { className: "w-5 h-5" }) })] }), _jsxs("div", { className: "flex items-center justify-between py-4", children: [_jsxs("div", { className: "flex items-center", children: [_jsx("input", { id: "remember", type: "checkbox", ...form.register('rememberMe'), className: "w-4 h-4 text-black border-gray-300 rounded focus:ring-0" }), _jsx("label", { htmlFor: "remember", className: "ml-2 text-base font-medium text-gray-700", children: "Beni hat\u0131rla" })] }), _jsx("button", { type: "button", onClick: onClose, className: "text-base font-medium text-gray-600 hover:text-black transition-colors", children: "\u015Eifrenizi mi unuttunuz?" })] }), _jsxs("div", { className: "py-6", children: [_jsxs("div", { className: "flex items-center mb-6", children: [_jsx("div", { className: "flex-1 border-t border-gray-200" }), _jsx("span", { className: "px-4 text-base font-medium text-gray-500", children: "Veya sosyal hesapla devam edin" }), _jsx("div", { className: "flex-1 border-t border-gray-200" })] }), _jsxs("div", { className: "flex flex-col sm:grid sm:grid-cols-2 gap-4", children: [_jsxs("button", { type: "button", onClick: () => handleLoginSocial('google'), className: "py-4 text-base font-medium border border-gray-200 hover:border-black transition-colors flex items-center justify-center space-x-2", children: [_jsx("svg", { width: "20", height: "20", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsxs("g", { clipPath: "url(#clip0_278_6045)", children: [_jsx("path", { d: "M21.6696 9.08832L12.696 9.08789C12.2997 9.08789 11.9785 9.40904 11.9785 9.8053V12.672C11.9785 13.0681 12.2997 13.3894 12.6959 13.3894H17.7493C17.196 14.8254 16.1632 16.0281 14.8455 16.7922L17.0002 20.5223C20.4567 18.5233 22.5002 15.0158 22.5002 11.0894C22.5002 10.5303 22.459 10.1307 22.3766 9.68064C22.314 9.33874 22.0171 9.08832 21.6696 9.08832Z", fill: "#167EE6" }), _jsx("path", { d: "M11.4999 17.6964C9.02689 17.6964 6.86797 16.3452 5.70846 14.3457L1.97852 16.4956C3.87666 19.7854 7.4325 22.0007 11.4999 22.0007C13.4953 22.0007 15.378 21.4635 16.9999 20.5272V20.5221L14.8452 16.792C13.8595 17.3637 12.719 17.6964 11.4999 17.6964Z", fill: "#12B347" }), _jsx("path", { d: "M17 20.5262V20.5211L14.8452 16.791C13.8596 17.3626 12.7192 17.6954 11.5 17.6954V21.9997C13.4953 21.9997 15.3782 21.4625 17 20.5262Z", fill: "#0F993E" }), _jsx("path", { d: "M4.80435 11.0007C4.80435 9.78177 5.13702 8.64133 5.70854 7.65576L1.9786 5.50586C1.0372 7.12264 0.5 9.00029 0.5 11.0007C0.5 13.0012 1.0372 14.8788 1.9786 16.4956L5.70854 14.3457C5.13702 13.3602 4.80435 12.2197 4.80435 11.0007Z", fill: "#FFD500" }), _jsx("path", { d: "M11.4999 4.30435C13.1126 4.30435 14.5939 4.87738 15.7509 5.83056C16.0363 6.06568 16.4512 6.04871 16.7127 5.78725L18.7438 3.75611C19.0405 3.45946 19.0193 2.97387 18.7024 2.69895C16.7639 1.0172 14.2416 0 11.4999 0C7.4325 0 3.87666 2.21534 1.97852 5.50511L5.70846 7.65501C6.86797 5.65555 9.02689 4.30435 11.4999 4.30435Z", fill: "#FF4B26" }), _jsx("path", { d: "M15.751 5.83056C16.0364 6.06568 16.4513 6.04871 16.7128 5.78725L18.7439 3.75611C19.0405 3.45946 19.0194 2.97387 18.7025 2.69895C16.764 1.01716 14.2417 0 11.5 0V4.30435C13.1126 4.30435 14.594 4.87738 15.751 5.83056Z", fill: "#D93F21" })] }) }), _jsx("span", { className: "text-sm sm:text-base", children: "Google ile giri\u015F yap" })] }), _jsxs("button", { type: "button", onClick: () => handleLoginSocial('facebook'), className: "py-4 text-base font-medium border border-gray-200 hover:border-black transition-colors flex items-center justify-center space-x-2", children: [_jsx("svg", { width: "20", height: "20", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsxs("g", { clipPath: "url(#clip0_278_6055)", children: [_jsx("path", { d: "M22.5 11C22.5 16.4905 18.4773 21.0414 13.2188 21.8664V14.1797H15.7818L16.2695 11H13.2188V8.93664C13.2188 8.06652 13.645 7.21875 15.0114 7.21875H16.3984V4.51172C16.3984 4.51172 15.1395 4.29688 13.9359 4.29688C11.4235 4.29688 9.78125 5.81969 9.78125 8.57656V11H6.98828V14.1797H9.78125V21.8664C4.52273 21.0414 0.5 16.4905 0.5 11C0.5 4.92508 5.42508 0 11.5 0C17.5749 0 22.5 4.92508 22.5 11Z", fill: "#1877F2" }), _jsx("path", { d: "M15.7818 14.1797L16.2695 11H13.2188V8.9366C13.2188 8.0667 13.6449 7.21875 15.0114 7.21875H16.3984V4.51172C16.3984 4.51172 15.1396 4.29688 13.9361 4.29688C11.4235 4.29688 9.78125 5.81969 9.78125 8.57656V11H6.98828V14.1797H9.78125V21.8663C10.3413 21.9542 10.9153 22 11.5 22C12.0847 22 12.6587 21.9542 13.2188 21.8663V14.1797H15.7818Z", fill: "white" })] }) }), _jsx("span", { className: "text-sm sm:text-base", children: "Facebook ile giri\u015F yap" })] })] })] }), _jsx("button", { onClick: handleSubmitGuest, type: "button", className: "w-full py-4 text-base font-medium hover:text-black transition-colors", children: "Misafir Olarak Devam Et" }), _jsx("button", { id: "btnLogin", type: "submit", className: "w-full py-5 text-lg font-bold bg-black text-white hover:bg-gray-800 transition-colors", children: "Giri\u015F Yap" }), _jsx("div", { className: "text-center", children: _jsxs("p", { className: "text-sm font-medium text-gray-500 leading-relaxed", children: ["Devam ederek", ' ', _jsx("button", { type: "button", onClick: onClose, className: "hover:underline", children: "Kullan\u0131m \u015Eartlar\u0131" }), ' ', "ve", ' ', _jsx("button", { type: "button", onClick: onClose, className: "hover:underline", children: "Gizlilik Politikas\u0131" }), "'n\u0131 kabul etmi\u015F olursunuz."] }) })] }));
|
|
45
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ViewRegisterProps {
|
|
3
|
+
onClose?: () => void;
|
|
4
|
+
onSwitchToLogin?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export default function ViewRegister({ onClose, onSwitchToLogin }: ViewRegisterProps): React.JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=view.register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.register.d.ts","sourceRoot":"","sources":["../../../../../core/feature/auth/view/view.register.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAuDxC,UAAU,iBAAiB;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,iBAAiB,qBA+QnF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Eye, EyeOff, Lock, Mail, User, Phone, ArrowRight } from 'lucide-react';
|
|
5
|
+
import { useAuth } from '@/core/feature/auth/hook/use.auth';
|
|
6
|
+
import { useRouter } from 'next/navigation';
|
|
7
|
+
import { useForm } from 'react-hook-form';
|
|
8
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import toast from 'react-hot-toast';
|
|
11
|
+
// Türk telefon numarası regex'i - 0 ile başlayan 11 haneli veya 5 ile başlayan 10 haneli
|
|
12
|
+
const turkishPhoneRegex = /^(\+90[5-9][0-9]{9}|0[5-9][0-9]{9}|[5-9][0-9]{8})$/;
|
|
13
|
+
// Zod validation şeması
|
|
14
|
+
const registerSchema = z.object({
|
|
15
|
+
firstName: z.string()
|
|
16
|
+
.min(1, 'Ad alanı zorunludur')
|
|
17
|
+
.min(2, 'Ad en az 2 karakter olmalıdır')
|
|
18
|
+
.max(50, 'Ad en fazla 50 karakter olabilir')
|
|
19
|
+
.regex(/^[a-zA-ZçğıöşüÇĞIİÖŞÜ\s]+$/, 'Ad sadece harf içerebilir'),
|
|
20
|
+
lastName: z.string()
|
|
21
|
+
.min(1, 'Soyad alanı zorunludur')
|
|
22
|
+
.min(2, 'Soyad en az 2 karakter olmalıdır')
|
|
23
|
+
.max(50, 'Soyad en fazla 50 karakter olabilir')
|
|
24
|
+
.regex(/^[a-zA-ZçğıöşüÇĞIİÖŞÜ\s]+$/, 'Soyad sadece harf içerebilir'),
|
|
25
|
+
email: z.string()
|
|
26
|
+
.min(1, 'E-posta alanı zorunludur')
|
|
27
|
+
.email('Geçerli bir e-posta adresi giriniz')
|
|
28
|
+
.max(100, 'E-posta adresi çok uzun'),
|
|
29
|
+
phone: z.string()
|
|
30
|
+
.min(1, 'Telefon numarası zorunludur')
|
|
31
|
+
.regex(turkishPhoneRegex, 'Geçerli bir Türk telefon numarası giriniz (örn: +905551234567)')
|
|
32
|
+
.transform((val) => val.replace(/\s/g, '')), // Boşlukları temizle
|
|
33
|
+
password: z.string()
|
|
34
|
+
.min(1, 'Şifre alanı zorunludur')
|
|
35
|
+
.min(6, 'Şifre en az 6 karakter olmalıdır')
|
|
36
|
+
.max(100, 'Şifre çok uzun'),
|
|
37
|
+
confirmPassword: z.string()
|
|
38
|
+
.min(1, 'Şifre tekrarı zorunludur'),
|
|
39
|
+
acceptTerms: z.boolean()
|
|
40
|
+
.refine((val) => val === true, 'Kullanım şartlarını kabul etmelisiniz'),
|
|
41
|
+
acceptMarketing: z.boolean().optional()
|
|
42
|
+
}).refine((data) => data.password === data.confirmPassword, {
|
|
43
|
+
message: 'Şifreler eşleşmiyor',
|
|
44
|
+
path: ['confirmPassword']
|
|
45
|
+
});
|
|
46
|
+
export default function ViewRegister({ onClose, onSwitchToLogin }) {
|
|
47
|
+
const router = useRouter();
|
|
48
|
+
const { register: authRegister } = useAuth();
|
|
49
|
+
const registerMutation = authRegister();
|
|
50
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
51
|
+
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
|
52
|
+
const { register, handleSubmit, formState: { errors, isSubmitting }, } = useForm({
|
|
53
|
+
resolver: zodResolver(registerSchema),
|
|
54
|
+
defaultValues: {
|
|
55
|
+
firstName: '',
|
|
56
|
+
lastName: '',
|
|
57
|
+
email: '',
|
|
58
|
+
phone: '',
|
|
59
|
+
password: '',
|
|
60
|
+
confirmPassword: '',
|
|
61
|
+
acceptTerms: false,
|
|
62
|
+
acceptMarketing: false
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const onSubmit = async (data) => {
|
|
66
|
+
registerMutation.mutate({
|
|
67
|
+
firstName: data.firstName,
|
|
68
|
+
lastName: data.lastName,
|
|
69
|
+
email: data.email,
|
|
70
|
+
phone: data.phone,
|
|
71
|
+
password: data.password,
|
|
72
|
+
acceptMarketing: data.acceptMarketing || false
|
|
73
|
+
}, {
|
|
74
|
+
onSuccess: () => {
|
|
75
|
+
onSwitchToLogin?.();
|
|
76
|
+
},
|
|
77
|
+
onError: (e) => {
|
|
78
|
+
toast.error(e.response?.data?.info?.title || 'Kayıt başarısız');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return (_jsxs("form", { onSubmit: handleSubmit(onSubmit), className: "space-y-6", children: [_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative", children: [_jsx(User, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: "text", ...register('firstName'), placeholder: "Ad\u0131n\u0131z", className: `w-full pl-10 pr-4 py-3 text-sm border rounded-sm focus:outline-none transition-colors ${errors.firstName ? 'border-red-500' : 'border-gray-200 focus:border-black'}` })] }), errors.firstName && (_jsx("p", { className: "mt-1 text-xs text-red-500", children: errors.firstName.message }))] }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative", children: [_jsx(User, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: "text", ...register('lastName'), placeholder: "Soyad\u0131n\u0131z", className: `w-full pl-10 pr-4 py-3 text-sm border rounded-sm focus:outline-none transition-colors ${errors.lastName ? 'border-red-500' : 'border-gray-200 focus:border-black'}` })] }), errors.lastName && (_jsx("p", { className: "mt-1 text-xs text-red-500", children: errors.lastName.message }))] })] }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative", children: [_jsx(Mail, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: "email", ...register('email'), placeholder: "E-posta adresiniz", className: `w-full pl-10 pr-4 py-3 text-sm border rounded-sm focus:outline-none transition-colors ${errors.email ? 'border-red-500' : 'border-gray-200 focus:border-black'}` })] }), errors.email && (_jsx("p", { className: "mt-1 text-xs text-red-500", children: errors.email.message }))] }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative", children: [_jsx(Phone, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: "tel", ...register('phone'), placeholder: "Telefon numaran\u0131z (\u00F6rn: 05551234567)", className: `w-full pl-10 pr-4 py-3 text-sm border rounded-sm focus:outline-none transition-colors ${errors.phone ? 'border-red-500' : 'border-gray-200 focus:border-black'}` })] }), errors.phone && (_jsx("p", { className: "mt-1 text-xs text-red-500", children: errors.phone.message }))] }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative", children: [_jsx(Lock, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: showPassword ? "text" : "password", ...register('password'), placeholder: "\u015Eifreniz (en az 6 karakter, b\u00FCy\u00FCk/k\u00FC\u00E7\u00FCk harf ve rakam)", className: `w-full pl-10 pr-12 py-3 text-sm border rounded-sm focus:outline-none transition-colors ${errors.password ? 'border-red-500' : 'border-gray-200 focus:border-black'}` }), _jsx("button", { type: "button", onClick: () => setShowPassword(!showPassword), className: "absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors", children: showPassword ? (_jsx(EyeOff, { className: "w-4 h-4" })) : (_jsx(Eye, { className: "w-4 h-4" })) })] }), errors.password && (_jsx("p", { className: "mt-1 text-xs text-red-500", children: errors.password.message }))] }), _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative", children: [_jsx(Lock, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: showConfirmPassword ? "text" : "password", ...register('confirmPassword'), placeholder: "\u015Eifrenizi tekrar giriniz", className: `w-full pl-10 pr-12 py-3 text-sm border rounded-sm focus:outline-none transition-colors ${errors.confirmPassword ? 'border-red-500' : 'border-gray-200 focus:border-black'}` }), _jsx("button", { type: "button", onClick: () => setShowConfirmPassword(!showConfirmPassword), className: "absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors", children: showConfirmPassword ? (_jsx(EyeOff, { className: "w-4 h-4" })) : (_jsx(Eye, { className: "w-4 h-4" })) })] }), errors.confirmPassword && (_jsx("p", { className: "mt-1 text-xs text-red-500", children: errors.confirmPassword.message }))] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-start", children: [_jsx("input", { type: "checkbox", ...register('acceptTerms'), className: "w-4 h-4 text-black border-gray-300 rounded focus:ring-0 focus:ring-offset-0 mt-0.5" }), _jsxs("label", { className: "ml-2 text-sm text-gray-600 font-light", children: [_jsx("button", { type: "button", onClick: onClose, className: "text-black hover:underline", children: "Kullan\u0131m \u015Eartlar\u0131" }), ' ', "ve", ' ', _jsx("button", { type: "button", onClick: onClose, className: "text-black hover:underline", children: "Gizlilik Politikas\u0131" }), "'n\u0131 okudum ve kabul ediyorum. *"] })] }), errors.acceptTerms && (_jsx("p", { className: "text-xs text-red-500 ml-6", children: errors.acceptTerms.message })), _jsxs("div", { className: "flex items-start", children: [_jsx("input", { type: "checkbox", ...register('acceptMarketing'), className: "w-4 h-4 text-black border-gray-300 rounded focus:ring-0 focus:ring-offset-0 mt-0.5" }), _jsx("label", { className: "ml-2 text-sm text-gray-600 font-light", children: "Kampanya ve promosyon bilgilerini e-posta ile almak istiyorum." })] })] }), _jsxs("button", { type: "submit", disabled: isSubmitting || registerMutation.isPending, className: "w-full bg-black text-white py-3 rounded-sm hover:bg-gray-800 transition-colors duration-200 flex items-center justify-center space-x-2 group disabled:opacity-50 disabled:cursor-not-allowed", children: [_jsx("span", { className: "text-sm font-light uppercase tracking-wider", children: isSubmitting || registerMutation.isPending ? 'Kayıt Oluşturuluyor...' : 'Kayıt Ol' }), !isSubmitting && !registerMutation.isPending && (_jsx(ArrowRight, { className: "w-4 h-4 group-hover:translate-x-1 transition-transform" }))] }), _jsxs("div", { className: "my-8 flex items-center", children: [_jsx("div", { className: "flex-1 border-t border-gray-200" }), _jsx("span", { className: "px-4 text-xs text-gray-500 uppercase tracking-wider", children: "veya" }), _jsx("div", { className: "flex-1 border-t border-gray-200" })] }), _jsxs("div", { className: "space-y-3 hidden", children: [_jsxs("button", { type: "button", className: "w-full border border-gray-200 py-3 rounded-sm hover:bg-gray-50 transition-colors duration-200 flex items-center justify-center space-x-2", children: [_jsxs("svg", { className: "w-5 h-5", viewBox: "0 0 24 24", children: [_jsx("path", { fill: "#4285F4", d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }), _jsx("path", { fill: "#34A853", d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" }), _jsx("path", { fill: "#FBBC05", d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" }), _jsx("path", { fill: "#EA4335", d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" })] }), _jsx("span", { className: "text-sm font-light", children: "Google ile kay\u0131t ol" })] }), _jsxs("button", { type: "button", className: "w-full border border-gray-200 py-3 rounded-sm hover:bg-gray-50 transition-colors duration-200 flex items-center justify-center space-x-2", children: [_jsx("svg", { className: "w-5 h-5 text-blue-600", fill: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { d: "M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z" }) }), _jsx("span", { className: "text-sm font-light", children: "Facebook ile kay\u0131t ol" })] })] })] }));
|
|
83
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IData } from '@/core/interface/nexine.interface';
|
|
2
|
+
import { BankAccount, BankTransferCode } from '@/core/interface/prisma.interface';
|
|
3
|
+
export declare const useBankAccount: () => {
|
|
4
|
+
fetch: (opts?: {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
}) => import("@tanstack/react-query").UseQueryResult<NoInfer<IData<BankAccount>>, Error>;
|
|
7
|
+
createTransferCode: () => import("@tanstack/react-query").UseMutationResult<BankTransferCode, Error, {
|
|
8
|
+
amount: number;
|
|
9
|
+
bankAccountId: string;
|
|
10
|
+
}, unknown>;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=use.bank.account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.bank.account.d.ts","sourceRoot":"","sources":["../../../../../core/feature/bank-account/hook/use.bank.account.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAuBlF,eAAO,MAAM,cAAc;mBAER;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;;gBASG,MAAM;uBAAiB,MAAM;;CAUvE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { nexineAxios } from '@/core/util/nexine.axios';
|
|
2
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
3
|
+
async function fetchBankAccounts() {
|
|
4
|
+
const withTags = await nexineAxios.get('/customer/bank-account', {
|
|
5
|
+
params: {
|
|
6
|
+
isCompanySpecificVisible: true,
|
|
7
|
+
tags: ['WEB'],
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
const tagged = withTags.data?.data ?? [];
|
|
11
|
+
if (tagged.length > 0)
|
|
12
|
+
return withTags.data;
|
|
13
|
+
const fallback = await nexineAxios.get('/customer/bank-account', {
|
|
14
|
+
params: {
|
|
15
|
+
isCompanySpecificVisible: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return fallback.data;
|
|
19
|
+
}
|
|
20
|
+
export const useBankAccount = () => {
|
|
21
|
+
return {
|
|
22
|
+
fetch: (opts) => {
|
|
23
|
+
return useQuery({
|
|
24
|
+
queryKey: ['bank-account', 'web'],
|
|
25
|
+
queryFn: fetchBankAccounts,
|
|
26
|
+
enabled: opts?.enabled !== false,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
createTransferCode: () => {
|
|
30
|
+
return useMutation({
|
|
31
|
+
mutationFn: async (data) => {
|
|
32
|
+
const response = await nexineAxios.post('/customer/payment/bank-transfer', data);
|
|
33
|
+
return response.data.bankTransferCode;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BasketSummaryInterface } from '@/core/interface/basket.interface';
|
|
2
|
+
type CartOrderSummaryProps = {
|
|
3
|
+
cart: BasketSummaryInterface | null;
|
|
4
|
+
itemCount: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function CartOrderSummary({ cart, itemCount }: CartOrderSummaryProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=cart.order.summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart.order.summary.d.ts","sourceRoot":"","sources":["../../../../../core/feature/cart/component/cart.order.summary.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAUhF,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,qBAAqB,+BAsE1E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { CartPromoCodeSection } from '@/core/feature/cart/component/cart.promo.code.section';
|
|
5
|
+
const ShieldCheck = (props) => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: [_jsx("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" }), _jsx("polyline", { points: "9 12 11 14 15 10" })] }));
|
|
6
|
+
export function CartOrderSummary({ cart, itemCount }) {
|
|
7
|
+
return (_jsx("aside", { className: "lg:col-span-4 lg:sticky lg:top-28 self-start w-full", children: _jsxs("div", { className: "p-4 bg-white border border-gray-100 rounded-2xl space-y-4", children: [_jsxs("div", { className: "pb-1", children: [_jsx("h2", { className: "text-sm font-medium text-gray-900 uppercase tracking-[0.1em]", children: "Sipari\u015F \u00D6zeti" }), _jsxs("p", { className: "text-[10px] font-bold text-gray-400 uppercase tracking-widest mt-0.5", children: [itemCount, " \u00DCr\u00FCn"] })] }), _jsxs("div", { className: "space-y-2.5", children: [_jsxs("div", { className: "flex justify-between items-center text-sm", children: [_jsx("span", { className: "text-gray-500", children: "Ara Toplam" }), _jsxs("span", { className: "font-bold text-gray-900", children: ["\u20BA", (Number(cart?.info?.payPrice?.total) || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2 })] })] }), Number(cart?.info?.discount?.pay || 0) > 0 && (_jsxs("div", { className: "flex justify-between items-center text-sm", children: [_jsx("span", { className: "text-gray-500", children: "\u0130ndirim" }), _jsxs("span", { className: "font-bold text-green-600", children: ["-\u20BA", Number(cart?.info?.discount?.pay || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2 })] })] })), Number(cart?.info?.promotion?.pay || 0) > 0 && (_jsxs("div", { className: "flex justify-between items-center text-sm", children: [_jsx("span", { className: "text-gray-500", children: "Promosyon" }), _jsxs("span", { className: "font-bold text-green-600", children: ["-\u20BA", Number(cart?.info?.promotion?.pay || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2 })] })] })), _jsxs("div", { className: "flex justify-between items-center text-sm", children: [_jsx("span", { className: "text-gray-500", children: "KDV Dahil" }), _jsxs("span", { className: "font-bold text-gray-900", children: ["\u20BA", (Number(cart?.info?.payPrice?.tax) || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2 })] })] })] }), _jsx("div", { className: "pt-3 border-t border-gray-100", children: _jsx(CartPromoCodeSection, { variant: "cart" }) }), _jsxs("div", { className: "pt-3 border-t border-gray-100 space-y-4", children: [_jsxs("div", { className: "flex justify-between items-end gap-3", children: [_jsx("span", { className: "text-sm font-bold text-gray-900", children: "Toplam" }), _jsxs("span", { className: "text-xl font-light text-gray-900", children: ["\u20BA", (Number(cart?.info?.payPrice?.pay) || 0).toLocaleString('tr-TR', { minimumFractionDigits: 2 })] })] }), _jsx(Link, { href: "/odeme", className: "block w-full bg-black text-white py-4 rounded-full text-center text-[11px] font-black uppercase tracking-[0.2em] hover:bg-[#CF0A2C] transition-all duration-300", children: "\u00D6demeye Ge\u00E7" }), _jsxs("div", { className: "flex items-center justify-center gap-2 text-[9px] font-bold text-gray-400 uppercase tracking-widest", children: [_jsx(ShieldCheck, { className: "w-3.5 h-3.5 shrink-0" }), "G\u00FCvenli \u00D6deme"] })] })] }) }));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart.promo.code.section.d.ts","sourceRoot":"","sources":["../../../../../core/feature/cart/component/cart.promo.code.section.tsx"],"names":[],"mappings":"AA8BA,KAAK,yBAAyB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC/B,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EAAE,OAAgB,EAAE,EAAE,yBAAyB,+BA6KnF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { useCartContext } from '@/core/context/cart.context';
|
|
5
|
+
import { useCart } from '@/core/feature/cart/hook/use.cart';
|
|
6
|
+
import { usePromoCode } from '@/core/feature/promo-code/hook/use.promo.code';
|
|
7
|
+
import { Status } from '@/core/interface/prisma.interface';
|
|
8
|
+
const CheckCircle2 = (props) => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: [_jsx("path", { d: "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" }), _jsx("polyline", { points: "9 11 12 14 22 4" })] }));
|
|
9
|
+
const Loader2 = (props) => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: _jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) }));
|
|
10
|
+
const X = (props) => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }));
|
|
11
|
+
function formatTRY(amount) {
|
|
12
|
+
return new Intl.NumberFormat('tr-TR', { style: 'currency', currency: 'TRY', maximumFractionDigits: 0 }).format(amount);
|
|
13
|
+
}
|
|
14
|
+
export function CartPromoCodeSection({ variant = 'cart' }) {
|
|
15
|
+
const { cart, promoCode, setPromoCode } = useCartContext();
|
|
16
|
+
const { mutate: updateCart, isPending: isUpdatingCart } = useCart().update();
|
|
17
|
+
const { mutate: findPromoCode, isPending: isFindingPromoCode } = usePromoCode().findByCode();
|
|
18
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
19
|
+
const [promoInput, setPromoInput] = useState('');
|
|
20
|
+
const [error, setError] = useState(null);
|
|
21
|
+
const appliedCode = cart?.promoCode?.code ?? promoCode?.code;
|
|
22
|
+
const isApplied = Boolean(cart?.promoCode?.id ?? promoCode?.id);
|
|
23
|
+
const isLoading = isFindingPromoCode || isUpdatingCart;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (cart?.promoCode?.id) {
|
|
26
|
+
setPromoInput(cart.promoCode.code);
|
|
27
|
+
setIsOpen(true);
|
|
28
|
+
}
|
|
29
|
+
}, [cart?.promoCode?.id, cart?.promoCode?.code]);
|
|
30
|
+
const applyPromoCode = useCallback((foundPromoCode) => {
|
|
31
|
+
if (!cart?.id) {
|
|
32
|
+
setError('Sepet bilgisi bulunamadı.');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (foundPromoCode.status === Status.ARCHIVED) {
|
|
36
|
+
setError('Bu promosyon kodu artık geçerli değil.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const currentBasketAmount = cart.info?.basePrice?.pay ?? cart.info?.basePrice?.total ?? 0;
|
|
40
|
+
if (foundPromoCode.basketLimit > 0 && currentBasketAmount < foundPromoCode.basketLimit) {
|
|
41
|
+
setError(`Bu kodu kullanabilmek için minimum ${formatTRY(foundPromoCode.basketLimit)} tutarında alışveriş yapmalısınız. Mevcut tutarınız: ${formatTRY(currentBasketAmount)}`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
updateCart({
|
|
45
|
+
id: cart.id,
|
|
46
|
+
promoCodeId: foundPromoCode.id,
|
|
47
|
+
campaignId: cart.campaign?.id ?? undefined,
|
|
48
|
+
}, {
|
|
49
|
+
onSuccess: () => {
|
|
50
|
+
setPromoCode(foundPromoCode);
|
|
51
|
+
setPromoInput(foundPromoCode.code);
|
|
52
|
+
setError(null);
|
|
53
|
+
setIsOpen(true);
|
|
54
|
+
},
|
|
55
|
+
onError: () => {
|
|
56
|
+
setError('Promosyon kodu sepete eklenemedi.');
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}, [cart, setPromoCode, updateCart]);
|
|
60
|
+
const handleApply = () => {
|
|
61
|
+
const trimmed = promoInput.trim();
|
|
62
|
+
if (!trimmed) {
|
|
63
|
+
setError('Lütfen bir promosyon kodu girin.');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
setError(null);
|
|
67
|
+
findPromoCode(trimmed, {
|
|
68
|
+
onSuccess: applyPromoCode,
|
|
69
|
+
onError: () => {
|
|
70
|
+
setError('Geçersiz promosyon kodu.');
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const handleClear = () => {
|
|
75
|
+
if (!cart?.id)
|
|
76
|
+
return;
|
|
77
|
+
updateCart({
|
|
78
|
+
id: cart.id,
|
|
79
|
+
promoCodeId: null,
|
|
80
|
+
campaignId: cart.campaign?.id ?? undefined,
|
|
81
|
+
}, {
|
|
82
|
+
onSuccess: () => {
|
|
83
|
+
setPromoCode(null);
|
|
84
|
+
setPromoInput('');
|
|
85
|
+
setError(null);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const toggleLabelClass = variant === 'checkout'
|
|
90
|
+
? 'text-left text-xs font-black uppercase tracking-widest text-gray-600 underline-offset-2 transition-colors hover:text-[#CF0A2C] hover:underline'
|
|
91
|
+
: 'text-left text-xs font-semibold text-gray-500 underline-offset-2 transition-colors hover:text-gray-900 hover:underline';
|
|
92
|
+
const inputClass = (hasError, applied) => `w-full rounded-lg border px-3 py-2 text-sm font-medium uppercase tracking-wide outline-none transition focus:ring-2 focus:ring-gray-900/10 ${applied
|
|
93
|
+
? 'border-green-500 bg-green-50 pr-9'
|
|
94
|
+
: hasError
|
|
95
|
+
? 'border-red-300 bg-red-50'
|
|
96
|
+
: 'border-gray-200 bg-white'}`;
|
|
97
|
+
const applyButtonClass = variant === 'checkout'
|
|
98
|
+
? 'shrink-0 rounded-lg bg-gray-900 px-4 py-2 text-xs font-bold uppercase tracking-widest text-white transition hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50'
|
|
99
|
+
: 'shrink-0 rounded-full bg-black px-4 py-2 text-[10px] font-black uppercase tracking-[0.15em] text-white transition hover:bg-[#CF0A2C] disabled:cursor-not-allowed disabled:opacity-50';
|
|
100
|
+
return (_jsx("div", { className: "flex flex-col gap-2", children: !isOpen ? (_jsx("button", { type: "button", onClick: () => setIsOpen(true), className: toggleLabelClass, children: "\u0130ndirim kodu ekle" })) : (_jsxs("div", { className: "space-y-2", children: [_jsx("span", { className: "text-xs font-medium text-gray-600", children: "\u0130ndirim kodu" }), _jsxs("div", { className: "flex flex-col gap-2 sm:flex-row", children: [_jsxs("div", { className: "relative flex-1 min-w-0", children: [_jsx("input", { type: "text", value: promoInput, onChange: e => {
|
|
101
|
+
setPromoInput(e.target.value.toUpperCase());
|
|
102
|
+
setError(null);
|
|
103
|
+
}, onKeyDown: e => {
|
|
104
|
+
if (e.key === 'Enter') {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
handleApply();
|
|
107
|
+
}
|
|
108
|
+
}, placeholder: "Kodu girin", disabled: isApplied || isLoading, className: inputClass(Boolean(error), isApplied) }), isApplied ? (_jsx(CheckCircle2, { className: "absolute right-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-green-500" })) : null] }), isApplied ? (_jsx("button", { type: "button", onClick: handleClear, disabled: isLoading, className: "flex h-9 w-full sm:w-9 shrink-0 items-center justify-center rounded-lg border border-gray-200 text-gray-400 transition hover:border-red-200 hover:bg-red-50 hover:text-red-500 disabled:opacity-50", title: "Kodu kald\u0131r", children: _jsx(X, { className: "h-4 w-4" }) })) : (_jsx("button", { type: "button", onClick: handleApply, disabled: !promoInput.trim() || isLoading, className: `${applyButtonClass} w-full sm:w-auto`, children: isLoading ? _jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : 'Uygula' }))] }), error ? _jsx("p", { className: "text-xs text-red-600", children: error }) : null, isApplied && appliedCode ? (_jsxs("p", { className: "text-xs text-green-600", children: [_jsx("span", { className: "font-semibold", children: appliedCode }), " kodu uyguland\u0131."] })) : null] })) }));
|
|
109
|
+
}
|