@armoyu/ui 1.0.1 → 1.0.3
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/Providers.d.ts +6 -0
- package/dist/app/Providers.d.ts.map +1 -0
- package/dist/app/Providers.js +37 -0
- package/dist/app/Providers.js.map +1 -0
- package/dist/app/api/proxy/[...path]/route.d.ts +22 -0
- package/dist/app/api/proxy/[...path]/route.d.ts.map +1 -0
- package/dist/app/api/proxy/[...path]/route.js +97 -0
- package/dist/app/api/proxy/[...path]/route.js.map +1 -0
- package/dist/app/layout.d.ts.map +1 -1
- package/dist/app/layout.js +16 -23
- package/dist/app/layout.js.map +1 -1
- package/dist/components/RollingNumber.d.ts +6 -6
- package/dist/components/RollingNumber.js +23 -23
- package/dist/components/RollingNumber.js.map +1 -1
- package/dist/components/StatsGrid.d.ts +5 -5
- package/dist/components/modules/auth/Dashboard.d.ts +1 -1
- package/dist/components/modules/auth/PostCard.d.ts +25 -24
- package/dist/components/modules/auth/PostCard.d.ts.map +1 -1
- package/dist/components/modules/auth/PostCard.js +115 -112
- package/dist/components/modules/auth/PostCard.js.map +1 -1
- package/dist/components/modules/auth/PostInteractionsModal.d.ts +11 -11
- package/dist/components/modules/auth/RepostModal.d.ts +21 -21
- package/dist/components/modules/auth/SidebarLeft.d.ts +1 -1
- package/dist/components/modules/auth/SidebarLeft.d.ts.map +1 -1
- package/dist/components/modules/auth/SidebarLeft.js +8 -40
- package/dist/components/modules/auth/SidebarLeft.js.map +1 -1
- package/dist/components/modules/auth/Stories.d.ts +1 -1
- package/dist/components/modules/auth/StoryViewer.d.ts +9 -9
- package/dist/components/modules/auth/widgets/EconomyWidget.d.ts +2 -0
- package/dist/components/modules/auth/widgets/EconomyWidget.d.ts.map +1 -0
- package/dist/components/modules/auth/widgets/EconomyWidget.js +38 -0
- package/dist/components/modules/auth/widgets/EconomyWidget.js.map +1 -0
- package/dist/components/modules/auth/widgets/LeagueWidget.d.ts +2 -0
- package/dist/components/modules/auth/widgets/LeagueWidget.d.ts.map +1 -0
- package/dist/components/modules/auth/widgets/LeagueWidget.js +36 -0
- package/dist/components/modules/auth/widgets/LeagueWidget.js.map +1 -0
- package/dist/components/modules/auth/widgets/MinecraftWidget.d.ts +2 -0
- package/dist/components/modules/auth/widgets/MinecraftWidget.d.ts.map +1 -0
- package/dist/components/modules/auth/widgets/MinecraftWidget.js +36 -0
- package/dist/components/modules/auth/widgets/MinecraftWidget.js.map +1 -0
- package/dist/components/modules/auth/widgets/RankingWidget.d.ts +5 -0
- package/dist/components/modules/auth/widgets/RankingWidget.d.ts.map +1 -0
- package/dist/components/modules/auth/widgets/RankingWidget.js +79 -0
- package/dist/components/modules/auth/widgets/RankingWidget.js.map +1 -0
- package/dist/components/modules/chat/ChatContainer.d.ts +1 -1
- package/dist/components/modules/chat/ChatInput.d.ts +4 -4
- package/dist/components/modules/chat/ChatList.d.ts +6 -6
- package/dist/components/modules/chat/ChatNotes.d.ts +1 -1
- package/dist/components/modules/community/GroupHeader.d.ts +10 -10
- package/dist/components/modules/community/GroupMenu.d.ts +9 -9
- package/dist/components/modules/community/SchoolCard.d.ts +6 -6
- package/dist/components/modules/community/SurveyCard.d.ts +6 -6
- package/dist/components/modules/forum/ForumBoard.d.ts +16 -16
- package/dist/components/modules/forum/ForumBoard.js +6 -6
- package/dist/components/modules/forum/ForumBoard.js.map +1 -1
- package/dist/components/modules/forum/TopicItem.d.ts +15 -15
- package/dist/components/modules/forum/TopicItem.js +6 -6
- package/dist/components/modules/forum/TopicItem.js.map +1 -1
- package/dist/components/modules/guest/Introduction.d.ts +1 -1
- package/dist/components/modules/magaza/BackToStore.d.ts +1 -1
- package/dist/components/modules/magaza/StoreHeader.d.ts +5 -5
- package/dist/components/modules/news/NewsCard.d.ts +11 -11
- package/dist/components/modules/news/NewsComments.d.ts +1 -1
- package/dist/components/modules/profile/ProfileContent.d.ts +4 -4
- package/dist/components/modules/profile/ProfileContent.d.ts.map +1 -1
- package/dist/components/modules/profile/ProfileContent.js +98 -70
- package/dist/components/modules/profile/ProfileContent.js.map +1 -1
- package/dist/components/modules/profile/ProfileHeader.d.ts +7 -7
- package/dist/components/modules/profile/ProfileHeader.js +19 -19
- package/dist/components/modules/profile/ProfileHeader.js.map +1 -1
- package/dist/components/modules/profile/ProfileStats.d.ts +6 -1
- package/dist/components/modules/profile/ProfileStats.d.ts.map +1 -1
- package/dist/components/modules/profile/ProfileStats.js +11 -6
- 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/tabs/AboutTab.d.ts +10 -0
- package/dist/components/modules/profile/tabs/AboutTab.d.ts.map +1 -0
- package/dist/components/modules/profile/tabs/AboutTab.js +9 -0
- package/dist/components/modules/profile/tabs/AboutTab.js.map +1 -0
- package/dist/components/modules/profile/tabs/CareerTab.d.ts +7 -0
- package/dist/components/modules/profile/tabs/CareerTab.d.ts.map +1 -0
- package/dist/components/modules/profile/tabs/CareerTab.js +46 -0
- package/dist/components/modules/profile/tabs/CareerTab.js.map +1 -0
- package/dist/components/modules/profile/tabs/FriendsTab.d.ts +7 -0
- package/dist/components/modules/profile/tabs/FriendsTab.d.ts.map +1 -0
- package/dist/components/modules/profile/tabs/FriendsTab.js +8 -0
- package/dist/components/modules/profile/tabs/FriendsTab.js.map +1 -0
- package/dist/components/modules/profile/tabs/GamesTab.d.ts +7 -0
- package/dist/components/modules/profile/tabs/GamesTab.d.ts.map +1 -0
- package/dist/components/modules/profile/tabs/GamesTab.js +37 -0
- package/dist/components/modules/profile/tabs/GamesTab.js.map +1 -0
- package/dist/components/modules/profile/tabs/PostsTab.d.ts +7 -0
- package/dist/components/modules/profile/tabs/PostsTab.d.ts.map +1 -0
- package/dist/components/modules/profile/tabs/PostsTab.js +81 -0
- package/dist/components/modules/profile/tabs/PostsTab.js.map +1 -0
- package/dist/components/modules/profile/widgets/ProfileBadgesWidget.d.ts +2 -0
- package/dist/components/modules/profile/widgets/ProfileBadgesWidget.d.ts.map +1 -0
- package/dist/components/modules/profile/widgets/ProfileBadgesWidget.js +6 -0
- package/dist/components/modules/profile/widgets/ProfileBadgesWidget.js.map +1 -0
- package/dist/components/modules/profile/widgets/ProfileCloudWidget.d.ts +6 -0
- package/dist/components/modules/profile/widgets/ProfileCloudWidget.d.ts.map +1 -0
- package/dist/components/modules/profile/widgets/ProfileCloudWidget.js +6 -0
- package/dist/components/modules/profile/widgets/ProfileCloudWidget.js.map +1 -0
- package/dist/components/modules/profile/widgets/ProfileFriendsWidget.d.ts +8 -0
- package/dist/components/modules/profile/widgets/ProfileFriendsWidget.d.ts.map +1 -0
- package/dist/components/modules/profile/widgets/ProfileFriendsWidget.js +12 -0
- package/dist/components/modules/profile/widgets/ProfileFriendsWidget.js.map +1 -0
- package/dist/components/modules/stations/StationCard.d.ts +2 -2
- package/dist/components/modules/stations/StationQRModal.d.ts +9 -9
- package/dist/components/shared/DevTools.d.ts +2 -0
- package/dist/components/shared/DevTools.d.ts.map +1 -0
- package/dist/components/shared/DevTools.js +39 -0
- package/dist/components/shared/DevTools.js.map +1 -0
- package/dist/components/shared/FloatingChatButton.d.ts +4 -4
- package/dist/components/shared/Header.d.ts +1 -1
- package/dist/components/shared/Header.d.ts.map +1 -1
- package/dist/components/shared/Header.js +108 -97
- package/dist/components/shared/Header.js.map +1 -1
- package/dist/components/shared/LoginModal.d.ts +4 -4
- package/dist/components/shared/LoginModal.d.ts.map +1 -1
- package/dist/components/shared/LoginModal.js +65 -69
- package/dist/components/shared/LoginModal.js.map +1 -1
- package/dist/components/shared/MainLayoutWrapper.d.ts +3 -3
- package/dist/components/showcase/ProfileTab.d.ts.map +1 -1
- package/dist/components/showcase/ProfileTab.js +43 -3
- package/dist/components/showcase/ProfileTab.js.map +1 -1
- package/dist/components/showcase/SocialTab.d.ts.map +1 -1
- package/dist/components/showcase/SocialTab.js +86 -2
- package/dist/components/showcase/SocialTab.js.map +1 -1
- package/dist/context/ArmoyuContext.d.ts +42 -0
- package/dist/context/ArmoyuContext.d.ts.map +1 -0
- package/dist/context/ArmoyuContext.js +76 -0
- package/dist/context/ArmoyuContext.js.map +1 -0
- package/dist/context/AuthContext.d.ts +18 -18
- package/dist/context/AuthContext.d.ts.map +1 -1
- package/dist/context/AuthContext.js +97 -74
- package/dist/context/AuthContext.js.map +1 -1
- package/dist/context/CartContext.d.ts +16 -16
- package/dist/context/SocketContext.d.ts +12 -12
- package/dist/context/SocketContext.d.ts.map +1 -1
- package/dist/context/SocketContext.js +31 -30
- package/dist/context/SocketContext.js.map +1 -1
- package/dist/index.d.ts +67 -65
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -80
- package/dist/index.js.map +1 -1
- package/dist/lib/ArmoyuUI.d.ts +18 -0
- package/dist/lib/ArmoyuUI.d.ts.map +1 -0
- package/dist/lib/ArmoyuUI.js +25 -0
- package/dist/lib/ArmoyuUI.js.map +1 -0
- package/dist/lib/constants/educationData.d.ts +7 -7
- package/dist/lib/constants/seedData.d.ts +164 -164
- package/dist/lib/constants/seedData.d.ts.map +1 -1
- package/dist/lib/constants/seedData.js +694 -694
- package/dist/lib/constants/seedData.js.map +1 -1
- package/dist/lib/constants/stationData.d.ts +13 -13
- package/dist/lib/constants/stationData.js +166 -166
- package/dist/lib/constants/stationData.js.map +1 -1
- package/dist/lib/constants/surveyData.d.ts +2 -2
- package/dist/lib/constants/teamData.d.ts +12 -12
- package/package.json +14 -12
- package/next.config.ts +0 -13
- package/postcss.config.js +0 -6
- package/src/app/layout.tsx +0 -67
- package/src/app/page.tsx +0 -101
- package/src/components/Button.tsx +0 -41
- package/src/components/GenderStatsBar.tsx +0 -66
- package/src/components/RollingNumber.tsx +0 -50
- package/src/components/Slider.tsx +0 -114
- package/src/components/StatsGrid.tsx +0 -35
- package/src/components/ViewModeToggle.tsx +0 -39
- package/src/components/modules/auth/Dashboard.tsx +0 -649
- package/src/components/modules/auth/MediaLightbox.tsx +0 -112
- package/src/components/modules/auth/PostCard.tsx +0 -556
- package/src/components/modules/auth/PostInteractionsModal.tsx +0 -138
- package/src/components/modules/auth/RepostModal.tsx +0 -167
- package/src/components/modules/auth/SidebarLeft.tsx +0 -237
- package/src/components/modules/auth/Stories.tsx +0 -69
- package/src/components/modules/auth/StoryViewer.tsx +0 -146
- package/src/components/modules/chat/ChatContainer.tsx +0 -332
- package/src/components/modules/chat/ChatInput.tsx +0 -57
- package/src/components/modules/chat/ChatList.tsx +0 -179
- package/src/components/modules/chat/ChatMessage.tsx +0 -43
- package/src/components/modules/chat/ChatNotes.tsx +0 -58
- package/src/components/modules/community/GroupHeader.tsx +0 -111
- package/src/components/modules/community/GroupMenu.tsx +0 -82
- package/src/components/modules/community/SchoolCard.tsx +0 -104
- package/src/components/modules/community/SurveyCard.tsx +0 -149
- package/src/components/modules/forum/ForumBoard.tsx +0 -78
- package/src/components/modules/forum/ForumPost.tsx +0 -71
- package/src/components/modules/forum/NewTopicModal.tsx +0 -112
- package/src/components/modules/forum/TopicItem.tsx +0 -72
- package/src/components/modules/galleries/GalleryCard.tsx +0 -66
- package/src/components/modules/giveaways/GiveawayCard.tsx +0 -76
- package/src/components/modules/groups/ApplicationModal.tsx +0 -133
- package/src/components/modules/groups/GroupCard.tsx +0 -96
- package/src/components/modules/guest/Introduction.tsx +0 -60
- package/src/components/modules/magaza/BackToStore.tsx +0 -53
- package/src/components/modules/magaza/StoreHeader.tsx +0 -74
- package/src/components/modules/news/NewsCard.tsx +0 -66
- package/src/components/modules/news/NewsComments.tsx +0 -141
- package/src/components/modules/profile/CloudStorageModal.tsx +0 -200
- package/src/components/modules/profile/EditProfileModal.tsx +0 -191
- package/src/components/modules/profile/ProfileContent.tsx +0 -491
- package/src/components/modules/profile/ProfileHeader.tsx +0 -128
- package/src/components/modules/profile/ProfileStats.tsx +0 -72
- package/src/components/modules/profile/TeamSelectorModal.tsx +0 -129
- package/src/components/modules/stations/StationCard.tsx +0 -95
- package/src/components/modules/stations/StationQRModal.tsx +0 -102
- package/src/components/shared/FloatingChatButton.tsx +0 -57
- package/src/components/shared/Footer.tsx +0 -77
- package/src/components/shared/Header.tsx +0 -799
- package/src/components/shared/LoginModal.tsx +0 -208
- package/src/components/shared/MainLayoutWrapper.tsx +0 -15
- package/src/components/shared/PageWidth.tsx +0 -22
- package/src/components/showcase/CommunityTab.tsx +0 -22
- package/src/components/showcase/CorporateTab.tsx +0 -38
- package/src/components/showcase/GeneralTab.tsx +0 -41
- package/src/components/showcase/MessagesTab.tsx +0 -26
- package/src/components/showcase/ProfileTab.tsx +0 -20
- package/src/components/showcase/ShopTab.tsx +0 -24
- package/src/components/showcase/SocialTab.tsx +0 -28
- package/src/context/AuthContext.tsx +0 -104
- package/src/context/CartContext.tsx +0 -93
- package/src/context/ChatContext.tsx +0 -32
- package/src/context/LayoutContext.tsx +0 -29
- package/src/context/SocketContext.tsx +0 -50
- package/src/context/ThemeContext.tsx +0 -52
- package/src/index.ts +0 -96
- package/src/lib/constants/educationData.ts +0 -124
- package/src/lib/constants/punishmentData.ts +0 -201
- package/src/lib/constants/seedData.ts +0 -758
- package/src/lib/constants/stationData.ts +0 -170
- package/src/lib/constants/surveyData.ts +0 -53
- package/src/lib/constants/teamData.ts +0 -69
- package/src/lib/utils/numberFormat.ts +0 -16
- package/src/lib/utils/odpUtils.ts +0 -51
- package/src/types/index.ts +0 -1
- package/src/types/stats.ts +0 -17
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ArmoyuUI } from '../lib/ArmoyuUI';
|
|
3
|
+
export interface ArmoyuNavigationConfig {
|
|
4
|
+
profilePrefix?: string;
|
|
5
|
+
groupPrefix?: string;
|
|
6
|
+
forumPrefix?: string;
|
|
7
|
+
educationPrefix?: string;
|
|
8
|
+
newsPrefix?: string;
|
|
9
|
+
galleryPrefix?: string;
|
|
10
|
+
giveawayPrefix?: string;
|
|
11
|
+
projectPrefix?: string;
|
|
12
|
+
storePrefix?: string;
|
|
13
|
+
managementPrefix?: string;
|
|
14
|
+
myArticlesPrefix?: string;
|
|
15
|
+
pollPrefix?: string;
|
|
16
|
+
supportPrefix?: string;
|
|
17
|
+
}
|
|
18
|
+
interface ArmoyuContextType {
|
|
19
|
+
ui: ArmoyuUI;
|
|
20
|
+
api: ArmoyuUI['api'];
|
|
21
|
+
apiKey: string;
|
|
22
|
+
token: string;
|
|
23
|
+
navigation: Required<ArmoyuNavigationConfig>;
|
|
24
|
+
setGlobalApiKey: (key: string) => void;
|
|
25
|
+
setGlobalToken: (token: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface ArmoyuProviderProps {
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
ui: ArmoyuUI;
|
|
30
|
+
navigation?: ArmoyuNavigationConfig;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* ArmoyuProvider provides the global ArmoyuUI instance to all UI components.
|
|
34
|
+
* This is required for any component that interacts with the ARMOYU backend.
|
|
35
|
+
*/
|
|
36
|
+
export declare function ArmoyuProvider({ children, ui, navigation }: ArmoyuProviderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
/**
|
|
38
|
+
* Custom hook to access the ArmoyuApi instance.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useArmoyu(): ArmoyuContextType;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=ArmoyuContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArmoyuContext.d.ts","sourceRoot":"","sources":["../../src/context/ArmoyuContext.tsx"],"names":[],"mappings":"AAEA,OAAc,EAA6B,SAAS,EAAoC,MAAM,OAAO,CAAC;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,QAAQ,CAAC;IACb,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IAC7C,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAID,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,mBAAmB,kDAmE/E;AAED;;GAEG;AACH,wBAAgB,SAAS,sBAMxB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useCallback, useEffect } from 'react';
|
|
4
|
+
const ArmoyuContext = createContext(undefined);
|
|
5
|
+
/**
|
|
6
|
+
* ArmoyuProvider provides the global ArmoyuUI instance to all UI components.
|
|
7
|
+
* This is required for any component that interacts with the ARMOYU backend.
|
|
8
|
+
*/
|
|
9
|
+
export function ArmoyuProvider({ children, ui, navigation }) {
|
|
10
|
+
const [apiKey, setApiKey] = useState('armoyu_showcase_key');
|
|
11
|
+
const [token, setToken] = useState('');
|
|
12
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
13
|
+
// Sadece istemci tarafında localStorage'dan yükle
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setIsMounted(true);
|
|
16
|
+
const savedApiKey = localStorage.getItem('armoyu_showcase_apiKey');
|
|
17
|
+
const savedToken = localStorage.getItem('armoyu_showcase_token');
|
|
18
|
+
if (savedApiKey) {
|
|
19
|
+
setApiKey(savedApiKey);
|
|
20
|
+
ui.api.setApiKey(savedApiKey);
|
|
21
|
+
}
|
|
22
|
+
if (savedToken) {
|
|
23
|
+
setToken(savedToken);
|
|
24
|
+
ui.api.setToken(savedToken);
|
|
25
|
+
}
|
|
26
|
+
}, [ui]);
|
|
27
|
+
const setGlobalApiKey = useCallback((key) => {
|
|
28
|
+
setApiKey(key);
|
|
29
|
+
ui.api.setApiKey(key);
|
|
30
|
+
localStorage.setItem('armoyu_showcase_apiKey', key);
|
|
31
|
+
}, [ui]);
|
|
32
|
+
const setGlobalToken = useCallback((t) => {
|
|
33
|
+
setToken(t);
|
|
34
|
+
ui.api.setToken(t);
|
|
35
|
+
localStorage.setItem('armoyu_showcase_token', t);
|
|
36
|
+
}, [ui]);
|
|
37
|
+
if (!isMounted || !ui) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const defaultNavigation = {
|
|
41
|
+
profilePrefix: '/oyuncular',
|
|
42
|
+
groupPrefix: '/gruplar',
|
|
43
|
+
forumPrefix: '/forum',
|
|
44
|
+
educationPrefix: '/egitim',
|
|
45
|
+
newsPrefix: '/haberler',
|
|
46
|
+
galleryPrefix: '/galeriler',
|
|
47
|
+
giveawayPrefix: '/cekilisler',
|
|
48
|
+
projectPrefix: '/projeler',
|
|
49
|
+
storePrefix: '/magaza',
|
|
50
|
+
managementPrefix: '/yonetim',
|
|
51
|
+
myArticlesPrefix: '/yazilarim',
|
|
52
|
+
pollPrefix: '/anketler',
|
|
53
|
+
supportPrefix: '/destek',
|
|
54
|
+
...navigation
|
|
55
|
+
};
|
|
56
|
+
return (_jsx(ArmoyuContext.Provider, { value: {
|
|
57
|
+
ui,
|
|
58
|
+
api: ui.api,
|
|
59
|
+
apiKey,
|
|
60
|
+
token,
|
|
61
|
+
navigation: defaultNavigation,
|
|
62
|
+
setGlobalApiKey,
|
|
63
|
+
setGlobalToken
|
|
64
|
+
}, children: children }));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Custom hook to access the ArmoyuApi instance.
|
|
68
|
+
*/
|
|
69
|
+
export function useArmoyu() {
|
|
70
|
+
const context = useContext(ArmoyuContext);
|
|
71
|
+
if (context === undefined) {
|
|
72
|
+
throw new Error('useArmoyu must be used within an ArmoyuProvider');
|
|
73
|
+
}
|
|
74
|
+
return context;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=ArmoyuContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArmoyuContext.js","sourceRoot":"","sources":["../../src/context/ArmoyuContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAa,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA6BtG,MAAM,aAAa,GAAG,aAAa,CAAgC,SAAS,CAAC,CAAC;AAQ9E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAuB;IAC9E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC5D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAA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,MAAM,iBAAiB,GAAqC;QAC1D,aAAa,EAAE,YAAY;QAC3B,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,QAAQ;QACrB,eAAe,EAAE,SAAS;QAC1B,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE,YAAY;QAC3B,cAAc,EAAE,aAAa;QAC7B,aAAa,EAAE,WAAW;QAC1B,WAAW,EAAE,SAAS;QACtB,gBAAgB,EAAE,UAAU;QAC5B,gBAAgB,EAAE,YAAY;QAC9B,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE,SAAS;QACxB,GAAG,UAAU;KACd,CAAC;IAEF,OAAO,CACL,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC7B,EAAE;YACF,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,MAAM;YACN,KAAK;YACL,UAAU,EAAE,iBAAiB;YAC7B,eAAe;YACf,cAAc;SACf,YACE,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -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: (
|
|
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: (username: string, password: string) => Promise<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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG7C,UAAU,eAAe;IACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,UAAU,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAID,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAmGvE;AAED,wBAAgB,OAAO,oBAMtB"}
|
|
@@ -1,75 +1,98 @@
|
|
|
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 {
|
|
6
|
-
const AuthContext = createContext(undefined);
|
|
7
|
-
export function AuthProvider({ children }) {
|
|
8
|
-
const
|
|
9
|
-
const [
|
|
10
|
-
const [
|
|
11
|
-
const [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setSession(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
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 { useArmoyu } from './ArmoyuContext';
|
|
6
|
+
const AuthContext = createContext(undefined);
|
|
7
|
+
export function AuthProvider({ children }) {
|
|
8
|
+
const { api } = useArmoyu();
|
|
9
|
+
const [user, setUser] = useState(null);
|
|
10
|
+
const [session, setSession] = useState(null);
|
|
11
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
12
|
+
const [isLoginModalOpen, setIsLoginModalOpen] = useState(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
async function restoreSession() {
|
|
15
|
+
// Check local storage for persistent token
|
|
16
|
+
const token = localStorage.getItem('armoyu_token');
|
|
17
|
+
if (token) {
|
|
18
|
+
try {
|
|
19
|
+
// Set token in core API client
|
|
20
|
+
api.setToken(token);
|
|
21
|
+
// Request current user profile from real API
|
|
22
|
+
const me = await api.auth.me();
|
|
23
|
+
if (me) {
|
|
24
|
+
setUser(me);
|
|
25
|
+
setSession(new Session({ user: me, token }));
|
|
26
|
+
console.log('[AuthContext] Session restored for:', me.username);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Token might be expired or invalid
|
|
30
|
+
localStorage.removeItem('armoyu_token');
|
|
31
|
+
api.setToken(null);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error('[AuthContext] Failed to restore session:', e);
|
|
36
|
+
localStorage.removeItem('armoyu_token');
|
|
37
|
+
api.setToken(null);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
}
|
|
42
|
+
restoreSession();
|
|
43
|
+
}, []);
|
|
44
|
+
const login = async (username, password) => {
|
|
45
|
+
try {
|
|
46
|
+
// Real API login via core library
|
|
47
|
+
const { user: loggedInUser, session: newSession } = await api.auth.login(username, password);
|
|
48
|
+
setUser(loggedInUser);
|
|
49
|
+
setSession(newSession);
|
|
50
|
+
// Store token in localStorage since Core library is now stateless
|
|
51
|
+
if (newSession.token) {
|
|
52
|
+
localStorage.setItem('armoyu_token', newSession.token);
|
|
53
|
+
}
|
|
54
|
+
console.log('[AuthContext] Login successful for:', loggedInUser.username);
|
|
55
|
+
setIsLoginModalOpen(false);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error('[AuthContext] Login failed:', error);
|
|
59
|
+
throw error; // Let the component handle the error UI
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const logout = () => {
|
|
63
|
+
api.auth.logout(); // Clears internal state and localStorage
|
|
64
|
+
setUser(null);
|
|
65
|
+
setSession(null);
|
|
66
|
+
};
|
|
67
|
+
const updateUser = (updatedUser) => {
|
|
68
|
+
setUser(updatedUser);
|
|
69
|
+
if (session) {
|
|
70
|
+
setSession(new Session({ ...session, user: updatedUser }));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const updateSession = (updatedSession) => {
|
|
74
|
+
setSession(updatedSession);
|
|
75
|
+
if (updatedSession.token) {
|
|
76
|
+
api.setToken(updatedSession.token);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return (_jsx(AuthContext.Provider, { value: {
|
|
80
|
+
user,
|
|
81
|
+
session,
|
|
82
|
+
login,
|
|
83
|
+
logout,
|
|
84
|
+
isLoading,
|
|
85
|
+
isLoginModalOpen,
|
|
86
|
+
setIsLoginModalOpen,
|
|
87
|
+
updateUser,
|
|
88
|
+
updateSession
|
|
89
|
+
}, children: children }));
|
|
90
|
+
}
|
|
91
|
+
export function useAuth() {
|
|
92
|
+
const context = useContext(AuthContext);
|
|
93
|
+
if (context === undefined) {
|
|
94
|
+
throw new Error('useAuth must be used within an AuthProvider');
|
|
95
|
+
}
|
|
96
|
+
return context;
|
|
97
|
+
}
|
|
75
98
|
//# sourceMappingURL=AuthContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.js","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAQ,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthContext.js","sourceRoot":"","sources":["../../src/context/AuthContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAQ,OAAO,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc5C,MAAM,WAAW,GAAG,aAAa,CAA8B,SAAS,CAAC,CAAC;AAE1E,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAiC;IACtE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,CAAC;IAC5B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAc,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAC7D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,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C,KAAK,EAAE,CAAC;YACzB,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC3B,IAAI;YACJ,OAAO;YACP,KAAK;YACL,MAAM;YACN,SAAS;YACT,gBAAgB;YAChB,mBAAmB;YACnB,UAAU;YACV,aAAa;SACd,YACE,QAAQ,GACY,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -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,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SocketEvent } from '@armoyu/core';
|
|
3
|
-
interface SocketContextType {
|
|
4
|
-
isConnected: boolean;
|
|
5
|
-
emit: (event: SocketEvent, data: any) => void;
|
|
6
|
-
on: (event: SocketEvent, callback: (data: any) => void) => () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function SocketProvider({ children }: {
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare function useSocket(): SocketContextType;
|
|
12
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SocketEvent } from '@armoyu/core';
|
|
3
|
+
interface SocketContextType {
|
|
4
|
+
isConnected: boolean;
|
|
5
|
+
emit: (event: SocketEvent, data: any) => void;
|
|
6
|
+
on: (event: SocketEvent, callback: (data: any) => void) => () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function SocketProvider({ children }: {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function useSocket(): SocketContextType;
|
|
12
|
+
export {};
|
|
13
13
|
//# sourceMappingURL=SocketContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocketContext.d.ts","sourceRoot":"","sources":["../../src/context/SocketContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"SocketContext.d.ts","sourceRoot":"","sources":["../../src/context/SocketContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C,UAAU,iBAAiB;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAE9C,EAAE,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACvE;AAID,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CA0BzE;AAED,wBAAgB,SAAS,sBAMxB"}
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
const SocketContext = createContext(undefined);
|
|
6
|
-
export function SocketProvider({ children }) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
+
import { useArmoyu } from './ArmoyuContext';
|
|
5
|
+
const SocketContext = createContext(undefined);
|
|
6
|
+
export function SocketProvider({ children }) {
|
|
7
|
+
const { api } = useArmoyu();
|
|
8
|
+
const [isConnected, setIsConnected] = useState(api.socket.isConnected);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const handleConnect = () => setIsConnected(true);
|
|
11
|
+
const handleDisconnect = () => setIsConnected(false);
|
|
12
|
+
const offConnect = api.socket.on('connect', handleConnect);
|
|
13
|
+
const offDisconnect = api.socket.on('disconnect', handleDisconnect);
|
|
14
|
+
return () => {
|
|
15
|
+
offConnect();
|
|
16
|
+
offDisconnect();
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
19
|
+
return (_jsx(SocketContext.Provider, { value: {
|
|
20
|
+
isConnected,
|
|
21
|
+
emit: api.socket.emit.bind(api.socket),
|
|
22
|
+
on: api.socket.on.bind(api.socket)
|
|
23
|
+
}, children: children }));
|
|
24
|
+
}
|
|
25
|
+
export function useSocket() {
|
|
26
|
+
const context = useContext(SocketContext);
|
|
27
|
+
if (context === undefined) {
|
|
28
|
+
throw new Error('useSocket must be used within a SocketProvider');
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
31
32
|
//# sourceMappingURL=SocketContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocketContext.js","sourceRoot":"","sources":["../../src/context/SocketContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SocketContext.js","sourceRoot":"","sources":["../../src/context/SocketContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,aAAa,GAAG,aAAa,CAAgC,SAAS,CAAC,CAAC;AAE9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