@imksh/create 1.0.25 → 1.0.27

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.
Files changed (271) hide show
  1. package/package.json +1 -1
  2. package/src/commands/create.js +2 -1
  3. package/src/index.js +1 -1
  4. package/src/utils/askTemplate.js +1 -0
  5. package/templates/mern-react-native/mobile/_gitignore +43 -0
  6. package/templates/mern-react-native/mobile/package.json +2 -1
  7. package/templates/mern-react-native/mobile/src/app/(auth)/edit-profile.tsx +11 -15
  8. package/templates/mern-react-native/mobile/src/app/(tabs)/dashboard.tsx +2 -2
  9. package/templates/mern-react-native/mobile/src/app/(tabs)/search.tsx +2 -2
  10. package/templates/mern-react-native/mobile/src/config/sidebar.config.ts +0 -60
  11. package/templates/mern-react-native/mobile/src/config/tabNavigation.ts +6 -36
  12. package/templates/mern-react-native/mobile/src/services/notification.service.ts +22 -0
  13. package/templates/mern-react-native/mobile/src/store/useNotificationStore.ts +158 -33
  14. package/templates/next/next.config.mjs +1 -0
  15. package/templates/next/package.json +10 -9
  16. package/templates/next/postcss.config.js +5 -0
  17. package/templates/next/src/app/layout.js +1 -0
  18. package/templates/next/src/app/page.js +1 -1
  19. package/templates/next/src/components/layout/ProtectedRoute.jsx +3 -3
  20. package/templates/next/src/index.css +1 -0
  21. package/templates/next/src/store/useUiStore.js +13 -7
  22. package/templates/next-ts/.env.example +0 -0
  23. package/templates/next-ts/AGENTS.md +37 -0
  24. package/templates/next-ts/CLAUDE.md +1 -0
  25. package/templates/next-ts/next-env.d.ts +3 -1
  26. package/templates/next-ts/next.config.mjs +1 -0
  27. package/templates/next-ts/package.json +13 -12
  28. package/templates/next-ts/postcss.config.js +5 -0
  29. package/templates/next-ts/public/logo.png +0 -0
  30. package/templates/next-ts/src/app/error.tsx +41 -0
  31. package/templates/next-ts/src/app/layout.tsx +2 -1
  32. package/templates/next-ts/src/app/not-found.tsx +5 -0
  33. package/templates/next-ts/src/app/page.tsx +1 -1
  34. package/templates/next-ts/src/components/layout/ProtectedRoute.tsx +3 -3
  35. package/templates/next-ts/src/components/ui/Button.tsx +63 -0
  36. package/templates/next-ts/src/components/ui/Input.tsx +79 -0
  37. package/templates/next-ts/src/index.css +1 -0
  38. package/templates/next-ts/src/store/useUiStore.ts +13 -7
  39. package/templates/next-ts/tsconfig.json +19 -5
  40. package/templates/production-fullstack/client/_gitignore +24 -0
  41. package/templates/production-fullstack/client/index.html +14 -0
  42. package/templates/production-fullstack/client/package.json +47 -0
  43. package/templates/production-fullstack/client/public/_redirects +1 -0
  44. package/templates/production-fullstack/client/public/favicon.ico +0 -0
  45. package/templates/production-fullstack/client/public/favicon.svg +1 -0
  46. package/templates/production-fullstack/client/public/logo.png +0 -0
  47. package/templates/production-fullstack/client/public/manifest.json +24 -0
  48. package/templates/production-fullstack/client/public/sw.js +56 -0
  49. package/templates/production-fullstack/client/src/App.tsx +68 -0
  50. package/templates/production-fullstack/client/src/assets/animations/loading.json +1 -0
  51. package/templates/production-fullstack/client/src/assets/data/navigation.ts +29 -0
  52. package/templates/production-fullstack/client/src/assets/images/logo.png +0 -0
  53. package/templates/production-fullstack/client/src/components/layout/ProtectedRoute.tsx +23 -0
  54. package/templates/production-fullstack/client/src/components/layout/PublicLayout.tsx +13 -0
  55. package/templates/production-fullstack/client/src/components/layout/SidebarLayout.tsx +37 -0
  56. package/templates/production-fullstack/client/src/components/shared/Breadcrumbs.tsx +27 -0
  57. package/templates/production-fullstack/client/src/components/shared/LottieIcon.tsx +36 -0
  58. package/templates/production-fullstack/client/src/components/shared/NotFound.tsx +78 -0
  59. package/templates/production-fullstack/client/src/components/shared/PwaInstallPrompt.tsx +72 -0
  60. package/templates/production-fullstack/client/src/components/shared/SEO.tsx +67 -0
  61. package/templates/production-fullstack/client/src/components/shared/Scroll.tsx +25 -0
  62. package/templates/production-fullstack/client/src/components/shared/Unauthorized.tsx +76 -0
  63. package/templates/production-fullstack/client/src/components/shared/skeletons/common/CardSkeleton.tsx +23 -0
  64. package/templates/production-fullstack/client/src/components/shared/skeletons/common/DashboardSkeleton.tsx +19 -0
  65. package/templates/production-fullstack/client/src/components/shared/skeletons/common/ListSkeleton.tsx +24 -0
  66. package/templates/production-fullstack/client/src/components/shared/skeletons/common/PageSkeleton.tsx +26 -0
  67. package/templates/production-fullstack/client/src/components/shared/skeletons/common/ProfileSkeleton.tsx +23 -0
  68. package/templates/production-fullstack/client/src/components/shared/skeletons/common/Skeleton.tsx +18 -0
  69. package/templates/production-fullstack/client/src/components/shared/skeletons/common/TableSkeleton.tsx +33 -0
  70. package/templates/production-fullstack/client/src/components/ui/ConfirmModal.tsx +152 -0
  71. package/templates/production-fullstack/client/src/components/ui/Header.tsx +230 -0
  72. package/templates/production-fullstack/client/src/components/ui/Loading.tsx +19 -0
  73. package/templates/production-fullstack/client/src/components/ui/Modal.tsx +106 -0
  74. package/templates/production-fullstack/client/src/components/ui/SidebarHeader.tsx +34 -0
  75. package/templates/production-fullstack/client/src/components/ui/Table.tsx +118 -0
  76. package/templates/production-fullstack/client/src/components/ui/ToggleSwitch.tsx +38 -0
  77. package/templates/production-fullstack/client/src/components/ui/sidebar.tsx +152 -0
  78. package/templates/production-fullstack/client/src/config/index.ts +44 -0
  79. package/templates/production-fullstack/client/src/constants/navigation.ts +14 -0
  80. package/templates/production-fullstack/client/src/features/auth/api/authService.ts +19 -0
  81. package/templates/production-fullstack/client/src/features/auth/pages/Login.tsx +233 -0
  82. package/templates/production-fullstack/client/src/features/auth/store/useAuthStore.ts +143 -0
  83. package/templates/production-fullstack/client/src/features/core/pages/Home.tsx +150 -0
  84. package/templates/production-fullstack/client/src/features/core/pages/Profile.tsx +9 -0
  85. package/templates/production-fullstack/client/src/hooks/useLenis.ts +28 -0
  86. package/templates/production-fullstack/client/src/hooks/usePwaInstall.ts +45 -0
  87. package/templates/production-fullstack/client/src/hooks/useWindowSize.ts +25 -0
  88. package/templates/production-fullstack/client/src/index.css +158 -0
  89. package/templates/production-fullstack/client/src/lib/axios.ts +22 -0
  90. package/templates/production-fullstack/client/src/lib/dayjs.ts +12 -0
  91. package/templates/production-fullstack/client/src/lib/query-client.ts +11 -0
  92. package/templates/production-fullstack/client/src/lib/socket.ts +6 -0
  93. package/templates/production-fullstack/client/src/main.tsx +28 -0
  94. package/templates/production-fullstack/client/src/store/useUiStore.ts +74 -0
  95. package/templates/production-fullstack/client/src/utils/formatDate.ts +19 -0
  96. package/templates/production-fullstack/client/src/utils/getInitials.ts +10 -0
  97. package/templates/production-fullstack/client/src/vite-env.d.ts +1 -0
  98. package/templates/production-fullstack/client/tsconfig.json +25 -0
  99. package/templates/production-fullstack/client/tsconfig.node.json +10 -0
  100. package/templates/production-fullstack/client/vite.config.ts +8 -0
  101. package/templates/production-fullstack/mobile/LICENSE +21 -0
  102. package/templates/production-fullstack/mobile/_gitignore +43 -0
  103. package/templates/production-fullstack/mobile/app.json +84 -0
  104. package/templates/production-fullstack/mobile/assets/animations/celebrate.json +1 -0
  105. package/templates/production-fullstack/mobile/assets/animations/infinity.json +1 -0
  106. package/templates/production-fullstack/mobile/assets/animations/loading.json +1 -0
  107. package/templates/production-fullstack/mobile/assets/fonts/Inter_Bold.ttf +0 -0
  108. package/templates/production-fullstack/mobile/assets/fonts/Inter_ExtraBold.ttf +0 -0
  109. package/templates/production-fullstack/mobile/assets/fonts/Inter_Medium.ttf +0 -0
  110. package/templates/production-fullstack/mobile/assets/fonts/Inter_Regular.ttf +0 -0
  111. package/templates/production-fullstack/mobile/assets/fonts/Inter_SemiBold.ttf +0 -0
  112. package/templates/production-fullstack/mobile/assets/images/logo/logo.png +0 -0
  113. package/templates/production-fullstack/mobile/assets/images/logo/logo.svg +1 -0
  114. package/templates/production-fullstack/mobile/assets/images/logo/logoWithBg.png +0 -0
  115. package/templates/production-fullstack/mobile/babel.config.js +13 -0
  116. package/templates/production-fullstack/mobile/drizzle.config.ts +8 -0
  117. package/templates/production-fullstack/mobile/eas.json +24 -0
  118. package/templates/production-fullstack/mobile/eslint.config.js +10 -0
  119. package/templates/production-fullstack/mobile/expo-env.d.ts +3 -0
  120. package/templates/production-fullstack/mobile/metro.config.js +6 -0
  121. package/templates/production-fullstack/mobile/nativewind-env.d.ts +3 -0
  122. package/templates/production-fullstack/mobile/package.json +89 -0
  123. package/templates/production-fullstack/mobile/src/app/(auth)/_layout.tsx +12 -0
  124. package/templates/production-fullstack/mobile/src/app/(auth)/change-password.tsx +112 -0
  125. package/templates/production-fullstack/mobile/src/app/(auth)/edit-profile.tsx +160 -0
  126. package/templates/production-fullstack/mobile/src/app/(auth)/forgot-password.tsx +191 -0
  127. package/templates/production-fullstack/mobile/src/app/(auth)/login.tsx +253 -0
  128. package/templates/production-fullstack/mobile/src/app/_layout.tsx +102 -0
  129. package/templates/production-fullstack/mobile/src/app/global.css +82 -0
  130. package/templates/production-fullstack/mobile/src/components/common/AnimatedHeader.tsx +328 -0
  131. package/templates/production-fullstack/mobile/src/components/common/ConfirmationToast.tsx +67 -0
  132. package/templates/production-fullstack/mobile/src/components/common/Loading.tsx +26 -0
  133. package/templates/production-fullstack/mobile/src/components/common/LocationLoader.tsx +591 -0
  134. package/templates/production-fullstack/mobile/src/components/common/ScreenHeader.tsx +68 -0
  135. package/templates/production-fullstack/mobile/src/components/common/TabHeader.tsx +58 -0
  136. package/templates/production-fullstack/mobile/src/components/common/Typography.tsx +113 -0
  137. package/templates/production-fullstack/mobile/src/components/common/Welcome.tsx +55 -0
  138. package/templates/production-fullstack/mobile/src/components/ui/BottomModal.tsx +159 -0
  139. package/templates/production-fullstack/mobile/src/components/ui/ClassicTabBar.tsx +129 -0
  140. package/templates/production-fullstack/mobile/src/components/ui/CustomTabBar.tsx +238 -0
  141. package/templates/production-fullstack/mobile/src/components/ui/Sidebar.tsx +258 -0
  142. package/templates/production-fullstack/mobile/src/components/ui/buttons/Button.tsx +180 -0
  143. package/templates/production-fullstack/mobile/src/components/ui/buttons/ButtonGroup.tsx +32 -0
  144. package/templates/production-fullstack/mobile/src/components/ui/buttons/FloatingActionButton.tsx +72 -0
  145. package/templates/production-fullstack/mobile/src/components/ui/buttons/IconButton.tsx +84 -0
  146. package/templates/production-fullstack/mobile/src/components/ui/data-display/Accordion.tsx +82 -0
  147. package/templates/production-fullstack/mobile/src/components/ui/data-display/Avatar.tsx +47 -0
  148. package/templates/production-fullstack/mobile/src/components/ui/data-display/Badge.tsx +104 -0
  149. package/templates/production-fullstack/mobile/src/components/ui/data-display/Card.tsx +36 -0
  150. package/templates/production-fullstack/mobile/src/components/ui/data-display/Image.tsx +43 -0
  151. package/templates/production-fullstack/mobile/src/components/ui/data-display/ImageViewer.tsx +33 -0
  152. package/templates/production-fullstack/mobile/src/components/ui/data-display/SwipeableRow.tsx +94 -0
  153. package/templates/production-fullstack/mobile/src/components/ui/feedback/CircularProgress.tsx +38 -0
  154. package/templates/production-fullstack/mobile/src/components/ui/feedback/GestureWrapper.tsx +114 -0
  155. package/templates/production-fullstack/mobile/src/components/ui/feedback/ProgressBar.tsx +51 -0
  156. package/templates/production-fullstack/mobile/src/components/ui/feedback/Skeleton.tsx +84 -0
  157. package/templates/production-fullstack/mobile/src/components/ui/feedback/Spinner.tsx +50 -0
  158. package/templates/production-fullstack/mobile/src/components/ui/inputs/Checkbox.tsx +54 -0
  159. package/templates/production-fullstack/mobile/src/components/ui/inputs/DatePicker.tsx +186 -0
  160. package/templates/production-fullstack/mobile/src/components/ui/inputs/ImagePickerModal.tsx +129 -0
  161. package/templates/production-fullstack/mobile/src/components/ui/inputs/Input.tsx +158 -0
  162. package/templates/production-fullstack/mobile/src/components/ui/inputs/LocationPicker.tsx +211 -0
  163. package/templates/production-fullstack/mobile/src/components/ui/inputs/OTPInput.tsx +83 -0
  164. package/templates/production-fullstack/mobile/src/components/ui/inputs/PasswordInput.tsx +16 -0
  165. package/templates/production-fullstack/mobile/src/components/ui/inputs/Radio.tsx +54 -0
  166. package/templates/production-fullstack/mobile/src/components/ui/inputs/SearchBar.tsx +53 -0
  167. package/templates/production-fullstack/mobile/src/components/ui/inputs/Slider.tsx +49 -0
  168. package/templates/production-fullstack/mobile/src/components/ui/inputs/Switch.tsx +75 -0
  169. package/templates/production-fullstack/mobile/src/components/ui/inputs/TextArea.tsx +15 -0
  170. package/templates/production-fullstack/mobile/src/components/ui/inputs/WebLocationPicker.tsx +321 -0
  171. package/templates/production-fullstack/mobile/src/components/ui/layout/Container.tsx +23 -0
  172. package/templates/production-fullstack/mobile/src/components/ui/layout/Divider.tsx +20 -0
  173. package/templates/production-fullstack/mobile/src/components/ui/layout/Grid.tsx +62 -0
  174. package/templates/production-fullstack/mobile/src/components/ui/layout/KeyboardAvoidingViewWrapper.tsx +16 -0
  175. package/templates/production-fullstack/mobile/src/components/ui/layout/ScrollContainer.tsx +21 -0
  176. package/templates/production-fullstack/mobile/src/components/ui/layout/Section.tsx +51 -0
  177. package/templates/production-fullstack/mobile/src/components/ui/layout/Spacer.tsx +6 -0
  178. package/templates/production-fullstack/mobile/src/components/ui/layout/Stack.tsx +34 -0
  179. package/templates/production-fullstack/mobile/src/components/ui/navigation/Pagination.tsx +61 -0
  180. package/templates/production-fullstack/mobile/src/components/ui/navigation/ProgressStepper.tsx +66 -0
  181. package/templates/production-fullstack/mobile/src/components/ui/navigation/Tabs.tsx +173 -0
  182. package/templates/production-fullstack/mobile/src/config/sidebar.config.ts +72 -0
  183. package/templates/production-fullstack/mobile/src/config/tabNavigation.ts +64 -0
  184. package/templates/production-fullstack/mobile/src/constants/Colors.ts +71 -0
  185. package/templates/production-fullstack/mobile/src/db/index.ts +9 -0
  186. package/templates/production-fullstack/mobile/src/db/schema.ts +14 -0
  187. package/templates/production-fullstack/mobile/src/features/auth/api/auth.service.ts +35 -0
  188. package/templates/production-fullstack/mobile/src/features/auth/store/useAuthStore.ts +273 -0
  189. package/templates/production-fullstack/mobile/src/features/auth/types/auth.type.ts +14 -0
  190. package/templates/production-fullstack/mobile/src/hooks/useDebounce.ts +17 -0
  191. package/templates/production-fullstack/mobile/src/lib/axios.ts +27 -0
  192. package/templates/production-fullstack/mobile/src/lib/query-client.ts +11 -0
  193. package/templates/production-fullstack/mobile/src/lib/socket.ts +36 -0
  194. package/templates/production-fullstack/mobile/src/lib/storage.ts +55 -0
  195. package/templates/production-fullstack/mobile/src/services/permission.service.ts +214 -0
  196. package/templates/production-fullstack/mobile/src/store/localStore.ts +7 -0
  197. package/templates/production-fullstack/mobile/src/store/useNotificationStore.ts +53 -0
  198. package/templates/production-fullstack/mobile/src/types/common.type.ts +6 -0
  199. package/templates/production-fullstack/mobile/src/types/images.d.ts +24 -0
  200. package/templates/production-fullstack/mobile/src/utils/toast.ts +26 -0
  201. package/templates/production-fullstack/mobile/tailwind.config.js +71 -0
  202. package/templates/production-fullstack/mobile/tsconfig.json +23 -0
  203. package/templates/production-fullstack/server/.env.example +63 -0
  204. package/templates/production-fullstack/server/README.md +75 -0
  205. package/templates/production-fullstack/server/_gitignore +24 -0
  206. package/templates/production-fullstack/server/eslint.config.js +13 -0
  207. package/templates/production-fullstack/server/package.json +58 -0
  208. package/templates/production-fullstack/server/prisma/schema/core/attachment.prisma +14 -0
  209. package/templates/production-fullstack/server/prisma/schema/core/notification.prisma +18 -0
  210. package/templates/production-fullstack/server/prisma/schema/core/permission.prisma +26 -0
  211. package/templates/production-fullstack/server/prisma/schema/core/role.prisma +25 -0
  212. package/templates/production-fullstack/server/prisma/schema/core/user.prisma +56 -0
  213. package/templates/production-fullstack/server/prisma/schema/enums/common.prisma +13 -0
  214. package/templates/production-fullstack/server/prisma/schema/enums/notification.prisma +6 -0
  215. package/templates/production-fullstack/server/prisma/schema/enums/user.prisma +11 -0
  216. package/templates/production-fullstack/server/prisma/schema/schema.prisma +7 -0
  217. package/templates/production-fullstack/server/prisma.config.ts +14 -0
  218. package/templates/production-fullstack/server/src/app.ts +36 -0
  219. package/templates/production-fullstack/server/src/common/middlewares/auth.middleware.ts +45 -0
  220. package/templates/production-fullstack/server/src/common/middlewares/errorHandler.ts +16 -0
  221. package/templates/production-fullstack/server/src/common/middlewares/multer.ts +20 -0
  222. package/templates/production-fullstack/server/src/common/middlewares/rateLimiter.ts +53 -0
  223. package/templates/production-fullstack/server/src/common/services/email.service.ts +28 -0
  224. package/templates/production-fullstack/server/src/common/services/push.service.ts +65 -0
  225. package/templates/production-fullstack/server/src/common/services/storage.service.ts +9 -0
  226. package/templates/production-fullstack/server/src/common/types/express.d.ts +10 -0
  227. package/templates/production-fullstack/server/src/common/utils/cloudinaryUpload.ts +44 -0
  228. package/templates/production-fullstack/server/src/common/utils/emailOtp.ts +30 -0
  229. package/templates/production-fullstack/server/src/common/utils/genOtpToken.ts +22 -0
  230. package/templates/production-fullstack/server/src/common/utils/generateVapidKeys.ts +12 -0
  231. package/templates/production-fullstack/server/src/common/utils/jwt.ts +27 -0
  232. package/templates/production-fullstack/server/src/common/utils/pushHelper.ts +22 -0
  233. package/templates/production-fullstack/server/src/config/env.ts +2 -0
  234. package/templates/production-fullstack/server/src/config/logger.ts +58 -0
  235. package/templates/production-fullstack/server/src/config/prisma.ts +26 -0
  236. package/templates/production-fullstack/server/src/features/attachments/upload.controller.ts +22 -0
  237. package/templates/production-fullstack/server/src/features/attachments/upload.routes.ts +11 -0
  238. package/templates/production-fullstack/server/src/features/auth/auth.controller.ts +124 -0
  239. package/templates/production-fullstack/server/src/features/auth/auth.routes.ts +22 -0
  240. package/templates/production-fullstack/server/src/features/auth/auth.service.ts +155 -0
  241. package/templates/production-fullstack/server/src/features/notifications/push.controller.ts +55 -0
  242. package/templates/production-fullstack/server/src/features/notifications/push.routes.ts +11 -0
  243. package/templates/production-fullstack/server/src/index.ts +17 -0
  244. package/templates/production-fullstack/server/src/routes/index.ts +12 -0
  245. package/templates/production-fullstack/server/src/sockets/auth.ts +0 -0
  246. package/templates/production-fullstack/server/src/sockets/connection.ts +31 -0
  247. package/templates/production-fullstack/server/src/sockets/emitters/assignment.emitter.ts +0 -0
  248. package/templates/production-fullstack/server/src/sockets/emitters/attendance.emitter.ts +0 -0
  249. package/templates/production-fullstack/server/src/sockets/emitters/exam.emitter.ts +0 -0
  250. package/templates/production-fullstack/server/src/sockets/emitters/notification.emitter.ts +17 -0
  251. package/templates/production-fullstack/server/src/sockets/events.ts +27 -0
  252. package/templates/production-fullstack/server/src/sockets/handlers/attendance.handler.ts +0 -0
  253. package/templates/production-fullstack/server/src/sockets/handlers/chat.handler.ts +0 -0
  254. package/templates/production-fullstack/server/src/sockets/handlers/index.ts +15 -0
  255. package/templates/production-fullstack/server/src/sockets/handlers/lms.handler.ts +0 -0
  256. package/templates/production-fullstack/server/src/sockets/handlers/notification.handler.ts +39 -0
  257. package/templates/production-fullstack/server/src/sockets/index.ts +39 -0
  258. package/templates/production-fullstack/server/src/sockets/middleware.ts +54 -0
  259. package/templates/production-fullstack/server/src/sockets/rooms.ts +11 -0
  260. package/templates/production-fullstack/server/src/sockets/types.ts +32 -0
  261. package/templates/production-fullstack/server/tsconfig.json +14 -0
  262. package/templates/react/src/assets/animations/loading.json +1 -0
  263. package/templates/react-native/_gitignore +43 -0
  264. package/templates/react-native/package.json +2 -1
  265. package/templates/react-native/src/app/(auth)/edit-profile.tsx +11 -15
  266. package/templates/react-native/src/app/(tabs)/dashboard.tsx +2 -2
  267. package/templates/react-native/src/app/(tabs)/search.tsx +2 -2
  268. package/templates/react-native/src/config/sidebar.config.ts +0 -60
  269. package/templates/react-native/src/config/tabNavigation.ts +6 -36
  270. package/templates/react-native/src/services/notification.service.ts +22 -0
  271. package/templates/react-native/src/store/useNotificationStore.ts +158 -33
