create-gufran-expo-app 2.0.0 → 2.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/lib/createApp.js +7 -2
- package/package.json +1 -1
- package/template/App.tsx +118 -0
- package/template/ReactotronConfig.js +5 -0
- package/template/android/app/build.gradle +184 -0
- package/template/android/app/debug.keystore +0 -0
- package/template/android/app/google-services.json +29 -0
- package/template/android/app/proguard-rules.pro +14 -0
- package/template/android/app/src/debug/AndroidManifest.xml +7 -0
- package/template/android/app/src/debugOptimized/AndroidManifest.xml +7 -0
- package/template/android/app/src/main/AndroidManifest.xml +28 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Bold.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Light.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Medium.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-Regular.ttf +0 -0
- package/template/android/app/src/main/assets/fonts/Outfit-SemiBold.ttf +0 -0
- package/template/android/app/src/main/java/com/club/yakka/MainActivity.kt +61 -0
- package/template/android/app/src/main/java/com/club/yakka/MainApplication.kt +60 -0
- package/template/android/app/src/main/res/drawable/ic_launcher_background.xml +6 -0
- package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/template/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png +0 -0
- package/template/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/template/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/template/android/app/src/main/res/values/colors.xml +6 -0
- package/template/android/app/src/main/res/values/strings.xml +5 -0
- package/template/android/app/src/main/res/values/styles.xml +14 -0
- package/template/android/app/src/main/res/values-night/colors.xml +1 -0
- package/template/android/build.gradle +33 -0
- package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/template/android/gradle.properties +65 -0
- package/template/android/gradlew +251 -0
- package/template/android/gradlew.bat +94 -0
- package/template/android/settings.gradle +39 -0
- package/template/app.json +69 -0
- package/template/assets/adaptive-icon.png +0 -0
- package/template/assets/adaptive-icon1.png +0 -0
- package/template/assets/app_icon.png +0 -0
- package/template/assets/favicon.png +0 -0
- package/template/assets/icon.png +0 -0
- package/template/assets/splash-icon.png +0 -0
- package/template/babel-plugin-disable-font-scaling.js +41 -0
- package/template/babel.config.js +28 -0
- package/template/firebase.json +5 -0
- package/template/index.ts +24 -0
- package/template/ios/.xcode.env +11 -0
- package/template/ios/ClubYakka/AppDelegate.swift +74 -0
- package/template/ios/ClubYakka/ClubYakka-Bridging-Header.h +3 -0
- package/template/ios/ClubYakka/ClubYakka.entitlements +8 -0
- package/template/ios/ClubYakka/GoogleService-Info.plist +30 -0
- package/template/ios/ClubYakka/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
- package/template/ios/ClubYakka/Images.xcassets/AppIcon.appiconset/Contents.json +14 -0
- package/template/ios/ClubYakka/Images.xcassets/Contents.json +6 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenBackground.colorset/Contents.json +20 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/Contents.json +23 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/image.png +0 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/image@2x.png +0 -0
- package/template/ios/ClubYakka/Images.xcassets/SplashScreenLegacy.imageset/image@3x.png +0 -0
- package/template/ios/ClubYakka/Info.plist +101 -0
- package/template/ios/ClubYakka/PrivacyInfo.xcprivacy +50 -0
- package/template/ios/ClubYakka/SplashScreen.storyboard +48 -0
- package/template/ios/ClubYakka/Supporting/Expo.plist +12 -0
- package/template/ios/ClubYakka.xcodeproj/project.pbxproj +669 -0
- package/template/ios/ClubYakka.xcodeproj/xcshareddata/xcschemes/ClubYakka.xcscheme +88 -0
- package/template/ios/ClubYakka.xcworkspace/contents.xcworkspacedata +10 -0
- package/template/ios/ClubYakka.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +5 -0
- package/template/ios/Podfile +84 -0
- package/template/ios/Podfile.lock +2698 -0
- package/template/ios/Podfile.properties.json +8 -0
- package/template/metro.config.js +17 -0
- package/template/package.json +70 -0
- package/template/patches/react-native-background-upload+6.6.0.patch +704 -0
- package/template/react-native.config.js +7 -0
- package/template/src/assets/fonts/Outfit-Bold.ttf +0 -0
- package/template/src/assets/fonts/Outfit-Light.ttf +0 -0
- package/template/src/assets/fonts/Outfit-Medium.ttf +0 -0
- package/template/src/assets/fonts/Outfit-Regular.ttf +0 -0
- package/template/src/assets/fonts/Outfit-SemiBold.ttf +0 -0
- package/template/src/assets/icons/BG.svg +33 -0
- package/template/src/assets/icons/Ic_Users.svg +6 -0
- package/template/src/assets/icons/arrow-left-white.svg +4 -0
- package/template/src/assets/icons/arrow-left.svg +4 -0
- package/template/src/assets/icons/bell.svg +4 -0
- package/template/src/assets/icons/bottomSheetIcone.svg +3 -0
- package/template/src/assets/icons/call.svg +4 -0
- package/template/src/assets/icons/camera.svg +0 -0
- package/template/src/assets/icons/chatAppleGreenBG.svg +22 -0
- package/template/src/assets/icons/check.svg +4 -0
- package/template/src/assets/icons/check_Radio.svg +4 -0
- package/template/src/assets/icons/chevron-right.svg +3 -0
- package/template/src/assets/icons/clubDefauldImage.png +0 -0
- package/template/src/assets/icons/curvBackgroundView.svg +3 -0
- package/template/src/assets/icons/defaultClub.png +0 -0
- package/template/src/assets/icons/email.svg +3 -0
- package/template/src/assets/icons/emptyUser.svg +5 -0
- package/template/src/assets/icons/eye-Hide.svg +8 -0
- package/template/src/assets/icons/eye.svg +4 -0
- package/template/src/assets/icons/gallery.svg +4 -0
- package/template/src/assets/icons/home.svg +4 -0
- package/template/src/assets/icons/ic_Calendar.svg +14 -0
- package/template/src/assets/icons/ic_Calendar_blue.svg +12 -0
- package/template/src/assets/icons/ic_Calendar_white.svg +12 -0
- package/template/src/assets/icons/ic_Chat.svg +14 -0
- package/template/src/assets/icons/ic_ChatAppleGreen.svg +21 -0
- package/template/src/assets/icons/ic_ChatAppleWhite.svg +21 -0
- package/template/src/assets/icons/ic_Download.svg +6 -0
- package/template/src/assets/icons/ic_Events.svg +6 -0
- package/template/src/assets/icons/ic_HeadCoachIcon.svg +3 -0
- package/template/src/assets/icons/ic_Membership.svg +10 -0
- package/template/src/assets/icons/ic_Notification.svg +6 -0
- package/template/src/assets/icons/ic_Raffles.svg +14 -0
- package/template/src/assets/icons/ic_Referral_Members.svg +12 -0
- package/template/src/assets/icons/ic_Shop.svg +13 -0
- package/template/src/assets/icons/ic_Teams.svg +8 -0
- package/template/src/assets/icons/ic_Volunteer.svg +9 -0
- package/template/src/assets/icons/ic_add.svg +3 -0
- package/template/src/assets/icons/ic_addCircle.svg +5 -0
- package/template/src/assets/icons/ic_chatSend.svg +4 -0
- package/template/src/assets/icons/ic_chat_blue_bg.svg +22 -0
- package/template/src/assets/icons/ic_clock_blue.svg +4 -0
- package/template/src/assets/icons/ic_delete.svg +8 -0
- package/template/src/assets/icons/ic_more.svg +5 -0
- package/template/src/assets/icons/ic_mute.svg +10 -0
- package/template/src/assets/icons/ic_pdf.svg +3 -0
- package/template/src/assets/icons/ic_pending_AppleGreen.svg +11 -0
- package/template/src/assets/icons/ic_right_appleGreen.svg +11 -0
- package/template/src/assets/icons/ic_unread_chat_blue_bg.svg +23 -0
- package/template/src/assets/icons/ic_volunteer_Member.svg +8 -0
- package/template/src/assets/icons/index.ts +144 -0
- package/template/src/assets/icons/location-blue.svg +4 -0
- package/template/src/assets/icons/location-white.svg +4 -0
- package/template/src/assets/icons/location.svg +4 -0
- package/template/src/assets/icons/lock.svg +5 -0
- package/template/src/assets/icons/log-out.svg +5 -0
- package/template/src/assets/icons/login_logo.svg +9 -0
- package/template/src/assets/icons/mail.svg +4 -0
- package/template/src/assets/icons/or_saprater.svg +5 -0
- package/template/src/assets/icons/password.svg +4 -0
- package/template/src/assets/icons/profile-appleGreen.svg +6 -0
- package/template/src/assets/icons/search.svg +3 -0
- package/template/src/assets/icons/settings.svg +4 -0
- package/template/src/assets/icons/success.svg +4 -0
- package/template/src/assets/icons/unCheck_Radio.svg +3 -0
- package/template/src/assets/icons/uncheck.svg +3 -0
- package/template/src/assets/icons/upload_Image.svg +6 -0
- package/template/src/assets/icons/upload_Image_Member.svg +6 -0
- package/template/src/assets/icons/user.svg +4 -0
- package/template/src/assets/icons/wifi.svg +1 -0
- package/template/src/assets/images/Splash.png +0 -0
- package/template/src/assets/images/SplashLogo.png +0 -0
- package/template/src/assets/images/background.png +0 -0
- package/template/src/assets/images/clubDefauldImage.png +0 -0
- package/template/src/assets/images/index.tsx +9 -0
- package/template/src/assets/index.ts +1 -0
- package/template/src/components/common/AddMemberModal.tsx +543 -0
- package/template/src/components/common/AppLoader.tsx +91 -0
- package/template/src/components/common/Button.tsx +173 -0
- package/template/src/components/common/ClubCard.tsx +248 -0
- package/template/src/components/common/Icon.tsx +93 -0
- package/template/src/components/common/IconAlt.tsx +65 -0
- package/template/src/components/common/IconButton.tsx +92 -0
- package/template/src/components/common/ImagePicker.tsx +451 -0
- package/template/src/components/common/LoadingSpinner.tsx +30 -0
- package/template/src/components/common/OTPInput.tsx +128 -0
- package/template/src/components/common/ReminderCalendar.tsx +129 -0
- package/template/src/components/common/ReminderCardItem.tsx +91 -0
- package/template/src/components/common/SafeAreaWrapper.tsx +27 -0
- package/template/src/components/common/SetReminderModal.tsx +308 -0
- package/template/src/components/common/SlowInternet.js +57 -0
- package/template/src/components/common/TeamCard.tsx +297 -0
- package/template/src/components/common/TextInput.tsx +227 -0
- package/template/src/components/common/ToastConfig.tsx +103 -0
- package/template/src/components/common/ToastManager.ts +86 -0
- package/template/src/components/common/UploadProgressModal.tsx +284 -0
- package/template/src/components/common/WrapperContainer.tsx +39 -0
- package/template/src/components/common/index.ts +19 -0
- package/template/src/constants/Constants.tsx +7 -0
- package/template/src/constants/Fonts.tsx +30 -0
- package/template/src/constants/index.ts +45 -0
- package/template/src/constants/strings.ts +211 -0
- package/template/src/constants/theme.ts +72 -0
- package/template/src/contexts/AuthContext.tsx +268 -0
- package/template/src/contexts/index.ts +2 -0
- package/template/src/hooks/index.ts +3 -0
- package/template/src/hooks/useImageUpload.ts +199 -0
- package/template/src/index.ts +8 -0
- package/template/src/navigation/AuthStack.tsx +67 -0
- package/template/src/navigation/MainStack.tsx +183 -0
- package/template/src/navigation/MiddleStack.tsx +35 -0
- package/template/src/navigation/RootNavigator.tsx +101 -0
- package/template/src/navigation/index.ts +5 -0
- package/template/src/navigation/navigationRef.ts +5 -0
- package/template/src/providers/QueryProvider.tsx +30 -0
- package/template/src/screens/DetailsScreen.tsx +271 -0
- package/template/src/screens/HomeScreen.tsx +736 -0
- package/template/src/screens/ProfileScreen.tsx +202 -0
- package/template/src/screens/SettingsScreen.tsx +253 -0
- package/template/src/screens/SportHubScreen.tsx +280 -0
- package/template/src/screens/auth/AddMamber.tsx +428 -0
- package/template/src/screens/auth/ForgotPasswordScreen.tsx +176 -0
- package/template/src/screens/auth/LoginScreen.tsx +286 -0
- package/template/src/screens/auth/OTPVerifyScreen.tsx +359 -0
- package/template/src/screens/auth/RegisterScreen.tsx +430 -0
- package/template/src/screens/auth/SuccessScreen.tsx +201 -0
- package/template/src/screens/auth/WalcomeScreen.tsx +274 -0
- package/template/src/screens/auth/index.ts +8 -0
- package/template/src/screens/chat/ChatScreen.tsx +1819 -0
- package/template/src/screens/chat/ChatThreadsScreen.tsx +360 -0
- package/template/src/screens/chat/ReportMessageScreen.tsx +238 -0
- package/template/src/screens/clubs/Announcements.tsx +426 -0
- package/template/src/screens/clubs/BuyRaffleTicketsScreen.tsx +568 -0
- package/template/src/screens/clubs/ClubDeteils.tsx +497 -0
- package/template/src/screens/clubs/JoinClub.tsx +841 -0
- package/template/src/screens/events/EventScreen.tsx +460 -0
- package/template/src/screens/index.ts +42 -0
- package/template/src/screens/raffles/MyReferralMembersScreen.tsx +758 -0
- package/template/src/screens/raffles/RaffleDetailsScreen.tsx +762 -0
- package/template/src/screens/raffles/RafflesScreen.tsx +495 -0
- package/template/src/screens/raffles/SetRaffleReminderScreen.tsx +390 -0
- package/template/src/screens/teams/JoinTeamScreen.tsx +464 -0
- package/template/src/screens/teams/MyTeamDetailsScreen.tsx +979 -0
- package/template/src/screens/teams/MyTeamScreen.tsx +568 -0
- package/template/src/screens/teams/PendingRequestsScreen.tsx +426 -0
- package/template/src/screens/volunteerOpportunities/SetReminderScreen.tsx +631 -0
- package/template/src/screens/volunteerOpportunities/VolunteerOpportunitiesDetailsScreen.tsx +1049 -0
- package/template/src/screens/volunteerOpportunities/VolunteerOpportunitiesScreen.tsx +608 -0
- package/template/src/services/api.ts +167 -0
- package/template/src/services/authService.ts +422 -0
- package/template/src/services/index.ts +5 -0
- package/template/src/services/mainServices.ts +1963 -0
- package/template/src/stores/authStore.ts +159 -0
- package/template/src/stores/index.ts +2 -0
- package/template/src/types/index.ts +85 -0
- package/template/src/types/navigation.ts +206 -0
- package/template/src/utils/AzureUploaderService.ts +371 -0
- package/template/src/utils/ClubSearchManager.ts +222 -0
- package/template/src/utils/NotificationManager.ts +503 -0
- package/template/src/utils/UploadDebugUtil.ts +107 -0
- package/template/src/utils/imagePicker.ts +321 -0
- package/template/src/utils/index.ts +111 -0
- package/template/src/utils/permissions.ts +277 -0
- package/template/src/utils/scaling.ts +14 -0
- package/template/src/utils/storage.ts +247 -0
- package/template/src/utils/usePermissions.ts +275 -0
- package/template/src/utils/validation.ts +340 -0
- package/template/tsconfig.json +50 -0
- package/template/types/svg.d.ts +6 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { MMKV } from 'react-native-mmkv';
|
|
3
|
+
import { StorageService } from '../utils/storage';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
import ToastManager from '../components/common/ToastManager';
|
|
6
|
+
import { useAuthStore } from '../stores/authStore';
|
|
7
|
+
|
|
8
|
+
// API Configuration
|
|
9
|
+
export const API_BASE_URL = `${process.env.EXPO_PUBLIC_API_BASE_URL}/api/v1/`; // prod api url
|
|
10
|
+
export const CHAT_HUB_URL = `${process.env.EXPO_PUBLIC_API_BASE_URL}/chathub`; // dev chat hub url
|
|
11
|
+
|
|
12
|
+
// Create axios instance with default config
|
|
13
|
+
const offsetTime = new Date().getTimezoneOffset() * 60 * -1;
|
|
14
|
+
|
|
15
|
+
// MMKV default storage (NotificationManager saves fcmToken here)
|
|
16
|
+
const mmkvDefaultStorage = new MMKV();
|
|
17
|
+
|
|
18
|
+
// Helpers to manage the FCM device token within this module
|
|
19
|
+
export const setFCMDeviceToken = (token: string): void => {
|
|
20
|
+
try {
|
|
21
|
+
if (token) {
|
|
22
|
+
mmkvDefaultStorage.set('fcmToken', token);
|
|
23
|
+
}
|
|
24
|
+
} catch { }
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getFCMDeviceToken = (): string | undefined => {
|
|
28
|
+
try {
|
|
29
|
+
const token = mmkvDefaultStorage.getString('fcmToken');
|
|
30
|
+
return token || undefined;
|
|
31
|
+
} catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const apiClient = axios.create({
|
|
37
|
+
baseURL: API_BASE_URL,
|
|
38
|
+
timeout: 10000,
|
|
39
|
+
headers: {
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
UtcOffsetInSecond: offsetTime,
|
|
42
|
+
AppVersion: 1,
|
|
43
|
+
DeviceTypeId: Platform.OS == "android" ? 1 : 2,
|
|
44
|
+
DeviceToken: ""
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Request interceptor to add auth tokens
|
|
49
|
+
apiClient.interceptors.request.use(
|
|
50
|
+
(config) => {
|
|
51
|
+
// Add auth tokens if available
|
|
52
|
+
const tokens = StorageService.auth.getTokens();
|
|
53
|
+
if (tokens.accessToken) {
|
|
54
|
+
config.headers.AccessToken = tokens.accessToken;
|
|
55
|
+
}
|
|
56
|
+
if (tokens.authorizationToken) {
|
|
57
|
+
config.headers.Authorization = "Bearer " + tokens.authorizationToken;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Add FCM DeviceToken header if available
|
|
61
|
+
try {
|
|
62
|
+
const fcmToken = mmkvDefaultStorage.getString('fcmToken');
|
|
63
|
+
if (fcmToken) {
|
|
64
|
+
config.headers.DeviceToken = fcmToken;
|
|
65
|
+
}
|
|
66
|
+
} catch { }
|
|
67
|
+
|
|
68
|
+
return config;
|
|
69
|
+
},
|
|
70
|
+
(error) => {
|
|
71
|
+
return Promise.reject(error);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Response interceptor for error handling
|
|
76
|
+
apiClient.interceptors.response.use(
|
|
77
|
+
(response) => {
|
|
78
|
+
return response;
|
|
79
|
+
},
|
|
80
|
+
(error) => {
|
|
81
|
+
console.log('Error response status:', error.response?.data);
|
|
82
|
+
if (error.response?.status === 401) {
|
|
83
|
+
clearAuthTokens();
|
|
84
|
+
ToastManager.error(error.response?.data?.message);
|
|
85
|
+
}
|
|
86
|
+
// Handle 409 status code differently - don't treat it as an error flow
|
|
87
|
+
if (error.response?.status === 409) {
|
|
88
|
+
// Return the response so it can be handled as a successful response with special status
|
|
89
|
+
return Promise.resolve({
|
|
90
|
+
data: error.response.data,
|
|
91
|
+
status: error.response.status,
|
|
92
|
+
statusText: error.response.statusText,
|
|
93
|
+
headers: error.response.headers,
|
|
94
|
+
config: error.config
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return Promise.reject(error);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const clearAuthTokens = (): void => {
|
|
102
|
+
StorageService.auth.clearAuthData();
|
|
103
|
+
useAuthStore.getState().logout();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// API Endpoints
|
|
107
|
+
export const API_ENDPOINTS = {
|
|
108
|
+
AUTH: {
|
|
109
|
+
LOGIN: 'Account/Login',
|
|
110
|
+
REGISTER: 'Account/SignUp',
|
|
111
|
+
FORGOT_PASSWORD: 'Account/ForgetPassword',
|
|
112
|
+
REFRESH_TOKEN: 'auth/refresh-token',
|
|
113
|
+
UPLOAD_SAS: 'Upload/SasToken',
|
|
114
|
+
VERIFY_OTP: 'Account/Verifyotp',
|
|
115
|
+
RESEND_OTP: 'Account/ResendOtp',
|
|
116
|
+
LOGOUT: 'Account/Logout',
|
|
117
|
+
|
|
118
|
+
},
|
|
119
|
+
VOLUNTEER: {
|
|
120
|
+
HOURS_DETAILS: 'Volunteer/Opportunities/GetVolunteerHoursDetails',
|
|
121
|
+
OPPORTUNITIES: 'Volunteer/Opportunities',
|
|
122
|
+
OPPORTUNITIES_BY_ID: 'Volunteer/Opportunities/{opportunityId}',
|
|
123
|
+
OPPORTUNITY_VOLUNTEERS: 'Volunteer/Opportunities/Volunteers',
|
|
124
|
+
JOIN: 'Volunteer/Opportunities/Join',
|
|
125
|
+
CANCEL_REQUEST: 'Volunteer/Opportunities/CancelVolunteerRequest',
|
|
126
|
+
SLOTS_BY_OPPORTUNITY: 'Volunteer/Opportunities/GetSlotsByOpportunityId',
|
|
127
|
+
REMINDER: 'Volunteer/opportunity/Reminder',
|
|
128
|
+
GET_REMINDER: 'Volunteer/opportunity/{opportunityId}/reminder',
|
|
129
|
+
DELETE_REMINDER: 'Volunteer/opportunity/{opportunityId}/reminder/{reminderId}',
|
|
130
|
+
VOLUNTEER_CHAT: 'Volunteer/members/{memberId}/Threads/{threadId}/messages/{pageNumber}',
|
|
131
|
+
},
|
|
132
|
+
USER: {
|
|
133
|
+
MEMBERS: 'user/members',
|
|
134
|
+
UPDATE_MEMBER: 'user/members',
|
|
135
|
+
},
|
|
136
|
+
CLUB: {
|
|
137
|
+
SEARCH: 'club/search',
|
|
138
|
+
SEARCH_MY_CLUBS: 'club/myclubs',
|
|
139
|
+
JOIN: 'club/{clubId}/members/{memberId}/join',
|
|
140
|
+
MEMBERS: 'club/{clubId}/members',
|
|
141
|
+
ANNOUNCEMENTS: 'club/{clubId}/announcements',
|
|
142
|
+
},
|
|
143
|
+
UPLOAD: {
|
|
144
|
+
GET_IMAGE_URL: 'Upload/GetImageUrl',
|
|
145
|
+
},
|
|
146
|
+
PAYMENT: {
|
|
147
|
+
PROCESS: 'Payments',
|
|
148
|
+
},
|
|
149
|
+
RAFFLE: {
|
|
150
|
+
GET_REFEREE_CODE: 'GetRefereeCode',
|
|
151
|
+
VERIFY_REFERRAL_CODE: 'Raffles/Code/Verify',
|
|
152
|
+
REMINDER: 'Raffles/Reminder',
|
|
153
|
+
GET_REMINDER: 'Raffles/{raffleId}/Reminder',
|
|
154
|
+
DELETE_REMINDER: 'Raffles/Reminder/{reminderId}',
|
|
155
|
+
GET_TICKET_DETAILS: 'Raffles/referral-ticket-details',
|
|
156
|
+
},
|
|
157
|
+
TEAM: {
|
|
158
|
+
SERCH_JOIN_TEAMS: 'Teams/Club/{clubId}/Teams/search',
|
|
159
|
+
MY_TEAMS: 'MyTeam/{memberId}',
|
|
160
|
+
JOIN_TEAM: 'Teams/join',
|
|
161
|
+
PENDING_REQUEST: 'Teams/GetJoinedTeamPendingRequestList',
|
|
162
|
+
CANCEL_PENDING_REQUEST: 'MyTeam/Request/Cancle',
|
|
163
|
+
TEAM_DETAILS: 'Teams/{teamId}/Details',
|
|
164
|
+
TEAM_THREADS: 'Teams/{teamId}/member/{memberId}/Threads',
|
|
165
|
+
TEAM_CHAT: 'Teams/{teamId}/members/{memberId}/Threads/{threadId}/messages/{pageNumber}',
|
|
166
|
+
}
|
|
167
|
+
} as const;
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { apiClient, API_ENDPOINTS } from '../services/api';
|
|
3
|
+
import { User } from '../stores/authStore';
|
|
4
|
+
|
|
5
|
+
// Types for API requests and responses
|
|
6
|
+
export interface ApiResponse<T = any> {
|
|
7
|
+
data: T;
|
|
8
|
+
status: number;
|
|
9
|
+
statusText: string;
|
|
10
|
+
headers: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface LoginRequest {
|
|
14
|
+
email: string;
|
|
15
|
+
password: string;
|
|
16
|
+
device_type?: string;
|
|
17
|
+
device_id?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface LoginResponse {
|
|
21
|
+
apiName: string;
|
|
22
|
+
data: {
|
|
23
|
+
Name: string;
|
|
24
|
+
accessToken: string;
|
|
25
|
+
authorizationToken: string;
|
|
26
|
+
email: string;
|
|
27
|
+
isProfileCompleted: boolean;
|
|
28
|
+
profileImage: string;
|
|
29
|
+
userId: number;
|
|
30
|
+
userType: number;
|
|
31
|
+
isAddMember?: boolean;
|
|
32
|
+
};
|
|
33
|
+
message: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RegisterRequest {
|
|
37
|
+
email: string;
|
|
38
|
+
password: string;
|
|
39
|
+
profileImage: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
phoneNumber?: string;
|
|
42
|
+
confirmPassword?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface RegisterResponse {
|
|
46
|
+
success: boolean;
|
|
47
|
+
message: string;
|
|
48
|
+
data: {
|
|
49
|
+
user: User;
|
|
50
|
+
token: string;
|
|
51
|
+
refreshToken?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ForgotPasswordRequest {
|
|
56
|
+
email: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ForgotPasswordResponse {
|
|
60
|
+
success: boolean;
|
|
61
|
+
message: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface VerifyOTPRequest {
|
|
65
|
+
email: string;
|
|
66
|
+
otp: string;
|
|
67
|
+
deviceToken: string;
|
|
68
|
+
deviceType: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface VerifyOTPResponse {
|
|
72
|
+
success: boolean;
|
|
73
|
+
message: string;
|
|
74
|
+
data: {
|
|
75
|
+
userId: number;
|
|
76
|
+
Name: string;
|
|
77
|
+
email: string;
|
|
78
|
+
profileImage: string;
|
|
79
|
+
authorizationToken: string;
|
|
80
|
+
accessToken: string;
|
|
81
|
+
userType: number;
|
|
82
|
+
isProfileCompleted: boolean;
|
|
83
|
+
isAddMember: boolean;
|
|
84
|
+
message: string;
|
|
85
|
+
apiName: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ResendOTPRequest {
|
|
90
|
+
email: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ResendOTPResponse {
|
|
94
|
+
success: boolean;
|
|
95
|
+
message: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface LogoutResponse {
|
|
99
|
+
success: boolean;
|
|
100
|
+
message: string;
|
|
101
|
+
apiName?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface MembersRequest {
|
|
105
|
+
PageNumber: number;
|
|
106
|
+
PageSize: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
export interface MembersResponse {
|
|
111
|
+
apiName: string;
|
|
112
|
+
data: {
|
|
113
|
+
members?: any[];
|
|
114
|
+
totalCount: number;
|
|
115
|
+
pageNumber: number;
|
|
116
|
+
pageSize: number;
|
|
117
|
+
totalPages: number;
|
|
118
|
+
};
|
|
119
|
+
message: string;
|
|
120
|
+
success: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface UpdateMemberRequest {
|
|
124
|
+
id?: number;
|
|
125
|
+
name: string;
|
|
126
|
+
profileImage: string;
|
|
127
|
+
birthDate: string;
|
|
128
|
+
relation: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface UpdateMemberResponse {
|
|
132
|
+
apiName: string;
|
|
133
|
+
data: any;
|
|
134
|
+
message: string;
|
|
135
|
+
success: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ClubSearchRequest {
|
|
139
|
+
pageNumber: number;
|
|
140
|
+
pageSize: number;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ClubSearchResponse {
|
|
144
|
+
apiName: string;
|
|
145
|
+
data:any[];
|
|
146
|
+
message: string;
|
|
147
|
+
success: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface GetImageUrlRequest {
|
|
151
|
+
containerName: string;
|
|
152
|
+
blobName: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface GetImageUrlResponse {
|
|
156
|
+
apiName: string;
|
|
157
|
+
data: {
|
|
158
|
+
imageUrl: string;
|
|
159
|
+
url: string;
|
|
160
|
+
};
|
|
161
|
+
message: string;
|
|
162
|
+
success: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// API service functions
|
|
166
|
+
export const authService = {
|
|
167
|
+
login: async (credentials: LoginRequest): Promise<ApiResponse<LoginResponse>> => {
|
|
168
|
+
const response = await apiClient.post(API_ENDPOINTS.AUTH.LOGIN, credentials);
|
|
169
|
+
return {
|
|
170
|
+
data: response.data,
|
|
171
|
+
status: response.status,
|
|
172
|
+
statusText: response.statusText,
|
|
173
|
+
headers: response.headers
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
register: async (userData: RegisterRequest): Promise<ApiResponse<RegisterResponse>> => {
|
|
178
|
+
const response = await apiClient.post(API_ENDPOINTS.AUTH.REGISTER, userData);
|
|
179
|
+
return {
|
|
180
|
+
data: response.data,
|
|
181
|
+
status: response.status,
|
|
182
|
+
statusText: response.statusText,
|
|
183
|
+
headers: response.headers
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
forgotPassword: async (email: ForgotPasswordRequest): Promise<ApiResponse<ForgotPasswordResponse>> => {
|
|
188
|
+
const response = await apiClient.post(API_ENDPOINTS.AUTH.FORGOT_PASSWORD, email);
|
|
189
|
+
return {
|
|
190
|
+
data: response.data,
|
|
191
|
+
status: response.status,
|
|
192
|
+
statusText: response.statusText,
|
|
193
|
+
headers: response.headers
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
verifyOTP: async (otp: VerifyOTPRequest): Promise<ApiResponse<VerifyOTPResponse>> => {
|
|
198
|
+
const response = await apiClient.post(API_ENDPOINTS.AUTH.VERIFY_OTP, otp);
|
|
199
|
+
return {
|
|
200
|
+
data: response.data,
|
|
201
|
+
status: response.status,
|
|
202
|
+
statusText: response.statusText,
|
|
203
|
+
headers: response.headers
|
|
204
|
+
};
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
resendOTP: async (email: ResendOTPRequest): Promise<ApiResponse<ResendOTPResponse>> => {
|
|
208
|
+
const response = await apiClient.post(API_ENDPOINTS.AUTH.RESEND_OTP, email);
|
|
209
|
+
return {
|
|
210
|
+
data: response.data,
|
|
211
|
+
status: response.status,
|
|
212
|
+
statusText: response.statusText,
|
|
213
|
+
headers: response.headers
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
logout: async (): Promise<ApiResponse<LogoutResponse>> => {
|
|
218
|
+
const response = await apiClient.post(API_ENDPOINTS.AUTH.LOGOUT);
|
|
219
|
+
return {
|
|
220
|
+
data: response.data,
|
|
221
|
+
status: response.status,
|
|
222
|
+
statusText: response.statusText,
|
|
223
|
+
headers: response.headers
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
getMembers: async (params: MembersRequest): Promise<ApiResponse<MembersResponse>> => {
|
|
228
|
+
const response = await apiClient.get(API_ENDPOINTS.USER.MEMBERS, {
|
|
229
|
+
params: params,
|
|
230
|
+
});
|
|
231
|
+
return {
|
|
232
|
+
data: response.data,
|
|
233
|
+
status: response.status,
|
|
234
|
+
statusText: response.statusText,
|
|
235
|
+
headers: response.headers
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
updateMember: async (memberId: number, memberData: UpdateMemberRequest): Promise<ApiResponse<UpdateMemberResponse>> => {
|
|
240
|
+
const response = await apiClient.post(`${API_ENDPOINTS.USER.UPDATE_MEMBER}/${memberId}`, memberData);
|
|
241
|
+
return {
|
|
242
|
+
data: response.data,
|
|
243
|
+
status: response.status,
|
|
244
|
+
statusText: response.statusText,
|
|
245
|
+
headers: response.headers
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
searchClubs: async (params: ClubSearchRequest): Promise<ApiResponse<ClubSearchResponse>> => {
|
|
250
|
+
const response = await apiClient.get(API_ENDPOINTS.CLUB.SEARCH, {
|
|
251
|
+
params: params,
|
|
252
|
+
});
|
|
253
|
+
return {
|
|
254
|
+
data: response.data,
|
|
255
|
+
status: response.status,
|
|
256
|
+
statusText: response.statusText,
|
|
257
|
+
headers: response.headers
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
getImageUrl: async (params: GetImageUrlRequest): Promise<ApiResponse<GetImageUrlResponse>> => {
|
|
262
|
+
const response = await apiClient.post(API_ENDPOINTS.UPLOAD.GET_IMAGE_URL, params);
|
|
263
|
+
return {
|
|
264
|
+
data: response.data,
|
|
265
|
+
status: response.status,
|
|
266
|
+
statusText: response.statusText,
|
|
267
|
+
headers: response.headers
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Error handling utility
|
|
273
|
+
export const getApiErrorInfo = (error: any) => {
|
|
274
|
+
const statusCode = error?.response?.status || error?.status || 0;
|
|
275
|
+
const statusText = error?.response?.statusText || error?.statusText || 'Unknown Error';
|
|
276
|
+
const message = error?.response?.data?.message || error?.message || 'An error occurred';
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
statusCode,
|
|
280
|
+
statusText,
|
|
281
|
+
message,
|
|
282
|
+
isNetworkError: !error?.response,
|
|
283
|
+
isServerError: statusCode >= 500,
|
|
284
|
+
isClientError: statusCode >= 400 && statusCode < 500,
|
|
285
|
+
isUnauthorized: statusCode === 401,
|
|
286
|
+
isForbidden: statusCode === 403,
|
|
287
|
+
isNotFound: statusCode === 404,
|
|
288
|
+
isValidationError: statusCode === 422,
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// React Query hooks for authentication
|
|
293
|
+
export const useLogin = () => {
|
|
294
|
+
return useMutation({
|
|
295
|
+
mutationFn: authService.login,
|
|
296
|
+
onSuccess: (response) => {
|
|
297
|
+
// Handle successful login
|
|
298
|
+
console.log('Login successful:', response);
|
|
299
|
+
},
|
|
300
|
+
onError: (error) => {
|
|
301
|
+
return error;
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export const useRegister = () => {
|
|
307
|
+
return useMutation({
|
|
308
|
+
mutationFn: authService.register,
|
|
309
|
+
onSuccess: (response) => {
|
|
310
|
+
// Handle successful registration
|
|
311
|
+
console.log('Registration successful:', response.data);
|
|
312
|
+
},
|
|
313
|
+
onError: (error) => {
|
|
314
|
+
// Handle registration error with status code
|
|
315
|
+
const errorInfo = getApiErrorInfo(error);
|
|
316
|
+
console.error('Registration failed:', errorInfo);
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export const useForgotPassword = () => {
|
|
322
|
+
return useMutation({
|
|
323
|
+
mutationFn: authService.forgotPassword,
|
|
324
|
+
onSuccess: (response) => {
|
|
325
|
+
// Handle successful forgot password request
|
|
326
|
+
console.log('Forgot password request successful:', response.data);
|
|
327
|
+
},
|
|
328
|
+
onError: (error) => {
|
|
329
|
+
// Handle forgot password error with status code
|
|
330
|
+
const errorInfo = getApiErrorInfo(error);
|
|
331
|
+
console.error('Forgot password request failed:', errorInfo);
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export const useVerifyOTP = () => {
|
|
337
|
+
return useMutation({
|
|
338
|
+
mutationFn: authService.verifyOTP,
|
|
339
|
+
onSuccess: (response) => {
|
|
340
|
+
// Handle successful OTP verification
|
|
341
|
+
console.log('Verify OTP request successful:', response.data);
|
|
342
|
+
},
|
|
343
|
+
onError: (error) => {
|
|
344
|
+
// Handle OTP verification error with status code
|
|
345
|
+
const errorInfo = getApiErrorInfo(error);
|
|
346
|
+
console.error('Verify OTP request failed:', errorInfo);
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export const useResendOTP = () => {
|
|
352
|
+
return useMutation({
|
|
353
|
+
mutationFn: authService.resendOTP,
|
|
354
|
+
onSuccess: (response) => {
|
|
355
|
+
console.log('Resend OTP request successful:', response.data);
|
|
356
|
+
},
|
|
357
|
+
onError: (error) => {
|
|
358
|
+
// Handle resend OTP error with status code
|
|
359
|
+
const errorInfo = getApiErrorInfo(error);
|
|
360
|
+
console.error('Resend OTP request failed:', errorInfo);
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export const useLogout = () => {
|
|
366
|
+
return useMutation({
|
|
367
|
+
mutationFn: authService.logout,
|
|
368
|
+
onSuccess: (response) => {
|
|
369
|
+
console.log('Logout request successful:', response.data);
|
|
370
|
+
},
|
|
371
|
+
onError: (error) => {
|
|
372
|
+
// Handle logout error with status code
|
|
373
|
+
const errorInfo = getApiErrorInfo(error);
|
|
374
|
+
console.error('Logout request failed:', errorInfo);
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export const useMembers = (params: MembersRequest) => {
|
|
380
|
+
return useQuery({
|
|
381
|
+
queryKey: ['members'],
|
|
382
|
+
queryFn: () => authService.getMembers(params),
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export const useUpdateMember = () => {
|
|
387
|
+
return useMutation({
|
|
388
|
+
mutationFn: ({ memberId, memberData }: { memberId: number; memberData: UpdateMemberRequest }) =>
|
|
389
|
+
authService.updateMember(memberId, memberData),
|
|
390
|
+
onSuccess: (response) => {
|
|
391
|
+
console.log('Member update successful:', response.data);
|
|
392
|
+
},
|
|
393
|
+
onError: (error) => {
|
|
394
|
+
// Handle member update error with status code
|
|
395
|
+
const errorInfo = getApiErrorInfo(error);
|
|
396
|
+
console.error('Member update failed:', errorInfo);
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export const useClubSearch = (params: ClubSearchRequest) => {
|
|
402
|
+
return useQuery({
|
|
403
|
+
queryKey: ['clubSearch', params],
|
|
404
|
+
queryFn: () => authService.searchClubs(params),
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export const useGetImageUrl = () => {
|
|
409
|
+
return useMutation({
|
|
410
|
+
mutationFn: authService.getImageUrl,
|
|
411
|
+
onSuccess: (response) => {
|
|
412
|
+
console.log('Get image URL successful:', response.data);
|
|
413
|
+
},
|
|
414
|
+
onError: (error) => {
|
|
415
|
+
const errorInfo = getApiErrorInfo(error);
|
|
416
|
+
console.error('Get image URL failed:', errorInfo);
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|