@armoyu/ui 1.0.0 → 1.0.1
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/app/layout.d.ts.map +1 -1
- package/dist/app/layout.js +16 -13
- package/dist/app/layout.js.map +1 -1
- package/dist/components/Button.d.ts +7 -7
- package/dist/components/Button.js +15 -15
- package/dist/components/GenderStatsBar.d.ts +5 -5
- package/dist/components/GenderStatsBar.js +7 -7
- package/dist/components/RollingNumber.js +3 -3
- package/dist/components/RollingNumber.js.map +1 -1
- package/dist/components/Slider.d.ts +10 -10
- package/dist/components/Slider.js +35 -35
- package/dist/components/StatsGrid.d.ts +5 -5
- package/dist/components/StatsGrid.js +13 -13
- package/dist/components/ViewModeToggle.d.ts +7 -7
- package/dist/components/ViewModeToggle.js +9 -9
- package/dist/components/modules/auth/Dashboard.d.ts +1 -1
- package/dist/components/modules/auth/Dashboard.js +250 -250
- package/dist/components/modules/auth/MediaLightbox.d.ts +13 -13
- package/dist/components/modules/auth/MediaLightbox.js +46 -46
- package/dist/components/modules/auth/PostCard.d.ts +24 -24
- package/dist/components/modules/auth/PostCard.js +112 -112
- package/dist/components/modules/auth/PostInteractionsModal.d.ts +11 -11
- package/dist/components/modules/auth/PostInteractionsModal.js +12 -12
- package/dist/components/modules/auth/RepostModal.d.ts +21 -21
- package/dist/components/modules/auth/RepostModal.js +75 -75
- package/dist/components/modules/auth/SidebarLeft.d.ts +1 -1
- package/dist/components/modules/auth/SidebarLeft.js +40 -40
- package/dist/components/modules/auth/Stories.d.ts +1 -1
- package/dist/components/modules/auth/Stories.js +15 -15
- package/dist/components/modules/auth/StoryViewer.d.ts +9 -9
- package/dist/components/modules/auth/StoryViewer.js +47 -47
- package/dist/components/modules/chat/ChatContainer.d.ts +1 -1
- package/dist/components/modules/chat/ChatContainer.js +196 -196
- package/dist/components/modules/chat/ChatInput.d.ts +4 -4
- package/dist/components/modules/chat/ChatInput.js +30 -30
- package/dist/components/modules/chat/ChatList.d.ts +6 -6
- package/dist/components/modules/chat/ChatList.js +51 -51
- package/dist/components/modules/chat/ChatMessage.d.ts +11 -11
- package/dist/components/modules/chat/ChatMessage.js +6 -6
- package/dist/components/modules/chat/ChatNotes.d.ts +1 -1
- package/dist/components/modules/chat/ChatNotes.js +11 -11
- package/dist/components/modules/community/GroupHeader.d.ts +10 -10
- package/dist/components/modules/community/GroupHeader.js +17 -17
- package/dist/components/modules/community/GroupMenu.d.ts +9 -9
- package/dist/components/modules/community/GroupMenu.js +16 -16
- package/dist/components/modules/community/SchoolCard.d.ts +6 -6
- package/dist/components/modules/community/SchoolCard.js +7 -7
- package/dist/components/modules/community/SurveyCard.d.ts +6 -6
- package/dist/components/modules/community/SurveyCard.js +35 -35
- package/dist/components/modules/forum/ForumBoard.d.ts +16 -16
- package/dist/components/modules/forum/ForumBoard.js +6 -6
- package/dist/components/modules/forum/ForumPost.d.ts +13 -13
- package/dist/components/modules/forum/ForumPost.js +5 -5
- package/dist/components/modules/forum/NewTopicModal.d.ts +7 -7
- package/dist/components/modules/forum/NewTopicModal.js +26 -26
- package/dist/components/modules/forum/TopicItem.d.ts +15 -15
- package/dist/components/modules/forum/TopicItem.js +6 -6
- package/dist/components/modules/galleries/GalleryCard.d.ts +9 -9
- package/dist/components/modules/galleries/GalleryCard.js +5 -5
- package/dist/components/modules/giveaways/GiveawayCard.d.ts +9 -9
- package/dist/components/modules/giveaways/GiveawayCard.js +6 -6
- package/dist/components/modules/groups/ApplicationModal.d.ts +7 -7
- package/dist/components/modules/groups/ApplicationModal.js +27 -27
- package/dist/components/modules/groups/GroupCard.d.ts +12 -12
- package/dist/components/modules/groups/GroupCard.js +6 -6
- package/dist/components/modules/guest/Introduction.d.ts +1 -1
- package/dist/components/modules/guest/Introduction.js +13 -13
- package/dist/components/modules/magaza/BackToStore.d.ts +1 -1
- package/dist/components/modules/magaza/BackToStore.js +10 -10
- package/dist/components/modules/magaza/StoreHeader.d.ts +5 -5
- package/dist/components/modules/magaza/StoreHeader.js +8 -8
- package/dist/components/modules/news/NewsCard.d.ts +11 -11
- package/dist/components/modules/news/NewsCard.js +6 -6
- package/dist/components/modules/news/NewsComments.d.ts +1 -1
- package/dist/components/modules/news/NewsComments.js +52 -52
- package/dist/components/modules/profile/CloudStorageModal.d.ts +8 -8
- package/dist/components/modules/profile/CloudStorageModal.js +31 -31
- package/dist/components/modules/profile/EditProfileModal.d.ts +8 -8
- package/dist/components/modules/profile/EditProfileModal.js +27 -27
- package/dist/components/modules/profile/ProfileContent.d.ts +4 -4
- package/dist/components/modules/profile/ProfileContent.js +70 -70
- package/dist/components/modules/profile/ProfileHeader.d.ts +7 -7
- package/dist/components/modules/profile/ProfileHeader.js +19 -19
- package/dist/components/modules/profile/ProfileStats.js +1 -1
- package/dist/components/modules/profile/ProfileStats.js.map +1 -1
- package/dist/components/modules/profile/TeamSelectorModal.d.ts +10 -10
- package/dist/components/modules/profile/TeamSelectorModal.js +16 -16
- package/dist/components/modules/stations/StationCard.d.ts +2 -2
- package/dist/components/modules/stations/StationCard.js +25 -25
- package/dist/components/modules/stations/StationQRModal.d.ts +9 -9
- package/dist/components/modules/stations/StationQRModal.js +12 -12
- package/dist/components/shared/FloatingChatButton.d.ts +4 -4
- package/dist/components/shared/FloatingChatButton.js +20 -20
- package/dist/components/shared/Footer.d.ts +1 -1
- package/dist/components/shared/Footer.js +9 -9
- package/dist/components/shared/Header.d.ts +1 -1
- package/dist/components/shared/Header.js +97 -97
- package/dist/components/shared/LoginModal.d.ts +4 -4
- package/dist/components/shared/LoginModal.js +69 -69
- package/dist/components/shared/MainLayoutWrapper.d.ts +3 -3
- package/dist/components/shared/MainLayoutWrapper.js +7 -7
- package/dist/components/shared/PageWidth.d.ts +5 -5
- package/dist/components/shared/PageWidth.js +13 -13
- package/dist/context/AuthContext.d.ts +18 -18
- package/dist/context/AuthContext.js +74 -74
- package/dist/context/CartContext.d.ts +16 -16
- package/dist/context/CartContext.js +63 -63
- package/dist/context/ChatContext.d.ts +12 -12
- package/dist/context/ChatContext.js +17 -17
- package/dist/context/LayoutContext.d.ts +10 -10
- package/dist/context/LayoutContext.js +16 -16
- package/dist/context/SocketContext.d.ts +12 -12
- package/dist/context/SocketContext.js +30 -30
- package/dist/context/ThemeContext.d.ts +10 -10
- package/dist/context/ThemeContext.js +39 -39
- package/dist/index.d.ts +65 -65
- package/dist/index.js +80 -80
- package/dist/lib/constants/educationData.d.ts +7 -7
- package/dist/lib/constants/educationData.js +117 -117
- package/dist/lib/constants/punishmentData.d.ts +29 -29
- package/dist/lib/constants/punishmentData.js +183 -183
- package/dist/lib/constants/seedData.d.ts +164 -164
- package/dist/lib/constants/seedData.js +694 -694
- package/dist/lib/constants/stationData.d.ts +13 -13
- package/dist/lib/constants/stationData.js +166 -166
- package/dist/lib/constants/surveyData.d.ts +2 -2
- package/dist/lib/constants/surveyData.js +49 -49
- package/dist/lib/constants/teamData.d.ts +12 -12
- package/dist/lib/constants/teamData.js +65 -65
- package/dist/types/stats.d.ts +17 -17
- package/dist/types/stats.js +1 -1
- package/next.config.ts +13 -13
- package/package.json +45 -46
- package/postcss.config.js +6 -6
- package/src/app/layout.tsx +67 -64
- package/src/app/page.tsx +101 -101
- package/src/components/RollingNumber.tsx +3 -3
- package/src/components/modules/profile/ProfileStats.tsx +4 -4
- package/src/components/showcase/CommunityTab.tsx +22 -22
- package/src/components/showcase/CorporateTab.tsx +38 -38
- package/src/components/showcase/GeneralTab.tsx +41 -41
- package/src/components/showcase/MessagesTab.tsx +26 -26
- package/src/components/showcase/ProfileTab.tsx +20 -20
- package/src/components/showcase/ShopTab.tsx +24 -24
- package/src/components/showcase/SocialTab.tsx +28 -28
- package/src/globals.css +187 -187
- package/src/lib/utils/numberFormat.ts +16 -16
- package/src/lib/utils/odpUtils.ts +51 -51
- package/src/types/index.ts +1 -1
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Button } from '../Button';
|
|
5
|
-
import { useAuth } from '../../context/AuthContext';
|
|
6
|
-
import { userList } from '../../lib/constants/seedData';
|
|
7
|
-
export function LoginModal({ isOpen, onClose }) {
|
|
8
|
-
const { login } = useAuth();
|
|
9
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
10
|
-
const [username, setUsername] = React.useState('');
|
|
11
|
-
const [password, setPassword] = React.useState('');
|
|
12
|
-
const [error, setError] = React.useState('');
|
|
13
|
-
// QR Kod State'leri
|
|
14
|
-
const [qrValue, setQrValue] = React.useState('');
|
|
15
|
-
const [qrProgress, setQrProgress] = React.useState(100);
|
|
16
|
-
// Modal açıldığında form verilerinin ve QR kodun yönetimi
|
|
17
|
-
React.useEffect(() => {
|
|
18
|
-
if (!isOpen) {
|
|
19
|
-
setUsername('');
|
|
20
|
-
setPassword('');
|
|
21
|
-
setError('');
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const generateQR = () => {
|
|
25
|
-
// Gerçek senaryoda bu veri backend'den dönen ve JWT içeren tek kullanımlık bir token olur.
|
|
26
|
-
setQrValue(`armoyu_mobile_auth_${Math.random().toString(36).substring(2, 15)}`);
|
|
27
|
-
setQrProgress(100);
|
|
28
|
-
};
|
|
29
|
-
generateQR();
|
|
30
|
-
const refreshInterval = setInterval(() => {
|
|
31
|
-
generateQR();
|
|
32
|
-
}, 20000); // Her 20 saniyede bir yenilenir
|
|
33
|
-
const progressInterval = setInterval(() => {
|
|
34
|
-
// 20 saniyelik süreci 100 parçaya bölerek her 100ms'de azaltır
|
|
35
|
-
setQrProgress((prev) => Math.max(0, prev - (100 / (20000 / 100))));
|
|
36
|
-
}, 100);
|
|
37
|
-
return () => {
|
|
38
|
-
clearInterval(refreshInterval);
|
|
39
|
-
clearInterval(progressInterval);
|
|
40
|
-
};
|
|
41
|
-
}, [isOpen]);
|
|
42
|
-
if (!isOpen)
|
|
43
|
-
return null;
|
|
44
|
-
const handleLogin = (e) => {
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
setError('');
|
|
47
|
-
setIsSubmitting(true);
|
|
48
|
-
// Simulate API delay
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
// Search for the user in our seeded userList
|
|
51
|
-
const foundUser = userList.find((u) => u.username.toLowerCase() === username.toLowerCase());
|
|
52
|
-
if (foundUser) {
|
|
53
|
-
login(foundUser);
|
|
54
|
-
setIsSubmitting(false);
|
|
55
|
-
onClose();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
setError('Kullanıcı bulunamadı! Lütfen listedeki geçerli bir kullanıcı adını deneyin.');
|
|
59
|
-
setIsSubmitting(false);
|
|
60
|
-
}
|
|
61
|
-
}, 800);
|
|
62
|
-
};
|
|
63
|
-
const fillTestAccount = () => {
|
|
64
|
-
setUsername('test');
|
|
65
|
-
setPassword('123456');
|
|
66
|
-
setError('');
|
|
67
|
-
};
|
|
68
|
-
return (_jsx("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: _jsxs("div", { className: "relative glass-panel bg-[#0a0a0e]/95 w-full max-w-4xl rounded-[2rem] shadow-[0_0_50px_rgba(0,0,0,1)] border border-white/10 flex flex-col md:flex-row overflow-hidden animate-in zoom-in-95 duration-300", children: [_jsx("button", { onClick: onClose, className: "absolute top-6 right-6 z-20 text-gray-400 hover:text-white transition-colors bg-white/5 p-2 rounded-full hover:bg-white/10 border border-white/5", title: "Kapat", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) }), _jsxs("div", { className: "w-full md:w-1/2 p-8 lg:p-12 flex flex-col justify-center relative z-10", children: [_jsx("h2", { className: "text-3xl font-black mb-2 text-white tracking-tight", children: "Giri\u015F Yap" }), _jsx("p", { className: "text-gray-400 text-sm mb-8", children: "Kald\u0131\u011F\u0131n yerden oynamaya devam et." }), _jsxs("div", { className: "mb-6 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl text-center shadow-inner flex items-center justify-between gap-4", children: [_jsxs("p", { className: "text-xs text-blue-300 font-medium text-left", children: ["Test hesab\u0131 ile ", _jsx("br", {}), "aray\u00FCz\u00FC inceleyin."] }), _jsx("button", { type: "button", onClick: () => { setUsername('berkaytikenoglu'); setPassword('armo-v3'); }, className: "text-xs font-bold bg-gradient-to-r from-blue-600 to-blue-500 hover:from-blue-500 hover:to-blue-400 text-white py-2 px-4 rounded-lg transition-all shadow-[0_0_10px_rgba(37,99,235,0.3)] border border-blue-400/50 whitespace-nowrap", children: "Kurucu Bilgilerini Gir" })] }), _jsxs("form", { className: "space-y-4", onSubmit: handleLogin, children: [error && (_jsx("div", { className: "p-3 bg-red-500/10 border border-red-500/30 text-red-400 text-sm font-medium rounded-xl text-center animate-in slide-in-from-top-2 duration-200", children: error })), _jsxs("div", { className: "space-y-1.5", children: [_jsx("label", { className: "text-xs font-bold text-gray-400 uppercase tracking-wider", children: "Kullan\u0131c\u0131 Ad\u0131" }), _jsx("input", { required: true, type: "text", value: username, onChange: (e) => setUsername(e.target.value), className: "w-full bg-white/5 border border-white/10 hover:border-white/20 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-medium", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx("label", { className: "text-xs font-bold text-gray-400 uppercase tracking-wider", children: "\u015Eifre" }), _jsx("input", { required: true, type: "password", value: password, onChange: (e) => setPassword(e.target.value), className: "w-full bg-white/5 border border-white/10 hover:border-white/20 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-medium tracking-widest", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" })] }), _jsxs("div", { className: "flex justify-between items-center text-sm px-1 pt-1", children: [_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer text-gray-400 hover:text-gray-300", children: [_jsx("input", { type: "checkbox", className: "rounded bg-transparent border border-white/20 text-blue-500 focus:ring-blue-500 h-4 w-4" }), _jsx("span", { children: "Beni Hat\u0131rla" })] }), _jsx("a", { href: "#", className: "text-blue-400 hover:text-blue-300 transition-colors font-medium", children: "\u015Eifremi Unuttum" })] }), _jsx(Button, { variant: "primary", className: "w-full h-12 text-md mt-6 font-bold shadow-[0_0_15px_rgba(37,99,235,0.4)] rounded-xl", isLoading: isSubmitting, children: "Hesab\u0131ma Giri\u015F Yap" }), _jsxs("p", { className: "text-center text-gray-500 text-sm mt-6 font-medium", children: ["Hen\u00FCz ARMOYU'da de\u011Fil misin? ", _jsx("a", { href: "#", className: "text-blue-400 hover:text-blue-300 ml-1", children: "Kay\u0131t Ol" })] })] })] }), _jsxs("div", { className: "w-full md:w-1/2 bg-gradient-to-br from-[#0c101c] to-[#160b24] p-8 lg:p-12 flex flex-col items-center justify-center border-t md:border-t-0 md:border-l border-white/5 relative", children: [_jsxs("div", { className: "text-center space-y-4 mb-8 relative z-10 w-full", children: [_jsx("h3", { className: "text-2xl font-bold text-white tracking-tight", children: "Mobil Uygulama \u0130le Gir" }), _jsxs("p", { className: "text-gray-400 text-sm max-w-[260px] mx-auto leading-relaxed", children: ["ARMOYU uygulamas\u0131ndan ", _jsx("strong", { className: "text-white font-medium", children: "Ayarlar > QR Okut" }), " men\u00FCs\u00FCne girerek saniyeler i\u00E7inde ba\u011Flan\u0131n."] })] }), _jsx("div", { className: "relative p-3 bg-white/10 backdrop-blur-md rounded-[2rem] shadow-2xl overflow-hidden border border-white/10", children: _jsx("div", { className: "bg-white p-4 rounded-2xl relative overflow-hidden group", children: _jsx("img", { src: `https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=${qrValue}`, alt: "Login QR Code", className: "w-44 h-44 md:w-48 md:h-48 transition-all duration-300 group-hover:scale-105", style: { opacity: qrProgress > 95 ? 0.3 : 1 } }) }) }), _jsxs("div", { className: "mt-10 flex flex-col items-center w-full max-w-[220px]", children: [_jsx("div", { className: "w-full h-1.5 bg-white/10 rounded-full overflow-hidden shadow-inner", children: _jsx("div", { className: "h-full bg-gradient-to-r from-blue-500 to-purple-500 rounded-full transition-all duration-100 ease-linear shadow-[0_0_10px_rgba(168,85,247,0.5)]", style: { width: `${qrProgress}%` } }) }), _jsxs("p", { className: "text-xs text-gray-400 mt-3 font-medium flex items-center gap-1.5", children: [_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", className: `${qrProgress < 15 ? 'text-red-400 animate-pulse' : 'text-blue-400'}`, children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("polyline", { points: "12 6 12 12 16 14" })] }), _jsxs("span", { className: `${qrProgress < 15 ? 'text-red-400' : 'text-gray-400'}`, children: [Math.ceil((qrProgress / 100) * 20), " saniye i\u00E7inde yenilenecek"] })] })] })] })] }) }));
|
|
69
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { useAuth } from '../../context/AuthContext';
|
|
6
|
+
import { userList } from '../../lib/constants/seedData';
|
|
7
|
+
export function LoginModal({ isOpen, onClose }) {
|
|
8
|
+
const { login } = useAuth();
|
|
9
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
10
|
+
const [username, setUsername] = React.useState('');
|
|
11
|
+
const [password, setPassword] = React.useState('');
|
|
12
|
+
const [error, setError] = React.useState('');
|
|
13
|
+
// QR Kod State'leri
|
|
14
|
+
const [qrValue, setQrValue] = React.useState('');
|
|
15
|
+
const [qrProgress, setQrProgress] = React.useState(100);
|
|
16
|
+
// Modal açıldığında form verilerinin ve QR kodun yönetimi
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
if (!isOpen) {
|
|
19
|
+
setUsername('');
|
|
20
|
+
setPassword('');
|
|
21
|
+
setError('');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const generateQR = () => {
|
|
25
|
+
// Gerçek senaryoda bu veri backend'den dönen ve JWT içeren tek kullanımlık bir token olur.
|
|
26
|
+
setQrValue(`armoyu_mobile_auth_${Math.random().toString(36).substring(2, 15)}`);
|
|
27
|
+
setQrProgress(100);
|
|
28
|
+
};
|
|
29
|
+
generateQR();
|
|
30
|
+
const refreshInterval = setInterval(() => {
|
|
31
|
+
generateQR();
|
|
32
|
+
}, 20000); // Her 20 saniyede bir yenilenir
|
|
33
|
+
const progressInterval = setInterval(() => {
|
|
34
|
+
// 20 saniyelik süreci 100 parçaya bölerek her 100ms'de azaltır
|
|
35
|
+
setQrProgress((prev) => Math.max(0, prev - (100 / (20000 / 100))));
|
|
36
|
+
}, 100);
|
|
37
|
+
return () => {
|
|
38
|
+
clearInterval(refreshInterval);
|
|
39
|
+
clearInterval(progressInterval);
|
|
40
|
+
};
|
|
41
|
+
}, [isOpen]);
|
|
42
|
+
if (!isOpen)
|
|
43
|
+
return null;
|
|
44
|
+
const handleLogin = (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
setError('');
|
|
47
|
+
setIsSubmitting(true);
|
|
48
|
+
// Simulate API delay
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
// Search for the user in our seeded userList
|
|
51
|
+
const foundUser = userList.find((u) => u.username.toLowerCase() === username.toLowerCase());
|
|
52
|
+
if (foundUser) {
|
|
53
|
+
login(foundUser);
|
|
54
|
+
setIsSubmitting(false);
|
|
55
|
+
onClose();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
setError('Kullanıcı bulunamadı! Lütfen listedeki geçerli bir kullanıcı adını deneyin.');
|
|
59
|
+
setIsSubmitting(false);
|
|
60
|
+
}
|
|
61
|
+
}, 800);
|
|
62
|
+
};
|
|
63
|
+
const fillTestAccount = () => {
|
|
64
|
+
setUsername('test');
|
|
65
|
+
setPassword('123456');
|
|
66
|
+
setError('');
|
|
67
|
+
};
|
|
68
|
+
return (_jsx("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4 animate-in fade-in duration-200", children: _jsxs("div", { className: "relative glass-panel bg-[#0a0a0e]/95 w-full max-w-4xl rounded-[2rem] shadow-[0_0_50px_rgba(0,0,0,1)] border border-white/10 flex flex-col md:flex-row overflow-hidden animate-in zoom-in-95 duration-300", children: [_jsx("button", { onClick: onClose, className: "absolute top-6 right-6 z-20 text-gray-400 hover:text-white transition-colors bg-white/5 p-2 rounded-full hover:bg-white/10 border border-white/5", title: "Kapat", children: _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) }), _jsxs("div", { className: "w-full md:w-1/2 p-8 lg:p-12 flex flex-col justify-center relative z-10", children: [_jsx("h2", { className: "text-3xl font-black mb-2 text-white tracking-tight", children: "Giri\u015F Yap" }), _jsx("p", { className: "text-gray-400 text-sm mb-8", children: "Kald\u0131\u011F\u0131n yerden oynamaya devam et." }), _jsxs("div", { className: "mb-6 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl text-center shadow-inner flex items-center justify-between gap-4", children: [_jsxs("p", { className: "text-xs text-blue-300 font-medium text-left", children: ["Test hesab\u0131 ile ", _jsx("br", {}), "aray\u00FCz\u00FC inceleyin."] }), _jsx("button", { type: "button", onClick: () => { setUsername('berkaytikenoglu'); setPassword('armo-v3'); }, className: "text-xs font-bold bg-gradient-to-r from-blue-600 to-blue-500 hover:from-blue-500 hover:to-blue-400 text-white py-2 px-4 rounded-lg transition-all shadow-[0_0_10px_rgba(37,99,235,0.3)] border border-blue-400/50 whitespace-nowrap", children: "Kurucu Bilgilerini Gir" })] }), _jsxs("form", { className: "space-y-4", onSubmit: handleLogin, children: [error && (_jsx("div", { className: "p-3 bg-red-500/10 border border-red-500/30 text-red-400 text-sm font-medium rounded-xl text-center animate-in slide-in-from-top-2 duration-200", children: error })), _jsxs("div", { className: "space-y-1.5", children: [_jsx("label", { className: "text-xs font-bold text-gray-400 uppercase tracking-wider", children: "Kullan\u0131c\u0131 Ad\u0131" }), _jsx("input", { required: true, type: "text", value: username, onChange: (e) => setUsername(e.target.value), className: "w-full bg-white/5 border border-white/10 hover:border-white/20 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-medium", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx("label", { className: "text-xs font-bold text-gray-400 uppercase tracking-wider", children: "\u015Eifre" }), _jsx("input", { required: true, type: "password", value: password, onChange: (e) => setPassword(e.target.value), className: "w-full bg-white/5 border border-white/10 hover:border-white/20 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 transition-all font-medium tracking-widest", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" })] }), _jsxs("div", { className: "flex justify-between items-center text-sm px-1 pt-1", children: [_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer text-gray-400 hover:text-gray-300", children: [_jsx("input", { type: "checkbox", className: "rounded bg-transparent border border-white/20 text-blue-500 focus:ring-blue-500 h-4 w-4" }), _jsx("span", { children: "Beni Hat\u0131rla" })] }), _jsx("a", { href: "#", className: "text-blue-400 hover:text-blue-300 transition-colors font-medium", children: "\u015Eifremi Unuttum" })] }), _jsx(Button, { variant: "primary", className: "w-full h-12 text-md mt-6 font-bold shadow-[0_0_15px_rgba(37,99,235,0.4)] rounded-xl", isLoading: isSubmitting, children: "Hesab\u0131ma Giri\u015F Yap" }), _jsxs("p", { className: "text-center text-gray-500 text-sm mt-6 font-medium", children: ["Hen\u00FCz ARMOYU'da de\u011Fil misin? ", _jsx("a", { href: "#", className: "text-blue-400 hover:text-blue-300 ml-1", children: "Kay\u0131t Ol" })] })] })] }), _jsxs("div", { className: "w-full md:w-1/2 bg-gradient-to-br from-[#0c101c] to-[#160b24] p-8 lg:p-12 flex flex-col items-center justify-center border-t md:border-t-0 md:border-l border-white/5 relative", children: [_jsxs("div", { className: "text-center space-y-4 mb-8 relative z-10 w-full", children: [_jsx("h3", { className: "text-2xl font-bold text-white tracking-tight", children: "Mobil Uygulama \u0130le Gir" }), _jsxs("p", { className: "text-gray-400 text-sm max-w-[260px] mx-auto leading-relaxed", children: ["ARMOYU uygulamas\u0131ndan ", _jsx("strong", { className: "text-white font-medium", children: "Ayarlar > QR Okut" }), " men\u00FCs\u00FCne girerek saniyeler i\u00E7inde ba\u011Flan\u0131n."] })] }), _jsx("div", { className: "relative p-3 bg-white/10 backdrop-blur-md rounded-[2rem] shadow-2xl overflow-hidden border border-white/10", children: _jsx("div", { className: "bg-white p-4 rounded-2xl relative overflow-hidden group", children: _jsx("img", { src: `https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=${qrValue}`, alt: "Login QR Code", className: "w-44 h-44 md:w-48 md:h-48 transition-all duration-300 group-hover:scale-105", style: { opacity: qrProgress > 95 ? 0.3 : 1 } }) }) }), _jsxs("div", { className: "mt-10 flex flex-col items-center w-full max-w-[220px]", children: [_jsx("div", { className: "w-full h-1.5 bg-white/10 rounded-full overflow-hidden shadow-inner", children: _jsx("div", { className: "h-full bg-gradient-to-r from-blue-500 to-purple-500 rounded-full transition-all duration-100 ease-linear shadow-[0_0_10px_rgba(168,85,247,0.5)]", style: { width: `${qrProgress}%` } }) }), _jsxs("p", { className: "text-xs text-gray-400 mt-3 font-medium flex items-center gap-1.5", children: [_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", className: `${qrProgress < 15 ? 'text-red-400 animate-pulse' : 'text-blue-400'}`, children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("polyline", { points: "12 6 12 12 16 14" })] }), _jsxs("span", { className: `${qrProgress < 15 ? 'text-red-400' : 'text-gray-400'}`, children: [Math.ceil((qrProgress / 100) * 20), " saniye i\u00E7inde yenilenecek"] })] })] })] })] }) }));
|
|
69
|
+
}
|
|
70
70
|
//# sourceMappingURL=LoginModal.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function MainLayoutWrapper({ children }: {
|
|
2
|
-
children: React.ReactNode;
|
|
3
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function MainLayoutWrapper({ children }: {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=MainLayoutWrapper.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useLayout } from '../../context/LayoutContext';
|
|
4
|
-
export function MainLayoutWrapper({ children }) {
|
|
5
|
-
const { pageWidth } = useLayout();
|
|
6
|
-
return (_jsx("main", { className: `flex-grow w-full overflow-x-hidden pt-8 px-4 md:px-8 mx-auto z-10 transition-all duration-700 ${pageWidth}`, children: children }));
|
|
7
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useLayout } from '../../context/LayoutContext';
|
|
4
|
+
export function MainLayoutWrapper({ children }) {
|
|
5
|
+
const { pageWidth } = useLayout();
|
|
6
|
+
return (_jsx("main", { className: `flex-grow w-full overflow-x-hidden pt-8 px-4 md:px-8 mx-auto z-10 transition-all duration-700 ${pageWidth}`, children: children }));
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=MainLayoutWrapper.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
interface PageWidthProps {
|
|
2
|
-
width: string;
|
|
3
|
-
}
|
|
4
|
-
export declare function PageWidth({ width }: PageWidthProps): null;
|
|
5
|
-
export {};
|
|
1
|
+
interface PageWidthProps {
|
|
2
|
+
width: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function PageWidth({ width }: PageWidthProps): null;
|
|
5
|
+
export {};
|
|
6
6
|
//# sourceMappingURL=PageWidth.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { useLayout } from '../../context/LayoutContext';
|
|
4
|
-
export function PageWidth({ width }) {
|
|
5
|
-
const { setPageWidth } = useLayout();
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
// Sayfa yüklendiğinde yeni genişliği uygula
|
|
8
|
-
setPageWidth(width);
|
|
9
|
-
// Sayfadan çıkıldığında varsayılan değere (%80) geri dön
|
|
10
|
-
return () => setPageWidth('max-w-[80%]');
|
|
11
|
-
}, [width, setPageWidth]);
|
|
12
|
-
return null; // Görünür bir element üretmez
|
|
13
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useLayout } from '../../context/LayoutContext';
|
|
4
|
+
export function PageWidth({ width }) {
|
|
5
|
+
const { setPageWidth } = useLayout();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
// Sayfa yüklendiğinde yeni genişliği uygula
|
|
8
|
+
setPageWidth(width);
|
|
9
|
+
// Sayfadan çıkıldığında varsayılan değere (%80) geri dön
|
|
10
|
+
return () => setPageWidth('max-w-[80%]');
|
|
11
|
+
}, [width, setPageWidth]);
|
|
12
|
+
return null; // Görünür bir element üretmez
|
|
13
|
+
}
|
|
14
14
|
//# sourceMappingURL=PageWidth.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { User, Session } from '@armoyu/core';
|
|
3
|
-
interface AuthContextType {
|
|
4
|
-
user: User | null;
|
|
5
|
-
session: Session | null;
|
|
6
|
-
login: (userData: User) => void;
|
|
7
|
-
logout: () => void;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
isLoginModalOpen: boolean;
|
|
10
|
-
setIsLoginModalOpen: (open: boolean) => void;
|
|
11
|
-
updateUser: (updatedUser: User) => void;
|
|
12
|
-
updateSession: (updatedSession: Session) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function AuthProvider({ children }: {
|
|
15
|
-
children: React.ReactNode;
|
|
16
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export declare function useAuth(): AuthContextType;
|
|
18
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { User, Session } from '@armoyu/core';
|
|
3
|
+
interface AuthContextType {
|
|
4
|
+
user: User | null;
|
|
5
|
+
session: Session | null;
|
|
6
|
+
login: (userData: User) => void;
|
|
7
|
+
logout: () => void;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
isLoginModalOpen: boolean;
|
|
10
|
+
setIsLoginModalOpen: (open: boolean) => void;
|
|
11
|
+
updateUser: (updatedUser: User) => void;
|
|
12
|
+
updateSession: (updatedSession: Session) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function AuthProvider({ children }: {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function useAuth(): AuthContextType;
|
|
18
|
+
export {};
|
|
19
19
|
//# sourceMappingURL=AuthContext.d.ts.map
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
-
import { Session } from '@armoyu/core';
|
|
5
|
-
import { userList, MOCK_SESSION } from '../lib/constants/seedData';
|
|
6
|
-
const AuthContext = createContext(undefined);
|
|
7
|
-
export function AuthProvider({ children }) {
|
|
8
|
-
const [user, setUser] = useState(null);
|
|
9
|
-
const [session, setSession] = useState(null);
|
|
10
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
11
|
-
const [isLoginModalOpen, setIsLoginModalOpen] = useState(false);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
// Check local storage for persistent login
|
|
14
|
-
const savedUserStr = localStorage.getItem('armoyu_user');
|
|
15
|
-
if (savedUserStr) {
|
|
16
|
-
try {
|
|
17
|
-
const savedData = JSON.parse(savedUserStr);
|
|
18
|
-
const username = savedData.username;
|
|
19
|
-
// Find user in seedData to maintain all object references
|
|
20
|
-
const foundUser = userList.find((u) => u.username === username);
|
|
21
|
-
if (foundUser) {
|
|
22
|
-
setUser(foundUser);
|
|
23
|
-
// If it's Berkay, use the mock session with notifications
|
|
24
|
-
if (username === 'berkaytikenoglu') {
|
|
25
|
-
setSession(MOCK_SESSION);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
setSession(new Session({ user: foundUser, token: 'mock-token' }));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
console.error('Failed to restore session', e);
|
|
34
|
-
localStorage.removeItem('armoyu_user');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Explicitly set loading to false AFTER the check
|
|
38
|
-
setIsLoading(false);
|
|
39
|
-
}, []);
|
|
40
|
-
const login = (userData) => {
|
|
41
|
-
setUser(userData);
|
|
42
|
-
// Handle session initialization
|
|
43
|
-
if (userData.username === 'berkaytikenoglu') {
|
|
44
|
-
setSession(MOCK_SESSION);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
setSession(new Session({ user: userData, token: 'mock-token' }));
|
|
48
|
-
}
|
|
49
|
-
localStorage.setItem('armoyu_user', JSON.stringify({ username: userData.username }));
|
|
50
|
-
setIsLoginModalOpen(false); // Close modal on success
|
|
51
|
-
};
|
|
52
|
-
const logout = () => {
|
|
53
|
-
setUser(null);
|
|
54
|
-
setSession(null);
|
|
55
|
-
localStorage.removeItem('armoyu_user');
|
|
56
|
-
};
|
|
57
|
-
const updateUser = (updatedUser) => {
|
|
58
|
-
setUser(updatedUser);
|
|
59
|
-
if (session) {
|
|
60
|
-
setSession(new Session({ ...session, user: updatedUser }));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const updateSession = (updatedSession) => {
|
|
64
|
-
setSession(updatedSession);
|
|
65
|
-
};
|
|
66
|
-
return (_jsx(AuthContext.Provider, { value: { user, session, login, logout, isLoading, isLoginModalOpen, setIsLoginModalOpen, updateUser, updateSession }, children: children }));
|
|
67
|
-
}
|
|
68
|
-
export function useAuth() {
|
|
69
|
-
const context = useContext(AuthContext);
|
|
70
|
-
if (context === undefined) {
|
|
71
|
-
throw new Error('useAuth must be used within an AuthProvider');
|
|
72
|
-
}
|
|
73
|
-
return context;
|
|
74
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
+
import { Session } from '@armoyu/core';
|
|
5
|
+
import { userList, MOCK_SESSION } from '../lib/constants/seedData';
|
|
6
|
+
const AuthContext = createContext(undefined);
|
|
7
|
+
export function AuthProvider({ children }) {
|
|
8
|
+
const [user, setUser] = useState(null);
|
|
9
|
+
const [session, setSession] = useState(null);
|
|
10
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
11
|
+
const [isLoginModalOpen, setIsLoginModalOpen] = useState(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
// Check local storage for persistent login
|
|
14
|
+
const savedUserStr = localStorage.getItem('armoyu_user');
|
|
15
|
+
if (savedUserStr) {
|
|
16
|
+
try {
|
|
17
|
+
const savedData = JSON.parse(savedUserStr);
|
|
18
|
+
const username = savedData.username;
|
|
19
|
+
// Find user in seedData to maintain all object references
|
|
20
|
+
const foundUser = userList.find((u) => u.username === username);
|
|
21
|
+
if (foundUser) {
|
|
22
|
+
setUser(foundUser);
|
|
23
|
+
// If it's Berkay, use the mock session with notifications
|
|
24
|
+
if (username === 'berkaytikenoglu') {
|
|
25
|
+
setSession(MOCK_SESSION);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
setSession(new Session({ user: foundUser, token: 'mock-token' }));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error('Failed to restore session', e);
|
|
34
|
+
localStorage.removeItem('armoyu_user');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Explicitly set loading to false AFTER the check
|
|
38
|
+
setIsLoading(false);
|
|
39
|
+
}, []);
|
|
40
|
+
const login = (userData) => {
|
|
41
|
+
setUser(userData);
|
|
42
|
+
// Handle session initialization
|
|
43
|
+
if (userData.username === 'berkaytikenoglu') {
|
|
44
|
+
setSession(MOCK_SESSION);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setSession(new Session({ user: userData, token: 'mock-token' }));
|
|
48
|
+
}
|
|
49
|
+
localStorage.setItem('armoyu_user', JSON.stringify({ username: userData.username }));
|
|
50
|
+
setIsLoginModalOpen(false); // Close modal on success
|
|
51
|
+
};
|
|
52
|
+
const logout = () => {
|
|
53
|
+
setUser(null);
|
|
54
|
+
setSession(null);
|
|
55
|
+
localStorage.removeItem('armoyu_user');
|
|
56
|
+
};
|
|
57
|
+
const updateUser = (updatedUser) => {
|
|
58
|
+
setUser(updatedUser);
|
|
59
|
+
if (session) {
|
|
60
|
+
setSession(new Session({ ...session, user: updatedUser }));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const updateSession = (updatedSession) => {
|
|
64
|
+
setSession(updatedSession);
|
|
65
|
+
};
|
|
66
|
+
return (_jsx(AuthContext.Provider, { value: { user, session, login, logout, isLoading, isLoginModalOpen, setIsLoginModalOpen, updateUser, updateSession }, children: children }));
|
|
67
|
+
}
|
|
68
|
+
export function useAuth() {
|
|
69
|
+
const context = useContext(AuthContext);
|
|
70
|
+
if (context === undefined) {
|
|
71
|
+
throw new Error('useAuth must be used within an AuthProvider');
|
|
72
|
+
}
|
|
73
|
+
return context;
|
|
74
|
+
}
|
|
75
75
|
//# sourceMappingURL=AuthContext.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Product, CartItem } from '@armoyu/core';
|
|
3
|
-
interface CartContextType {
|
|
4
|
-
cart: CartItem[];
|
|
5
|
-
addToCart: (product: Product, quantity?: number) => void;
|
|
6
|
-
removeFromCart: (productId: string) => void;
|
|
7
|
-
updateQuantity: (productId: string, quantity: number) => void;
|
|
8
|
-
clearCart: () => void;
|
|
9
|
-
totalItems: number;
|
|
10
|
-
totalPrice: number;
|
|
11
|
-
}
|
|
12
|
-
export declare function CartProvider({ children }: {
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare function useCart(): CartContextType;
|
|
16
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Product, CartItem } from '@armoyu/core';
|
|
3
|
+
interface CartContextType {
|
|
4
|
+
cart: CartItem[];
|
|
5
|
+
addToCart: (product: Product, quantity?: number) => void;
|
|
6
|
+
removeFromCart: (productId: string) => void;
|
|
7
|
+
updateQuantity: (productId: string, quantity: number) => void;
|
|
8
|
+
clearCart: () => void;
|
|
9
|
+
totalItems: number;
|
|
10
|
+
totalPrice: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function CartProvider({ children }: {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function useCart(): CartContextType;
|
|
16
|
+
export {};
|
|
17
17
|
//# sourceMappingURL=CartContext.d.ts.map
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
-
import { CartItem } from '@armoyu/core';
|
|
5
|
-
const CartContext = createContext(undefined);
|
|
6
|
-
export function CartProvider({ children }) {
|
|
7
|
-
const [cart, setCart] = useState([]);
|
|
8
|
-
// Load cart from localStorage on mount
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const savedCart = localStorage.getItem('armoyu_cart');
|
|
11
|
-
if (savedCart) {
|
|
12
|
-
try {
|
|
13
|
-
const parsed = JSON.parse(savedCart);
|
|
14
|
-
setCart(parsed.map((i) => CartItem.fromJSON(i)));
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error('Failed to parse cart', e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}, []);
|
|
21
|
-
// Save cart to localStorage on change
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
localStorage.setItem('armoyu_cart', JSON.stringify(cart));
|
|
24
|
-
}, [cart]);
|
|
25
|
-
const addToCart = (product, quantity = 1) => {
|
|
26
|
-
setCart(prev => {
|
|
27
|
-
const existing = prev.find(item => item.product.id === product.id);
|
|
28
|
-
if (existing) {
|
|
29
|
-
return prev.map(item => item.product.id === product.id
|
|
30
|
-
? new CartItem({ ...item, quantity: item.quantity + quantity })
|
|
31
|
-
: item);
|
|
32
|
-
}
|
|
33
|
-
return [...prev, new CartItem({ product, quantity })];
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
const removeFromCart = (productId) => {
|
|
37
|
-
setCart(prev => prev.filter(item => item.product.id !== productId));
|
|
38
|
-
};
|
|
39
|
-
const updateQuantity = (productId, quantity) => {
|
|
40
|
-
setCart(prev => prev.map(item => item.product.id === productId
|
|
41
|
-
? new CartItem({ ...item, quantity: Math.max(1, quantity) })
|
|
42
|
-
: item));
|
|
43
|
-
};
|
|
44
|
-
const clearCart = () => setCart([]);
|
|
45
|
-
const totalItems = cart.reduce((acc, item) => acc + item.quantity, 0);
|
|
46
|
-
const totalPrice = cart.reduce((acc, item) => acc + item.getTotalPrice(), 0);
|
|
47
|
-
return (_jsx(CartContext.Provider, { value: {
|
|
48
|
-
cart,
|
|
49
|
-
addToCart,
|
|
50
|
-
removeFromCart,
|
|
51
|
-
updateQuantity,
|
|
52
|
-
clearCart,
|
|
53
|
-
totalItems,
|
|
54
|
-
totalPrice
|
|
55
|
-
}, children: children }));
|
|
56
|
-
}
|
|
57
|
-
export function useCart() {
|
|
58
|
-
const context = useContext(CartContext);
|
|
59
|
-
if (context === undefined) {
|
|
60
|
-
throw new Error('useCart must be used within a CartProvider');
|
|
61
|
-
}
|
|
62
|
-
return context;
|
|
63
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
+
import { CartItem } from '@armoyu/core';
|
|
5
|
+
const CartContext = createContext(undefined);
|
|
6
|
+
export function CartProvider({ children }) {
|
|
7
|
+
const [cart, setCart] = useState([]);
|
|
8
|
+
// Load cart from localStorage on mount
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const savedCart = localStorage.getItem('armoyu_cart');
|
|
11
|
+
if (savedCart) {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(savedCart);
|
|
14
|
+
setCart(parsed.map((i) => CartItem.fromJSON(i)));
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
console.error('Failed to parse cart', e);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}, []);
|
|
21
|
+
// Save cart to localStorage on change
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
localStorage.setItem('armoyu_cart', JSON.stringify(cart));
|
|
24
|
+
}, [cart]);
|
|
25
|
+
const addToCart = (product, quantity = 1) => {
|
|
26
|
+
setCart(prev => {
|
|
27
|
+
const existing = prev.find(item => item.product.id === product.id);
|
|
28
|
+
if (existing) {
|
|
29
|
+
return prev.map(item => item.product.id === product.id
|
|
30
|
+
? new CartItem({ ...item, quantity: item.quantity + quantity })
|
|
31
|
+
: item);
|
|
32
|
+
}
|
|
33
|
+
return [...prev, new CartItem({ product, quantity })];
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const removeFromCart = (productId) => {
|
|
37
|
+
setCart(prev => prev.filter(item => item.product.id !== productId));
|
|
38
|
+
};
|
|
39
|
+
const updateQuantity = (productId, quantity) => {
|
|
40
|
+
setCart(prev => prev.map(item => item.product.id === productId
|
|
41
|
+
? new CartItem({ ...item, quantity: Math.max(1, quantity) })
|
|
42
|
+
: item));
|
|
43
|
+
};
|
|
44
|
+
const clearCart = () => setCart([]);
|
|
45
|
+
const totalItems = cart.reduce((acc, item) => acc + item.quantity, 0);
|
|
46
|
+
const totalPrice = cart.reduce((acc, item) => acc + item.getTotalPrice(), 0);
|
|
47
|
+
return (_jsx(CartContext.Provider, { value: {
|
|
48
|
+
cart,
|
|
49
|
+
addToCart,
|
|
50
|
+
removeFromCart,
|
|
51
|
+
updateQuantity,
|
|
52
|
+
clearCart,
|
|
53
|
+
totalItems,
|
|
54
|
+
totalPrice
|
|
55
|
+
}, children: children }));
|
|
56
|
+
}
|
|
57
|
+
export function useCart() {
|
|
58
|
+
const context = useContext(CartContext);
|
|
59
|
+
if (context === undefined) {
|
|
60
|
+
throw new Error('useCart must be used within a CartProvider');
|
|
61
|
+
}
|
|
62
|
+
return context;
|
|
63
|
+
}
|
|
64
64
|
//# sourceMappingURL=CartContext.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface ChatContextType {
|
|
3
|
-
isChatOpen: boolean;
|
|
4
|
-
toggleChat: () => void;
|
|
5
|
-
openChat: () => void;
|
|
6
|
-
closeChat: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function ChatProvider({ children }: {
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare function useChat(): ChatContextType;
|
|
12
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ChatContextType {
|
|
3
|
+
isChatOpen: boolean;
|
|
4
|
+
toggleChat: () => void;
|
|
5
|
+
openChat: () => void;
|
|
6
|
+
closeChat: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function ChatProvider({ children }: {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function useChat(): ChatContextType;
|
|
12
|
+
export {};
|
|
13
13
|
//# sourceMappingURL=ChatContext.d.ts.map
|