@@ -0,0 +1,253 @@
1
+ import React, { useState, useCallback } from "react";
2
+ import { View } from "react-native";
3
+ import { useAuthStore } from "../../features/auth/store/useAuthStore";
4
+ import { Txt } from "../../components/common/Typography";
5
+ import { Redirect, router, useFocusEffect } from "expo-router";
6
+ import ScrollContainer from "../../components/ui/layout/ScrollContainer";
7
+ import Input from "../../components/ui/inputs/Input";
8
+ import Button from "../../components/ui/buttons/Button";
9
+ import Tabs from "../../components/ui/navigation/Tabs";
10
+ import Image from "@/components/ui/data-display/Image";
11
+ import logo from "../../../assets/images/logo/logo.png";
12
+
13
+ export default function LoginScreen() {
14
+ const {
15
+ login,
16
+ signup,
17
+ sendOtp,
18
+ loading,
19
+ error,
20
+ user,
21
+ isCheckingAuth,
22
+ clearError,
23
+ demoLogin,
24
+ } = useAuthStore();
25
+
26
+ useFocusEffect(
27
+ useCallback(() => {
28
+ return () => clearError();
29
+ }, [clearError]),
30
+ );
31
+
32
+ const [mode, setMode] = useState("login");
33
+ const [showPassword, setShowPassword] = useState(false);
34
+ const [form, setForm] = useState({
35
+ name: "",
36
+ email: "",
37
+ password: "",
38
+ otp: "",
39
+ });
40
+ const [otpSent, setOtpSent] = useState(false);
41
+ const [timer, setTimer] = useState(0);
42
+
43
+ React.useEffect(() => {
44
+ let interval: ReturnType<typeof setInterval>;
45
+ if (timer > 0) {
46
+ interval = setInterval(() => {
47
+ setTimer((prev) => prev - 1);
48
+ }, 1000);
49
+ }
50
+ return () => clearInterval(interval);
51
+ }, [timer]);
52
+
53
+ const handleChange = (name: string, value: string) => {
54
+ setForm((prev) => ({ ...prev, [name]: value }));
55
+ };
56
+
57
+ const handleSubmit = async () => {
58
+ let ok;
59
+ if (mode === "login") {
60
+ ok = await login(form.email, form.password);
61
+ } else {
62
+ if (!otpSent) {
63
+ ok = await sendOtp(form.email);
64
+ if (ok) {
65
+ setOtpSent(true);
66
+ setTimer(60);
67
+ }
68
+ } else {
69
+ ok = await signup(form.name, form.email, form.password, form.otp);
70
+ }
71
+ }
72
+ };
73
+
74
+ if (!isCheckingAuth && user) {
75
+ return <Redirect href="/(tabs)" />;
76
+ }
77
+
78
+ return (
79
+ <ScrollContainer
80
+ contentContainerStyle={{
81
+ flexGrow: 1,
82
+ justifyContent: "center",
83
+ padding: 16,
84
+ }}
85
+ className="bg-base-100"
86
+ >
87
+ <View className="w-full p-6 ">
88
+ {/* Header */}
89
+ <View className="items-center mb-8 w-full">
90
+ <View className="w-16 h-16 rounded-2xl bg-primary/10 border border-primary/20 items-center justify-center mb-4">
91
+ <Image src={logo} height={40} width={40} />
92
+ </View>
93
+ <Txt
94
+ variant="xl"
95
+ className="text-2xl mb-1 text-center"
96
+ numberOfLines={1}
97
+ >
98
+ {mode === "login" ? "Welcome back" : "Create account"}
99
+ </Txt>
100
+ <Txt
101
+ variant="sm"
102
+ className="text-xs text-base-content/50 text-center px-2"
103
+ >
104
+ {mode === "login"
105
+ ? "Sign in to continue your journey"
106
+ : "Enter your information to create a new account"}
107
+ </Txt>
108
+ </View>
109
+
110
+ {/* Tab Switcher */}
111
+ <View className="mb-6">
112
+ <Tabs
113
+ variant="button"
114
+ activeTab={mode}
115
+ onChange={(id) => {
116
+ setMode(id);
117
+ setOtpSent(false);
118
+ }}
119
+ tabs={[
120
+ { id: "login", label: "Sign in" },
121
+ { id: "signup", label: "Sign Up" },
122
+ ]}
123
+ />
124
+ </View>
125
+
126
+ {/* Error */}
127
+ {error ? (
128
+ <View className="bg-error/10 border border-error/20 rounded-2xl p-3 mb-4">
129
+ <Txt variant="md" className="text-error text-xs text-center">
130
+ ⚠️ {error}
131
+ </Txt>
132
+ </View>
133
+ ) : null}
134
+
135
+ {/* Form */}
136
+ <View className="gap-2">
137
+ {mode === "signup" && (
138
+ <Input
139
+ leftIcon="person"
140
+ placeholder="Full name"
141
+ value={form.name}
142
+ onChangeText={(val) => handleChange("name", val)}
143
+ />
144
+ )}
145
+
146
+ <Input
147
+ leftIcon="mail"
148
+ placeholder="Email address"
149
+ value={form.email}
150
+ onChangeText={(val) => handleChange("email", val)}
151
+ autoCapitalize="none"
152
+ keyboardType="email-address"
153
+ />
154
+
155
+ <Input
156
+ leftIcon="lock-closed"
157
+ rightIcon={showPassword ? "eye-off" : "eye"}
158
+ onRightIconPress={() => setShowPassword(!showPassword)}
159
+ placeholder="Password"
160
+ value={form.password}
161
+ onChangeText={(val) => handleChange("password", val)}
162
+ secureTextEntry={!showPassword}
163
+ />
164
+
165
+ {mode === "login" && (
166
+ <View className="items-end mt-1 mb-2">
167
+ <Txt
168
+ variant="md"
169
+ className="text-primary text-xs"
170
+ onPress={() => router.push("/(auth)/forgot-password")}
171
+ >
172
+ Forgot Password?
173
+ </Txt>
174
+ </View>
175
+ )}
176
+
177
+ {mode === "signup" && otpSent && (
178
+ <Input
179
+ leftIcon="key"
180
+ placeholder="Enter OTP"
181
+ value={form.otp}
182
+ onChangeText={(val) => handleChange("otp", val)}
183
+ keyboardType="numeric"
184
+ />
185
+ )}
186
+
187
+ <View className="mt-2">
188
+ <Button
189
+ label={
190
+ mode === "login"
191
+ ? "Sign In →"
192
+ : otpSent
193
+ ? "Verify & Create Account →"
194
+ : "Send OTP →"
195
+ }
196
+ onPress={handleSubmit}
197
+ isLoading={loading}
198
+ variant="primary"
199
+ isFullWidth
200
+ />
201
+ </View>
202
+
203
+ {mode === "login" && (
204
+ <View className="mt-2">
205
+ <Button
206
+ label="Demo Login"
207
+ onPress={() => demoLogin()}
208
+ isLoading={loading}
209
+ variant="outline"
210
+ isFullWidth
211
+ />
212
+ </View>
213
+ )}
214
+
215
+ {mode === "signup" && otpSent && (
216
+ <View className="mt-2">
217
+ <Button
218
+ label={timer > 0 ? `Resend OTP in ${timer}s` : "Resend OTP"}
219
+ onPress={async () => {
220
+ const ok = await sendOtp(form.email);
221
+ if (ok) setTimer(60);
222
+ }}
223
+ disabled={timer > 0 || loading}
224
+ variant="outline"
225
+ isFullWidth
226
+ />
227
+ </View>
228
+ )}
229
+ </View>
230
+
231
+ {/* Footer */}
232
+ <View className="mt-8">
233
+ <Txt
234
+ variant="sm"
235
+ className="text-sm text-base-content/50 text-center"
236
+ >
237
+ {mode === "login" ? "New here? " : "Already have an account? "}
238
+ <Txt
239
+ variant="md"
240
+ className="text-primary text-sm"
241
+ onPress={() => {
242
+ setMode(mode === "login" ? "signup" : "login");
243
+ setOtpSent(false);
244
+ }}
245
+ >
246
+ {mode === "login" ? "Create an account" : "Sign in"}
247
+ </Txt>
248
+ </Txt>
249
+ </View>
250
+ </View>
251
+ </ScrollContainer>
252
+ );
253
+ }
@@ -0,0 +1,102 @@
1
+ import { useEffect } from "react";
2
+ import { Stack, useRouter, useSegments } from "expo-router";
3
+ import Toast from "react-native-toast-message";
4
+ import { useAuthStore } from "../features/auth/store/useAuthStore";
5
+ import { useColorScheme } from "nativewind";
6
+ import { Colors } from "../constants/Colors";
7
+ import "./global.css";
8
+ import Loading from "@/components/common/Loading";
9
+
10
+ import { PaperProvider } from "react-native-paper";
11
+ import AsyncStorage from "@react-native-async-storage/async-storage";
12
+ import { useFonts } from "expo-font";
13
+ import { GestureHandlerRootView } from "react-native-gesture-handler";
14
+ import * as SplashScreen from "expo-splash-screen";
15
+ import { StatusBar } from "expo-status-bar";
16
+ import { QueryClientProvider } from "@tanstack/react-query";
17
+ import { queryClient } from "../lib/query-client";
18
+
19
+ SplashScreen.preventAutoHideAsync();
20
+
21
+ export default function RootLayout() {
22
+ const [fontsLoaded, fontError] = useFonts({
23
+ InterRegular: require("../../assets/fonts/Inter_Regular.ttf"),
24
+ InterMedium: require("../../assets/fonts/Inter_Medium.ttf"),
25
+ InterSemiBold: require("../../assets/fonts/Inter_SemiBold.ttf"),
26
+ InterBold: require("../../assets/fonts/Inter_Bold.ttf"),
27
+ InterExtraBold: require("../../assets/fonts/Inter_ExtraBold.ttf"),
28
+ });
29
+
30
+ const { getMe, isCheckingAuth, loadCachedUser, user } = useAuthStore();
31
+ const { colorScheme, setColorScheme } = useColorScheme();
32
+ const colors = Colors[colorScheme ?? "light"];
33
+
34
+ const segments = useSegments();
35
+ const router = useRouter();
36
+
37
+ useEffect(() => {
38
+ if (fontsLoaded || fontError) {
39
+ SplashScreen.hideAsync();
40
+ }
41
+ }, [fontsLoaded, fontError]);
42
+
43
+ useEffect(() => {
44
+ // Load cached user quickly, then fetch fresh in background
45
+ loadCachedUser().then(() => {
46
+ getMe();
47
+ });
48
+
49
+ // Load saved theme
50
+ AsyncStorage.getItem("theme").then((savedTheme) => {
51
+ if (savedTheme === "light" || savedTheme === "dark") {
52
+ setColorScheme(savedTheme);
53
+ }
54
+ });
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }, []);
57
+
58
+ useEffect(() => {
59
+ if (isCheckingAuth) return;
60
+
61
+ const inAuthGroup = segments[0] === "(auth)";
62
+
63
+ if (!user && !inAuthGroup) {
64
+ // Redirect to the auth group
65
+ router.replace("/(auth)/login");
66
+ } else if (user && inAuthGroup) {
67
+ // Redirect away from auth
68
+ router.replace("/(tabs)");
69
+ }
70
+ }, [user, isCheckingAuth, segments]);
71
+
72
+ if (!fontsLoaded && !fontError) {
73
+ return null;
74
+ }
75
+
76
+ if (isCheckingAuth) {
77
+ return <Loading />;
78
+ }
79
+
80
+ return (
81
+ <QueryClientProvider client={queryClient}>
82
+ <GestureHandlerRootView style={{ flex: 1 }}>
83
+ <PaperProvider>
84
+ <StatusBar style={colorScheme === "dark" ? "light" : "dark"} />
85
+ <Stack
86
+ screenOptions={{
87
+ headerShown: false,
88
+ contentStyle: { backgroundColor: colors.base100 },
89
+ }}
90
+ >
91
+ <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
92
+ <Stack.Screen
93
+ name="(auth)"
94
+ options={{ headerShown: false, animation: "fade" }}
95
+ />
96
+ </Stack>
97
+ <Toast />
98
+ </PaperProvider>
99
+ </GestureHandlerRootView>
100
+ </QueryClientProvider>
101
+ );
102
+ }
@@ -0,0 +1,82 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ @layer base {
6
+ :root {
7
+ /* Surface */
8
+ --color-base-100: 255 255 255; /* #FFFFFF */
9
+ --color-base-200: 248 250 252; /* #F8FAFC */
10
+ --color-base-300: 226 232 240; /* #E2E8F0 */
11
+ --color-base-content: 15 23 42; /* #0F172A */
12
+
13
+ /* Brand */
14
+ --color-primary: 59 130 246; /* #3B82F6 */
15
+ --color-primary-content: 255 255 255;
16
+
17
+ --color-secondary: 100 116 139; /* #64748B */
18
+ --color-secondary-content: 255 255 255;
19
+
20
+ --color-accent: 20 184 166; /* #14B8A6 */
21
+ --color-accent-content: 255 255 255;
22
+
23
+ /* Neutral */
24
+ --color-neutral: 30 41 59; /* #1E293B */
25
+ --color-neutral-content: 255 255 255;
26
+
27
+ /* Semantic */
28
+ --color-info: 14 165 233; /* #0EA5E9 */
29
+ --color-info-content: 255 255 255;
30
+
31
+ --color-success: 34 197 94; /* #22C55E */
32
+ --color-success-content: 255 255 255;
33
+
34
+ --color-warning: 245 158 11; /* #F59E0B */
35
+ --color-warning-content: 255 255 255;
36
+
37
+ --color-error: 239 68 68; /* #EF4444 */
38
+ --color-error-content: 255 255 255;
39
+
40
+ /* Radius */
41
+ --rounded-box: 12px;
42
+ --rounded-btn: 10px;
43
+ --rounded-badge: 8px;
44
+ }
45
+
46
+ @media (prefers-color-scheme: dark) {
47
+ :root {
48
+ /* Surface */
49
+ --color-base-100: 17 24 39; /* #111827 */
50
+ --color-base-200: 27 36 51; /* #1B2433 */
51
+ --color-base-300: 42 52 69; /* #2A3445 */
52
+ --color-base-content: 248 250 252;/* #F8FAFC */
53
+
54
+ /* Brand */
55
+ --color-primary: 96 165 250; /* #60A5FA */
56
+ --color-primary-content: 255 255 255;
57
+
58
+ --color-secondary: 148 163 184; /* #94A3B8 */
59
+ --color-secondary-content: 17 24 39;
60
+
61
+ --color-accent: 45 212 191; /* #2DD4BF */
62
+ --color-accent-content: 17 24 39;
63
+
64
+ /* Neutral */
65
+ --color-neutral: 248 250 252; /* #F8FAFC */
66
+ --color-neutral-content: 17 24 39;
67
+
68
+ /* Semantic */
69
+ --color-info: 56 189 248; /* #38BDF8 */
70
+ --color-info-content: 17 24 39;
71
+
72
+ --color-success: 74 222 128; /* #4ADE80 */
73
+ --color-success-content: 17 24 39;
74
+
75
+ --color-warning: 251 191 36; /* #FBBF24 */
76
+ --color-warning-content: 17 24 39;
77
+
78
+ --color-error: 248 113 113; /* #F87171 */
79
+ --color-error-content: 255 255 255;
80
+ }
81
+ }
82
+ }