@imksh/create 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/bin/index.js +3 -0
- package/package.json +43 -0
- package/src/commands/create.js +90 -0
- package/src/index.js +41 -0
- package/src/utils/askTemplate.js +25 -0
- package/src/utils/copyTemplate.js +36 -0
- package/src/utils/installPackages.js +25 -0
- package/src/utils/logger.js +17 -0
- package/src/utils/runGit.js +11 -0
- package/templates/mern/_gitignore +2 -0
- package/templates/mern/client/_gitignore +24 -0
- package/templates/mern/client/index.html +14 -0
- package/templates/mern/client/package.json +39 -0
- package/templates/mern/client/public/_redirects +1 -0
- package/templates/mern/client/public/favicon.ico +0 -0
- package/templates/mern/client/public/favicon.svg +1 -0
- package/templates/mern/client/public/logo.png +0 -0
- package/templates/mern/client/public/manifest.json +24 -0
- package/templates/mern/client/public/sw.js +56 -0
- package/templates/mern/client/src/App.jsx +68 -0
- package/templates/mern/client/src/assets/animations/loading.json +1 -0
- package/templates/mern/client/src/assets/data/navigation.js +29 -0
- package/templates/mern/client/src/assets/images/logo.png +0 -0
- package/templates/mern/client/src/components/common/Breadcrumbs.jsx +27 -0
- package/templates/mern/client/src/components/common/Loading.jsx +19 -0
- package/templates/mern/client/src/components/common/LottieIcon.jsx +36 -0
- package/templates/mern/client/src/components/common/NotFound.jsx +78 -0
- package/templates/mern/client/src/components/common/PwaInstallPrompt.jsx +72 -0
- package/templates/mern/client/src/components/common/SEO.jsx +67 -0
- package/templates/mern/client/src/components/common/Scroll.jsx +25 -0
- package/templates/mern/client/src/components/common/Table.jsx +110 -0
- package/templates/mern/client/src/components/common/ToggleSwitch.jsx +38 -0
- package/templates/mern/client/src/components/common/Unauthorized.jsx +76 -0
- package/templates/mern/client/src/components/layout/ProtectedRoute.jsx +17 -0
- package/templates/mern/client/src/components/layout/PublicLayout.jsx +13 -0
- package/templates/mern/client/src/components/layout/SidebarLayout.jsx +37 -0
- package/templates/mern/client/src/components/modals/ConfirmModal.jsx +135 -0
- package/templates/mern/client/src/components/modals/Modal.jsx +94 -0
- package/templates/mern/client/src/components/skeletons/common/CardSkeleton.jsx +23 -0
- package/templates/mern/client/src/components/skeletons/common/DashboardSkeleton.jsx +19 -0
- package/templates/mern/client/src/components/skeletons/common/ListSkeleton.jsx +24 -0
- package/templates/mern/client/src/components/skeletons/common/PageSkeleton.jsx +26 -0
- package/templates/mern/client/src/components/skeletons/common/ProfileSkeleton.jsx +23 -0
- package/templates/mern/client/src/components/skeletons/common/Skeleton.jsx +18 -0
- package/templates/mern/client/src/components/skeletons/common/TableSkeleton.jsx +33 -0
- package/templates/mern/client/src/components/ui/Header.jsx +230 -0
- package/templates/mern/client/src/components/ui/SidebarHeader.jsx +27 -0
- package/templates/mern/client/src/components/ui/sidebar.jsx +152 -0
- package/templates/mern/client/src/config/api.js +22 -0
- package/templates/mern/client/src/config/appConfig.js +44 -0
- package/templates/mern/client/src/config/navigation.js +14 -0
- package/templates/mern/client/src/hooks/useLenis.js +28 -0
- package/templates/mern/client/src/hooks/usePwaInstall.js +45 -0
- package/templates/mern/client/src/hooks/useWindowSize.js +25 -0
- package/templates/mern/client/src/index.css +158 -0
- package/templates/mern/client/src/main.jsx +24 -0
- package/templates/mern/client/src/pages/Home.jsx +154 -0
- package/templates/mern/client/src/pages/Login.jsx +196 -0
- package/templates/mern/client/src/pages/Profile.jsx +9 -0
- package/templates/mern/client/src/services/authService.js +16 -0
- package/templates/mern/client/src/store/useAuthStore.js +98 -0
- package/templates/mern/client/src/store/useUiStore.js +54 -0
- package/templates/mern/client/src/utils/getInitials.js +10 -0
- package/templates/mern/client/vite.config.js +8 -0
- package/templates/mern/package.json +18 -0
- package/templates/mern/server/.env.example +62 -0
- package/templates/mern/server/README.md +65 -0
- package/templates/mern/server/_gitignore +24 -0
- package/templates/mern/server/package.json +32 -0
- package/templates/mern/server/src/app.js +42 -0
- package/templates/mern/server/src/config/cloudinary.js +9 -0
- package/templates/mern/server/src/config/db.js +14 -0
- package/templates/mern/server/src/config/dotenv.js +2 -0
- package/templates/mern/server/src/config/email.js +30 -0
- package/templates/mern/server/src/config/socket.js +54 -0
- package/templates/mern/server/src/config/webPush.js +9 -0
- package/templates/mern/server/src/controllers/auth.controller.js +153 -0
- package/templates/mern/server/src/controllers/upload.controller.js +26 -0
- package/templates/mern/server/src/index.js +24 -0
- package/templates/mern/server/src/middleware/auth.middleware.js +43 -0
- package/templates/mern/server/src/middleware/errorHandler.js +22 -0
- package/templates/mern/server/src/middleware/multer.js +21 -0
- package/templates/mern/server/src/middleware/rateLimiter.js +57 -0
- package/templates/mern/server/src/models/otp.model.js +21 -0
- package/templates/mern/server/src/models/pushSubscription.model.js +32 -0
- package/templates/mern/server/src/models/user.model.js +43 -0
- package/templates/mern/server/src/routes/auth.route.js +22 -0
- package/templates/mern/server/src/routes/index.js +10 -0
- package/templates/mern/server/src/routes/upload.route.js +12 -0
- package/templates/mern/server/src/services/auth.service.js +162 -0
- package/templates/mern/server/src/services/auth.service.ts +0 -0
- package/templates/mern/server/src/utils/authToken.js +26 -0
- package/templates/mern/server/src/utils/cloudinary.js +27 -0
- package/templates/mern/server/src/utils/cloudinaryUpload.js +87 -0
- package/templates/mern/server/src/utils/emailOtp.js +190 -0
- package/templates/mern/server/src/utils/genOtpToken.js +20 -0
- package/templates/mern/server/src/utils/generateVapidKeys.js +12 -0
- package/templates/mern/server/src/utils/jwt.js +25 -0
- package/templates/mern/server/src/utils/logger.js +25 -0
- package/templates/mern-ts/_gitignore +2 -0
- package/templates/mern-ts/client/_gitignore +24 -0
- package/templates/mern-ts/client/index.html +14 -0
- package/templates/mern-ts/client/package.json +45 -0
- package/templates/mern-ts/client/public/_redirects +1 -0
- package/templates/mern-ts/client/public/favicon.ico +0 -0
- package/templates/mern-ts/client/public/favicon.svg +1 -0
- package/templates/mern-ts/client/public/logo.png +0 -0
- package/templates/mern-ts/client/public/manifest.json +24 -0
- package/templates/mern-ts/client/public/sw.js +56 -0
- package/templates/mern-ts/client/src/App.tsx +68 -0
- package/templates/mern-ts/client/src/assets/animations/loading.json +1 -0
- package/templates/mern-ts/client/src/assets/data/navigation.ts +29 -0
- package/templates/mern-ts/client/src/assets/images/logo.png +0 -0
- package/templates/mern-ts/client/src/components/common/Breadcrumbs.tsx +27 -0
- package/templates/mern-ts/client/src/components/common/Loading.tsx +19 -0
- package/templates/mern-ts/client/src/components/common/LottieIcon.tsx +36 -0
- package/templates/mern-ts/client/src/components/common/NotFound.tsx +78 -0
- package/templates/mern-ts/client/src/components/common/PwaInstallPrompt.tsx +72 -0
- package/templates/mern-ts/client/src/components/common/SEO.tsx +67 -0
- package/templates/mern-ts/client/src/components/common/Scroll.tsx +25 -0
- package/templates/mern-ts/client/src/components/common/Table.tsx +118 -0
- package/templates/mern-ts/client/src/components/common/ToggleSwitch.tsx +38 -0
- package/templates/mern-ts/client/src/components/common/Unauthorized.tsx +76 -0
- package/templates/mern-ts/client/src/components/layout/ProtectedRoute.tsx +23 -0
- package/templates/mern-ts/client/src/components/layout/PublicLayout.tsx +13 -0
- package/templates/mern-ts/client/src/components/layout/SidebarLayout.tsx +37 -0
- package/templates/mern-ts/client/src/components/modals/ConfirmModal.tsx +135 -0
- package/templates/mern-ts/client/src/components/modals/Modal.tsx +94 -0
- package/templates/mern-ts/client/src/components/skeletons/common/CardSkeleton.tsx +23 -0
- package/templates/mern-ts/client/src/components/skeletons/common/DashboardSkeleton.tsx +19 -0
- package/templates/mern-ts/client/src/components/skeletons/common/ListSkeleton.tsx +24 -0
- package/templates/mern-ts/client/src/components/skeletons/common/PageSkeleton.tsx +26 -0
- package/templates/mern-ts/client/src/components/skeletons/common/ProfileSkeleton.tsx +23 -0
- package/templates/mern-ts/client/src/components/skeletons/common/Skeleton.tsx +18 -0
- package/templates/mern-ts/client/src/components/skeletons/common/TableSkeleton.tsx +33 -0
- package/templates/mern-ts/client/src/components/ui/Header.tsx +230 -0
- package/templates/mern-ts/client/src/components/ui/SidebarHeader.tsx +27 -0
- package/templates/mern-ts/client/src/components/ui/sidebar.tsx +152 -0
- package/templates/mern-ts/client/src/config/api.ts +22 -0
- package/templates/mern-ts/client/src/config/appConfig.ts +44 -0
- package/templates/mern-ts/client/src/config/navigation.ts +14 -0
- package/templates/mern-ts/client/src/hooks/useLenis.ts +28 -0
- package/templates/mern-ts/client/src/hooks/usePwaInstall.ts +45 -0
- package/templates/mern-ts/client/src/hooks/useWindowSize.ts +25 -0
- package/templates/mern-ts/client/src/index.css +158 -0
- package/templates/mern-ts/client/src/main.tsx +24 -0
- package/templates/mern-ts/client/src/pages/Home.tsx +154 -0
- package/templates/mern-ts/client/src/pages/Login.tsx +196 -0
- package/templates/mern-ts/client/src/pages/Profile.tsx +9 -0
- package/templates/mern-ts/client/src/services/authService.ts +16 -0
- package/templates/mern-ts/client/src/store/useAuthStore.ts +98 -0
- package/templates/mern-ts/client/src/store/useUiStore.ts +54 -0
- package/templates/mern-ts/client/src/utils/getInitials.ts +10 -0
- package/templates/mern-ts/client/tsconfig.json +25 -0
- package/templates/mern-ts/client/tsconfig.node.json +10 -0
- package/templates/mern-ts/client/vite.config.ts +8 -0
- package/templates/mern-ts/package.json +19 -0
- package/templates/mern-ts/server/.env.example +62 -0
- package/templates/mern-ts/server/README.md +69 -0
- package/templates/mern-ts/server/_gitignore +24 -0
- package/templates/mern-ts/server/package.json +47 -0
- package/templates/mern-ts/server/src/app.ts +36 -0
- package/templates/mern-ts/server/src/config/cloudinary.ts +9 -0
- package/templates/mern-ts/server/src/config/db.ts +15 -0
- package/templates/mern-ts/server/src/config/dotenv.ts +2 -0
- package/templates/mern-ts/server/src/config/email.ts +28 -0
- package/templates/mern-ts/server/src/config/socket.ts +54 -0
- package/templates/mern-ts/server/src/config/webPush.ts +9 -0
- package/templates/mern-ts/server/src/controllers/auth.controller.ts +126 -0
- package/templates/mern-ts/server/src/controllers/upload.controller.ts +22 -0
- package/templates/mern-ts/server/src/index.ts +17 -0
- package/templates/mern-ts/server/src/middleware/auth.middleware.ts +38 -0
- package/templates/mern-ts/server/src/middleware/errorHandler.ts +16 -0
- package/templates/mern-ts/server/src/middleware/multer.ts +20 -0
- package/templates/mern-ts/server/src/middleware/rateLimiter.ts +53 -0
- package/templates/mern-ts/server/src/models/otp.model.ts +21 -0
- package/templates/mern-ts/server/src/models/pushSubscription.model.ts +32 -0
- package/templates/mern-ts/server/src/models/user.model.ts +43 -0
- package/templates/mern-ts/server/src/routes/auth.route.ts +22 -0
- package/templates/mern-ts/server/src/routes/index.ts +10 -0
- package/templates/mern-ts/server/src/routes/upload.route.ts +11 -0
- package/templates/mern-ts/server/src/services/auth.service.ts +115 -0
- package/templates/mern-ts/server/src/types/express.d.ts +10 -0
- package/templates/mern-ts/server/src/utils/cloudinaryUpload.ts +44 -0
- package/templates/mern-ts/server/src/utils/emailOtp.ts +30 -0
- package/templates/mern-ts/server/src/utils/genOtpToken.ts +22 -0
- package/templates/mern-ts/server/src/utils/generateVapidKeys.ts +12 -0
- package/templates/mern-ts/server/src/utils/jwt.ts +27 -0
- package/templates/mern-ts/server/src/utils/logger.ts +27 -0
- package/templates/mern-ts/server/tsconfig.json +14 -0
- package/templates/next/_gitignore +24 -0
- package/templates/next/package.json +20 -0
- package/templates/next/src/app/layout.js +7 -0
- package/templates/next/src/app/page.js +218 -0
- package/templates/next-ts/_gitignore +24 -0
- package/templates/next-ts/package.json +24 -0
- package/templates/next-ts/src/app/layout.tsx +9 -0
- package/templates/next-ts/src/app/page.tsx +218 -0
- package/templates/next-ts/tsconfig.json +27 -0
- package/templates/node/.env.example +62 -0
- package/templates/node/README.md +65 -0
- package/templates/node/_gitignore +24 -0
- package/templates/node/package.json +32 -0
- package/templates/node/src/app.js +42 -0
- package/templates/node/src/config/cloudinary.js +9 -0
- package/templates/node/src/config/db.js +14 -0
- package/templates/node/src/config/dotenv.js +2 -0
- package/templates/node/src/config/email.js +30 -0
- package/templates/node/src/config/socket.js +54 -0
- package/templates/node/src/config/webPush.js +9 -0
- package/templates/node/src/controllers/auth.controller.js +153 -0
- package/templates/node/src/controllers/upload.controller.js +26 -0
- package/templates/node/src/index.js +24 -0
- package/templates/node/src/middleware/auth.middleware.js +43 -0
- package/templates/node/src/middleware/errorHandler.js +22 -0
- package/templates/node/src/middleware/multer.js +21 -0
- package/templates/node/src/middleware/rateLimiter.js +57 -0
- package/templates/node/src/models/otp.model.js +21 -0
- package/templates/node/src/models/pushSubscription.model.js +32 -0
- package/templates/node/src/models/user.model.js +43 -0
- package/templates/node/src/routes/auth.route.js +22 -0
- package/templates/node/src/routes/index.js +10 -0
- package/templates/node/src/routes/upload.route.js +12 -0
- package/templates/node/src/services/auth.service.js +162 -0
- package/templates/node/src/services/auth.service.ts +0 -0
- package/templates/node/src/utils/authToken.js +26 -0
- package/templates/node/src/utils/cloudinary.js +27 -0
- package/templates/node/src/utils/cloudinaryUpload.js +87 -0
- package/templates/node/src/utils/emailOtp.js +190 -0
- package/templates/node/src/utils/genOtpToken.js +20 -0
- package/templates/node/src/utils/generateVapidKeys.js +12 -0
- package/templates/node/src/utils/jwt.js +25 -0
- package/templates/node/src/utils/logger.js +25 -0
- package/templates/node-prisma/.env.example +63 -0
- package/templates/node-prisma/README.md +69 -0
- package/templates/node-prisma/_gitignore +24 -0
- package/templates/node-prisma/package.json +35 -0
- package/templates/node-prisma/prisma/schema.prisma +41 -0
- package/templates/node-prisma/src/app.js +42 -0
- package/templates/node-prisma/src/config/cloudinary.js +9 -0
- package/templates/node-prisma/src/config/db.js +16 -0
- package/templates/node-prisma/src/config/dotenv.js +2 -0
- package/templates/node-prisma/src/config/email.js +30 -0
- package/templates/node-prisma/src/config/socket.js +54 -0
- package/templates/node-prisma/src/config/webPush.js +9 -0
- package/templates/node-prisma/src/controllers/auth.controller.js +146 -0
- package/templates/node-prisma/src/controllers/upload.controller.js +26 -0
- package/templates/node-prisma/src/index.js +24 -0
- package/templates/node-prisma/src/middleware/auth.middleware.js +44 -0
- package/templates/node-prisma/src/middleware/errorHandler.js +22 -0
- package/templates/node-prisma/src/middleware/multer.js +21 -0
- package/templates/node-prisma/src/middleware/rateLimiter.js +57 -0
- package/templates/node-prisma/src/routes/auth.route.js +22 -0
- package/templates/node-prisma/src/routes/index.js +10 -0
- package/templates/node-prisma/src/routes/upload.route.js +12 -0
- package/templates/node-prisma/src/services/auth.service.js +163 -0
- package/templates/node-prisma/src/services/auth.service.ts +0 -0
- package/templates/node-prisma/src/utils/authToken.js +26 -0
- package/templates/node-prisma/src/utils/cloudinary.js +27 -0
- package/templates/node-prisma/src/utils/cloudinaryUpload.js +87 -0
- package/templates/node-prisma/src/utils/emailOtp.js +190 -0
- package/templates/node-prisma/src/utils/genOtpToken.js +20 -0
- package/templates/node-prisma/src/utils/generateVapidKeys.js +12 -0
- package/templates/node-prisma/src/utils/jwt.js +25 -0
- package/templates/node-prisma/src/utils/logger.js +25 -0
- package/templates/node-prisma-ts/.env.example +63 -0
- package/templates/node-prisma-ts/README.md +73 -0
- package/templates/node-prisma-ts/_gitignore +24 -0
- package/templates/node-prisma-ts/package.json +48 -0
- package/templates/node-prisma-ts/prisma/schema.prisma +41 -0
- package/templates/node-prisma-ts/src/app.ts +36 -0
- package/templates/node-prisma-ts/src/config/cloudinary.ts +9 -0
- package/templates/node-prisma-ts/src/config/db.ts +16 -0
- package/templates/node-prisma-ts/src/config/dotenv.ts +2 -0
- package/templates/node-prisma-ts/src/config/email.ts +28 -0
- package/templates/node-prisma-ts/src/config/socket.ts +54 -0
- package/templates/node-prisma-ts/src/config/webPush.ts +9 -0
- package/templates/node-prisma-ts/src/controllers/auth.controller.ts +124 -0
- package/templates/node-prisma-ts/src/controllers/upload.controller.ts +22 -0
- package/templates/node-prisma-ts/src/index.ts +17 -0
- package/templates/node-prisma-ts/src/middleware/auth.middleware.ts +45 -0
- package/templates/node-prisma-ts/src/middleware/errorHandler.ts +16 -0
- package/templates/node-prisma-ts/src/middleware/multer.ts +20 -0
- package/templates/node-prisma-ts/src/middleware/rateLimiter.ts +53 -0
- package/templates/node-prisma-ts/src/routes/auth.route.ts +22 -0
- package/templates/node-prisma-ts/src/routes/index.ts +10 -0
- package/templates/node-prisma-ts/src/routes/upload.route.ts +11 -0
- package/templates/node-prisma-ts/src/services/auth.service.ts +163 -0
- package/templates/node-prisma-ts/src/types/express.d.ts +10 -0
- package/templates/node-prisma-ts/src/utils/cloudinaryUpload.ts +44 -0
- package/templates/node-prisma-ts/src/utils/emailOtp.ts +30 -0
- package/templates/node-prisma-ts/src/utils/genOtpToken.ts +22 -0
- package/templates/node-prisma-ts/src/utils/generateVapidKeys.ts +12 -0
- package/templates/node-prisma-ts/src/utils/jwt.ts +27 -0
- package/templates/node-prisma-ts/src/utils/logger.ts +27 -0
- package/templates/node-prisma-ts/tsconfig.json +14 -0
- package/templates/node-ts/.env.example +62 -0
- package/templates/node-ts/README.md +69 -0
- package/templates/node-ts/_gitignore +24 -0
- package/templates/node-ts/package.json +47 -0
- package/templates/node-ts/src/app.ts +36 -0
- package/templates/node-ts/src/config/cloudinary.ts +9 -0
- package/templates/node-ts/src/config/db.ts +15 -0
- package/templates/node-ts/src/config/dotenv.ts +2 -0
- package/templates/node-ts/src/config/email.ts +28 -0
- package/templates/node-ts/src/config/socket.ts +54 -0
- package/templates/node-ts/src/config/webPush.ts +9 -0
- package/templates/node-ts/src/controllers/auth.controller.ts +126 -0
- package/templates/node-ts/src/controllers/upload.controller.ts +22 -0
- package/templates/node-ts/src/index.ts +17 -0
- package/templates/node-ts/src/middleware/auth.middleware.ts +38 -0
- package/templates/node-ts/src/middleware/errorHandler.ts +16 -0
- package/templates/node-ts/src/middleware/multer.ts +20 -0
- package/templates/node-ts/src/middleware/rateLimiter.ts +53 -0
- package/templates/node-ts/src/models/otp.model.ts +21 -0
- package/templates/node-ts/src/models/pushSubscription.model.ts +32 -0
- package/templates/node-ts/src/models/user.model.ts +43 -0
- package/templates/node-ts/src/routes/auth.route.ts +22 -0
- package/templates/node-ts/src/routes/index.ts +10 -0
- package/templates/node-ts/src/routes/upload.route.ts +11 -0
- package/templates/node-ts/src/services/auth.service.ts +115 -0
- package/templates/node-ts/src/types/express.d.ts +10 -0
- package/templates/node-ts/src/utils/cloudinaryUpload.ts +44 -0
- package/templates/node-ts/src/utils/emailOtp.ts +30 -0
- package/templates/node-ts/src/utils/genOtpToken.ts +22 -0
- package/templates/node-ts/src/utils/generateVapidKeys.ts +12 -0
- package/templates/node-ts/src/utils/jwt.ts +27 -0
- package/templates/node-ts/src/utils/logger.ts +27 -0
- package/templates/node-ts/tsconfig.json +18 -0
- package/templates/react/.env.example +1 -0
- package/templates/react/_gitignore +24 -0
- package/templates/react/index.html +14 -0
- package/templates/react/package.json +39 -0
- package/templates/react/public/_redirects +1 -0
- package/templates/react/public/favicon.ico +0 -0
- package/templates/react/public/favicon.svg +1 -0
- package/templates/react/public/logo.png +0 -0
- package/templates/react/public/manifest.json +24 -0
- package/templates/react/public/sw.js +56 -0
- package/templates/react/src/App.jsx +68 -0
- package/templates/react/src/assets/animations/loading.json +1 -0
- package/templates/react/src/assets/data/navigation.js +29 -0
- package/templates/react/src/assets/images/logo.png +0 -0
- package/templates/react/src/components/common/Breadcrumbs.jsx +27 -0
- package/templates/react/src/components/common/Loading.jsx +19 -0
- package/templates/react/src/components/common/LottieIcon.jsx +36 -0
- package/templates/react/src/components/common/NotFound.jsx +78 -0
- package/templates/react/src/components/common/PwaInstallPrompt.jsx +72 -0
- package/templates/react/src/components/common/SEO.jsx +67 -0
- package/templates/react/src/components/common/Scroll.jsx +25 -0
- package/templates/react/src/components/common/Table.jsx +110 -0
- package/templates/react/src/components/common/ToggleSwitch.jsx +38 -0
- package/templates/react/src/components/common/Unauthorized.jsx +76 -0
- package/templates/react/src/components/layout/ProtectedRoute.jsx +17 -0
- package/templates/react/src/components/layout/PublicLayout.jsx +13 -0
- package/templates/react/src/components/layout/SidebarLayout.jsx +37 -0
- package/templates/react/src/components/modals/ConfirmModal.jsx +135 -0
- package/templates/react/src/components/modals/Modal.jsx +94 -0
- package/templates/react/src/components/skeletons/common/CardSkeleton.jsx +23 -0
- package/templates/react/src/components/skeletons/common/DashboardSkeleton.jsx +19 -0
- package/templates/react/src/components/skeletons/common/ListSkeleton.jsx +24 -0
- package/templates/react/src/components/skeletons/common/PageSkeleton.jsx +26 -0
- package/templates/react/src/components/skeletons/common/ProfileSkeleton.jsx +23 -0
- package/templates/react/src/components/skeletons/common/Skeleton.jsx +18 -0
- package/templates/react/src/components/skeletons/common/TableSkeleton.jsx +33 -0
- package/templates/react/src/components/ui/Header.jsx +230 -0
- package/templates/react/src/components/ui/SidebarHeader.jsx +27 -0
- package/templates/react/src/components/ui/sidebar.jsx +152 -0
- package/templates/react/src/config/api.js +22 -0
- package/templates/react/src/config/appConfig.js +44 -0
- package/templates/react/src/config/navigation.js +14 -0
- package/templates/react/src/hooks/useLenis.js +28 -0
- package/templates/react/src/hooks/usePwaInstall.js +45 -0
- package/templates/react/src/hooks/useWindowSize.js +25 -0
- package/templates/react/src/index.css +158 -0
- package/templates/react/src/main.jsx +24 -0
- package/templates/react/src/pages/Home.jsx +154 -0
- package/templates/react/src/pages/Login.jsx +196 -0
- package/templates/react/src/pages/Profile.jsx +9 -0
- package/templates/react/src/services/authService.js +16 -0
- package/templates/react/src/store/useAuthStore.js +98 -0
- package/templates/react/src/store/useUiStore.js +54 -0
- package/templates/react/src/utils/getInitials.js +10 -0
- package/templates/react/vite.config.js +8 -0
- package/templates/react-ts/_gitignore +24 -0
- package/templates/react-ts/index.html +14 -0
- package/templates/react-ts/package.json +45 -0
- package/templates/react-ts/public/_redirects +1 -0
- package/templates/react-ts/public/favicon.ico +0 -0
- package/templates/react-ts/public/favicon.svg +1 -0
- package/templates/react-ts/public/logo.png +0 -0
- package/templates/react-ts/public/manifest.json +24 -0
- package/templates/react-ts/public/sw.js +56 -0
- package/templates/react-ts/src/App.tsx +68 -0
- package/templates/react-ts/src/assets/animations/loading.json +1 -0
- package/templates/react-ts/src/assets/data/navigation.ts +29 -0
- package/templates/react-ts/src/assets/images/logo.png +0 -0
- package/templates/react-ts/src/components/common/Breadcrumbs.tsx +27 -0
- package/templates/react-ts/src/components/common/Loading.tsx +19 -0
- package/templates/react-ts/src/components/common/LottieIcon.tsx +36 -0
- package/templates/react-ts/src/components/common/NotFound.tsx +78 -0
- package/templates/react-ts/src/components/common/PwaInstallPrompt.tsx +72 -0
- package/templates/react-ts/src/components/common/SEO.tsx +67 -0
- package/templates/react-ts/src/components/common/Scroll.tsx +25 -0
- package/templates/react-ts/src/components/common/Table.tsx +118 -0
- package/templates/react-ts/src/components/common/ToggleSwitch.tsx +38 -0
- package/templates/react-ts/src/components/common/Unauthorized.tsx +76 -0
- package/templates/react-ts/src/components/layout/ProtectedRoute.tsx +23 -0
- package/templates/react-ts/src/components/layout/PublicLayout.tsx +13 -0
- package/templates/react-ts/src/components/layout/SidebarLayout.tsx +37 -0
- package/templates/react-ts/src/components/modals/ConfirmModal.tsx +135 -0
- package/templates/react-ts/src/components/modals/Modal.tsx +94 -0
- package/templates/react-ts/src/components/skeletons/common/CardSkeleton.tsx +23 -0
- package/templates/react-ts/src/components/skeletons/common/DashboardSkeleton.tsx +19 -0
- package/templates/react-ts/src/components/skeletons/common/ListSkeleton.tsx +24 -0
- package/templates/react-ts/src/components/skeletons/common/PageSkeleton.tsx +26 -0
- package/templates/react-ts/src/components/skeletons/common/ProfileSkeleton.tsx +23 -0
- package/templates/react-ts/src/components/skeletons/common/Skeleton.tsx +18 -0
- package/templates/react-ts/src/components/skeletons/common/TableSkeleton.tsx +33 -0
- package/templates/react-ts/src/components/ui/Header.tsx +230 -0
- package/templates/react-ts/src/components/ui/SidebarHeader.tsx +27 -0
- package/templates/react-ts/src/components/ui/sidebar.tsx +152 -0
- package/templates/react-ts/src/config/api.ts +22 -0
- package/templates/react-ts/src/config/appConfig.ts +44 -0
- package/templates/react-ts/src/config/navigation.ts +14 -0
- package/templates/react-ts/src/hooks/useLenis.ts +28 -0
- package/templates/react-ts/src/hooks/usePwaInstall.ts +45 -0
- package/templates/react-ts/src/hooks/useWindowSize.ts +25 -0
- package/templates/react-ts/src/index.css +158 -0
- package/templates/react-ts/src/main.tsx +24 -0
- package/templates/react-ts/src/pages/Home.tsx +154 -0
- package/templates/react-ts/src/pages/Login.tsx +196 -0
- package/templates/react-ts/src/pages/Profile.tsx +9 -0
- package/templates/react-ts/src/services/authService.ts +16 -0
- package/templates/react-ts/src/store/useAuthStore.ts +98 -0
- package/templates/react-ts/src/store/useUiStore.ts +54 -0
- package/templates/react-ts/src/utils/getInitials.ts +10 -0
- package/templates/react-ts/tsconfig.json +25 -0
- package/templates/react-ts/tsconfig.node.json +10 -0
- package/templates/react-ts/vite.config.ts +8 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');
|
|
2
|
+
@import "tailwindcss";
|
|
3
|
+
@plugin "flyonui";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/* ========================================
|
|
7
|
+
LIGHT THEME
|
|
8
|
+
======================================== */
|
|
9
|
+
:root, [data-theme="light"] {
|
|
10
|
+
/* --font-sans: "Outfit", sans-serif; */
|
|
11
|
+
--color-base-100: #ffffff;
|
|
12
|
+
--color-base-200: #f8fafc;
|
|
13
|
+
--color-base-300: #e2e8f0;
|
|
14
|
+
--color-base-content: #0f172a;
|
|
15
|
+
|
|
16
|
+
--color-primary: #2563eb;
|
|
17
|
+
--color-primary-content: #ffffff;
|
|
18
|
+
--color-secondary: #64748b;
|
|
19
|
+
--color-secondary-content: #ffffff;
|
|
20
|
+
--color-accent: #00b8a3;
|
|
21
|
+
--color-accent-content: #ffffff;
|
|
22
|
+
--color-neutral: #1e293b;
|
|
23
|
+
--color-neutral-content: #ffffff;
|
|
24
|
+
|
|
25
|
+
--color-info: #0ea5e9;
|
|
26
|
+
--color-success: #22c55e;
|
|
27
|
+
--color-warning: #f59e0b;
|
|
28
|
+
--color-error: #ef4444;
|
|
29
|
+
|
|
30
|
+
--rounded-box: 12px;
|
|
31
|
+
--rounded-btn: 10px;
|
|
32
|
+
--rounded-badge: 8px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* ========================================
|
|
36
|
+
DARK THEME
|
|
37
|
+
======================================== */
|
|
38
|
+
[data-theme="dark"] {
|
|
39
|
+
--color-base-100: #282828;
|
|
40
|
+
--color-base-200: #242424;
|
|
41
|
+
--color-base-300: #2d2d2d;
|
|
42
|
+
--color-base-content: #f5f5f5;
|
|
43
|
+
|
|
44
|
+
--color-primary: #2563eb;
|
|
45
|
+
--color-primary-content: #ffffff;
|
|
46
|
+
--color-secondary: #3a3a3a;
|
|
47
|
+
--color-secondary-content: #d4d4d4;
|
|
48
|
+
--color-accent: #00b8a3;
|
|
49
|
+
--color-accent-content: #ffffff;
|
|
50
|
+
--color-neutral: #2d2d2d;
|
|
51
|
+
--color-neutral-content: #f5f5f5;
|
|
52
|
+
|
|
53
|
+
--color-info: #38bdf8;
|
|
54
|
+
--color-success: #22c55e;
|
|
55
|
+
--color-warning: #f59e0b;
|
|
56
|
+
--color-error: #ef4444;
|
|
57
|
+
|
|
58
|
+
--rounded-box: 12px;
|
|
59
|
+
--rounded-btn: 10px;
|
|
60
|
+
--rounded-badge: 8px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ========================================
|
|
64
|
+
MODERN UI UTILITIES & ANIMATIONS
|
|
65
|
+
======================================== */
|
|
66
|
+
html {
|
|
67
|
+
scroll-behavior: smooth;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
body {
|
|
71
|
+
font-family: var(--font-sans);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.glass-panel {
|
|
75
|
+
background: rgba(255, 255, 255, 0.03);
|
|
76
|
+
backdrop-filter: blur(16px);
|
|
77
|
+
-webkit-backdrop-filter: blur(16px);
|
|
78
|
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[data-theme="light"] .glass-panel {
|
|
82
|
+
background: rgba(255, 255, 255, 0.6);
|
|
83
|
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@keyframes float {
|
|
87
|
+
0%, 100% { transform: translateY(0); }
|
|
88
|
+
50% { transform: translateY(-10px); }
|
|
89
|
+
}
|
|
90
|
+
.animate-float {
|
|
91
|
+
animation: float 6s ease-in-out infinite;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes float-slow {
|
|
95
|
+
0%, 100% { transform: translateY(0); }
|
|
96
|
+
50% { transform: translateY(-20px); }
|
|
97
|
+
}
|
|
98
|
+
.animate-float-slow {
|
|
99
|
+
animation: float-slow 8s ease-in-out infinite;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@keyframes pulse-glow {
|
|
103
|
+
0%, 100% { opacity: 0.4; transform: scale(1); }
|
|
104
|
+
50% { opacity: 0.8; transform: scale(1.05); }
|
|
105
|
+
}
|
|
106
|
+
.animate-pulse-glow {
|
|
107
|
+
animation: pulse-glow 4s ease-in-out infinite;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ========================================
|
|
111
|
+
ANIMATIONS
|
|
112
|
+
======================================== */
|
|
113
|
+
@keyframes slideInRight {
|
|
114
|
+
from { transform: translateX(100%); opacity: 0; }
|
|
115
|
+
to { transform: translateX(0); opacity: 1; }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.animate-slideInRight {
|
|
119
|
+
animation: slideInRight 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@keyframes fadeIn {
|
|
123
|
+
from { opacity: 0; transform: translateY(8px); }
|
|
124
|
+
to { opacity: 1; transform: translateY(0); }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.animate-fadeIn {
|
|
128
|
+
animation: fadeIn 0.3s ease forwards;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@keyframes zoomIn {
|
|
132
|
+
from { opacity: 0; transform: scale(0.95); }
|
|
133
|
+
to { opacity: 1; transform: scale(1); }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.animate-zoomIn {
|
|
137
|
+
animation: zoomIn 0.18s ease forwards;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Hide Scrollbar */
|
|
141
|
+
|
|
142
|
+
::-webkit-scrollbar {
|
|
143
|
+
width: 0px;
|
|
144
|
+
height: 0px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
* {
|
|
148
|
+
scrollbar-width: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.hide-scrollbar {
|
|
152
|
+
-ms-overflow-style: none; /* IE & Edge */
|
|
153
|
+
scrollbar-width: none; /* Firefox */
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.hide-scrollbar::-webkit-scrollbar {
|
|
157
|
+
display: none; /* Chrome, Safari */
|
|
158
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import { BrowserRouter } from "react-router-dom";
|
|
4
|
+
import App from "./App.jsx";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
|
|
7
|
+
if ("serviceWorker" in navigator) {
|
|
8
|
+
window.addEventListener("load", () => {
|
|
9
|
+
navigator.serviceWorker
|
|
10
|
+
.register("/sw.js")
|
|
11
|
+
.then((reg) =>
|
|
12
|
+
console.log("Service Worker registered successfully:", reg.scope),
|
|
13
|
+
)
|
|
14
|
+
.catch((err) => console.log("Service Worker registration failed:", err));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
19
|
+
<React.StrictMode>
|
|
20
|
+
<BrowserRouter>
|
|
21
|
+
<App />
|
|
22
|
+
</BrowserRouter>
|
|
23
|
+
</React.StrictMode>,
|
|
24
|
+
);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Link } from "react-router-dom";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import { FiZap, FiLayers, FiCpu, FiShield, FiArrowRight } from "react-icons/fi";
|
|
5
|
+
import appConfig from "../config/appConfig";
|
|
6
|
+
import toast from "react-hot-toast";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
|
|
9
|
+
const Home = () => {
|
|
10
|
+
const [count, setCount] = useState(0);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div className="min-h-screen w-full relative overflow-hidden flex flex-col items-center justify-center bg-gradient-to-br from-slate-950 via-slate-900 to-indigo-950 text-white font-sans p-6">
|
|
14
|
+
{/* Animated Glowing Ambient Orbs */}
|
|
15
|
+
<div className="absolute top-1/4 left-1/4 w-96 h-96 bg-primary/20 rounded-full blur-3xl -z-10 animate-pulse-glow" />
|
|
16
|
+
<div className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-indigo-500/10 rounded-full blur-3xl -z-10 animate-pulse-glow" />
|
|
17
|
+
|
|
18
|
+
{/* Hero Welcome Section */}
|
|
19
|
+
<div className="max-w-3xl w-full text-center space-y-6">
|
|
20
|
+
<motion.div
|
|
21
|
+
initial={{ opacity: 0, scale: 0.95 }}
|
|
22
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
23
|
+
transition={{ duration: 0.5 }}
|
|
24
|
+
className="flex items-center justify-center gap-3 mb-2"
|
|
25
|
+
>
|
|
26
|
+
<div className="bg-primary/20 text-primary border border-primary/30 p-2.5 rounded-2xl">
|
|
27
|
+
<img
|
|
28
|
+
src={appConfig.app.logo}
|
|
29
|
+
alt={appConfig.app.name}
|
|
30
|
+
className="w-8 h-8 rounded-full"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
<span className="text-sm font-semibold tracking-widest uppercase text-primary-content/65">
|
|
34
|
+
React Starter Kit
|
|
35
|
+
</span>
|
|
36
|
+
</motion.div>
|
|
37
|
+
|
|
38
|
+
<motion.h1
|
|
39
|
+
initial={{ opacity: 0, y: 15 }}
|
|
40
|
+
animate={{ opacity: 1, y: 0 }}
|
|
41
|
+
transition={{ duration: 0.5, delay: 0.1 }}
|
|
42
|
+
className="text-4xl sm:text-5xl font-black tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-white via-indigo-200 to-primary-content"
|
|
43
|
+
>
|
|
44
|
+
Welcome to {appConfig.app.name}
|
|
45
|
+
</motion.h1>
|
|
46
|
+
|
|
47
|
+
<motion.p
|
|
48
|
+
initial={{ opacity: 0, y: 15 }}
|
|
49
|
+
animate={{ opacity: 1, y: 0 }}
|
|
50
|
+
transition={{ duration: 0.5, delay: 0.2 }}
|
|
51
|
+
className="text-sm sm:text-base text-slate-300 max-w-xl mx-auto leading-relaxed"
|
|
52
|
+
>
|
|
53
|
+
A production-ready React setup built using <strong>@imksh/cli</strong>
|
|
54
|
+
. Everything is pre-configured and ready to publish.
|
|
55
|
+
</motion.p>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
{/* Features Grid */}
|
|
59
|
+
<motion.div
|
|
60
|
+
initial={{ opacity: 0, y: 20 }}
|
|
61
|
+
animate={{ opacity: 1, y: 0 }}
|
|
62
|
+
transition={{ duration: 0.6, delay: 0.3 }}
|
|
63
|
+
className="grid grid-cols-2 md:grid-cols-4 gap-4 max-w-4xl w-full my-10 shrink-0"
|
|
64
|
+
>
|
|
65
|
+
{/* Card 1 */}
|
|
66
|
+
<div className="bg-white/[0.03] backdrop-blur border border-white/[0.08] p-5 rounded-2xl flex flex-col gap-3">
|
|
67
|
+
<div className="text-primary text-xl">
|
|
68
|
+
<FiLayers />
|
|
69
|
+
</div>
|
|
70
|
+
<div>
|
|
71
|
+
<h3 className="text-sm font-bold text-white">Zustand & UI</h3>
|
|
72
|
+
<p className="text-xs text-slate-400 mt-1">
|
|
73
|
+
Light/Dark theme, sidebar collapse & responsive menu states.
|
|
74
|
+
</p>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{/* Card 2 */}
|
|
79
|
+
<div className="bg-white/[0.03] backdrop-blur border border-white/[0.08] p-5 rounded-2xl flex flex-col gap-3">
|
|
80
|
+
<div className="text-success text-xl">
|
|
81
|
+
<FiZap />
|
|
82
|
+
</div>
|
|
83
|
+
<div>
|
|
84
|
+
<h3 className="text-sm font-bold text-white">Tailwind & UI</h3>
|
|
85
|
+
<p className="text-xs text-slate-400 mt-1">
|
|
86
|
+
Tailwind CSS v4 + FlyonUI components pre-configured.
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
{/* Card 3 */}
|
|
92
|
+
<div className="bg-white/[0.03] backdrop-blur border border-white/[0.08] p-5 rounded-2xl flex flex-col gap-3">
|
|
93
|
+
<div className="text-warning text-xl">
|
|
94
|
+
<FiCpu />
|
|
95
|
+
</div>
|
|
96
|
+
<div>
|
|
97
|
+
<h3 className="text-sm font-bold text-white">Layouts & Router</h3>
|
|
98
|
+
<p className="text-xs text-slate-400 mt-1">
|
|
99
|
+
Public & Dashboard layouts with dynamic headers.
|
|
100
|
+
</p>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{/* Card 4 */}
|
|
105
|
+
<div className="bg-white/[0.03] backdrop-blur border border-white/[0.08] p-5 rounded-2xl flex flex-col gap-3">
|
|
106
|
+
<div className="text-error text-xl">
|
|
107
|
+
<FiShield />
|
|
108
|
+
</div>
|
|
109
|
+
<div>
|
|
110
|
+
<h3 className="text-sm font-bold text-white">Helpers</h3>
|
|
111
|
+
<p className="text-xs text-slate-400 mt-1">
|
|
112
|
+
Modal system, Tables, Loading Skeletons, and Auth Services.
|
|
113
|
+
</p>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</motion.div>
|
|
117
|
+
|
|
118
|
+
{/* Call to Actions */}
|
|
119
|
+
<motion.div
|
|
120
|
+
initial={{ opacity: 0, y: 15 }}
|
|
121
|
+
animate={{ opacity: 1, y: 0 }}
|
|
122
|
+
transition={{ duration: 0.5, delay: 0.4 }}
|
|
123
|
+
className="flex gap-4"
|
|
124
|
+
>
|
|
125
|
+
<motion.button
|
|
126
|
+
whileTap={{ scale: 0.95 }}
|
|
127
|
+
onClick={() => setCount((prev) => prev + 1)}
|
|
128
|
+
className="btn btn-primary rounded-xl px-6 py-2.5 font-semibold text-sm gap-2 shadow-lg shadow-primary/20 flex items-center transition-all"
|
|
129
|
+
>
|
|
130
|
+
count {count}
|
|
131
|
+
</motion.button>
|
|
132
|
+
<motion.button
|
|
133
|
+
whileTap={{ scale: 0.95 }}
|
|
134
|
+
onClick={()=>toast.success("Hello World")}
|
|
135
|
+
className="btn btn-outline rounded-xl px-6 py-2.5 font-semibold text-sm gap-2 flex items-center transition-all text-white border-white"
|
|
136
|
+
>
|
|
137
|
+
Show Toast
|
|
138
|
+
</motion.button>
|
|
139
|
+
</motion.div>
|
|
140
|
+
|
|
141
|
+
{/* Footer Branding */}
|
|
142
|
+
<motion.div
|
|
143
|
+
initial={{ opacity: 0 }}
|
|
144
|
+
animate={{ opacity: 0.5 }}
|
|
145
|
+
transition={{ duration: 0.5, delay: 0.5 }}
|
|
146
|
+
className="absolute bottom-6 text-xs text-slate-500 font-medium"
|
|
147
|
+
>
|
|
148
|
+
Generated with @imksh/cli • Version {appConfig.app.version}
|
|
149
|
+
</motion.div>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default Home;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Link, useNavigate } from "react-router-dom";
|
|
3
|
+
import {
|
|
4
|
+
Mail,
|
|
5
|
+
Lock,
|
|
6
|
+
User,
|
|
7
|
+
Eye,
|
|
8
|
+
EyeOff,
|
|
9
|
+
ArrowLeft,
|
|
10
|
+
GraduationCap,
|
|
11
|
+
} from "lucide-react";
|
|
12
|
+
import { useAuthStore } from "../store/useAuthStore";
|
|
13
|
+
import Loading from "../components/common/Loading";
|
|
14
|
+
|
|
15
|
+
const Login = () => {
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
const { login, signup, loading, error, user } = useAuthStore();
|
|
18
|
+
|
|
19
|
+
const [mode, setMode] = useState("login"); // "login" | "signup"
|
|
20
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
21
|
+
const [form, setForm] = useState({ name: "", email: "", password: "" });
|
|
22
|
+
|
|
23
|
+
const handleChange = (e) =>
|
|
24
|
+
setForm((prev) => ({ ...prev, [e.target.name]: e.target.value }));
|
|
25
|
+
|
|
26
|
+
const handleSubmit = async (e) => {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
let ok;
|
|
29
|
+
if (mode === "login") {
|
|
30
|
+
ok = await login(form.email, form.password);
|
|
31
|
+
} else {
|
|
32
|
+
ok = await signup(form.name, form.email, form.password);
|
|
33
|
+
}
|
|
34
|
+
if (ok) navigate("/");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (loading || user) {
|
|
38
|
+
return <Loading />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="min-h-dvh w-screen bg-base-100 text-base-content flex items-center justify-center p-4 font-sans">
|
|
43
|
+
<div className="relative w-full max-w-md">
|
|
44
|
+
{/* Card */}
|
|
45
|
+
<div className="bg-base-200/80 backdrop-blur-md border border-base-300 rounded-3xl p-8 shadow-2xl">
|
|
46
|
+
{/* Logo & title */}
|
|
47
|
+
<div className="flex flex-col items-center gap-2 mb-8">
|
|
48
|
+
<div className="w-12 h-12 rounded-2xl bg-primary/15 border border-primary/20 flex items-center justify-center text-2xl shadow-inner text-primary font-bold">
|
|
49
|
+
<GraduationCap size={24} />
|
|
50
|
+
</div>
|
|
51
|
+
<h1 className="text-2xl font-black tracking-tight">
|
|
52
|
+
{mode === "login" ? "Welcome back" : "Create account"}
|
|
53
|
+
</h1>
|
|
54
|
+
<p className="text-xs text-base-content/50 text-center">
|
|
55
|
+
{mode === "login"
|
|
56
|
+
? "Sign in to continue your learning journey"
|
|
57
|
+
: "Join LMS and start learning the MERN stack"}
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
{/* Tab switcher */}
|
|
62
|
+
<div className="tabs tabs-box bg-base-300/50 p-1 rounded-2xl w-full flex mb-6 border border-base-300">
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
onClick={() => setMode("login")}
|
|
66
|
+
className={`tab flex-1 rounded-xl text-sm font-bold transition-all ${
|
|
67
|
+
mode === "login"
|
|
68
|
+
? "tab-active bg-primary text-primary-content!"
|
|
69
|
+
: ""
|
|
70
|
+
}`}
|
|
71
|
+
>
|
|
72
|
+
Sign In
|
|
73
|
+
</button>
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
onClick={() => setMode("signup")}
|
|
77
|
+
className={`tab flex-1 rounded-xl text-sm font-bold transition-all ${
|
|
78
|
+
mode === "signup"
|
|
79
|
+
? "tab-active bg-primary text-primary-content!"
|
|
80
|
+
: ""
|
|
81
|
+
}`}
|
|
82
|
+
>
|
|
83
|
+
Sign Up
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
{/* Error */}
|
|
88
|
+
{error && (
|
|
89
|
+
<div className="alert alert-error alert-soft rounded-2xl text-xs mb-4 p-3 border border-error/20">
|
|
90
|
+
⚠️ {error}
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
|
|
94
|
+
{/* Form */}
|
|
95
|
+
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
96
|
+
{/* Name — signup only */}
|
|
97
|
+
{mode === "signup" && (
|
|
98
|
+
<label className="input input-bordered rounded-2xl flex items-center gap-2 bg-base-100 border-base-300 focus-within:border-primary transition-colors">
|
|
99
|
+
<User size={16} className="text-base-content/40 shrink-0" />
|
|
100
|
+
<input
|
|
101
|
+
name="name"
|
|
102
|
+
type="text"
|
|
103
|
+
placeholder="Full name"
|
|
104
|
+
value={form.name}
|
|
105
|
+
onChange={handleChange}
|
|
106
|
+
required
|
|
107
|
+
className="grow text-sm bg-transparent outline-none placeholder:text-base-content/30"
|
|
108
|
+
/>
|
|
109
|
+
</label>
|
|
110
|
+
)}
|
|
111
|
+
|
|
112
|
+
{/* Email */}
|
|
113
|
+
<label className="input input-bordered rounded-2xl flex items-center gap-2 bg-base-100 border-base-300 focus-within:border-primary transition-colors">
|
|
114
|
+
<Mail size={16} className="text-base-content/40 shrink-0" />
|
|
115
|
+
<input
|
|
116
|
+
name="email"
|
|
117
|
+
type="email"
|
|
118
|
+
placeholder="Email address"
|
|
119
|
+
value={form.email}
|
|
120
|
+
onChange={handleChange}
|
|
121
|
+
required
|
|
122
|
+
className="grow text-sm bg-transparent outline-none placeholder:text-base-content/30"
|
|
123
|
+
/>
|
|
124
|
+
</label>
|
|
125
|
+
|
|
126
|
+
{/* Password */}
|
|
127
|
+
<label className="input input-bordered rounded-2xl flex items-center gap-2 bg-base-100 border-base-300 focus-within:border-primary transition-colors">
|
|
128
|
+
<Lock size={16} className="text-base-content/40 shrink-0" />
|
|
129
|
+
<input
|
|
130
|
+
name="password"
|
|
131
|
+
type={showPassword ? "text" : "password"}
|
|
132
|
+
placeholder="Password"
|
|
133
|
+
value={form.password}
|
|
134
|
+
onChange={handleChange}
|
|
135
|
+
required
|
|
136
|
+
minLength={6}
|
|
137
|
+
className="grow text-sm bg-transparent outline-none placeholder:text-base-content/30"
|
|
138
|
+
/>
|
|
139
|
+
<button
|
|
140
|
+
type="button"
|
|
141
|
+
onClick={() => setShowPassword((p) => !p)}
|
|
142
|
+
className="text-base-content/40 hover:text-base-content transition-colors"
|
|
143
|
+
>
|
|
144
|
+
{showPassword ? <EyeOff size={16} /> : <Eye size={16} />}
|
|
145
|
+
</button>
|
|
146
|
+
</label>
|
|
147
|
+
|
|
148
|
+
{/* Submit */}
|
|
149
|
+
<button
|
|
150
|
+
type="submit"
|
|
151
|
+
disabled={loading}
|
|
152
|
+
className="btn btn-primary rounded-2xl font-bold mt-2 w-full shadow-lg hover:scale-[1.01] active:scale-[0.99] transition-transform"
|
|
153
|
+
>
|
|
154
|
+
{loading ? (
|
|
155
|
+
<span className="loading loading-spinner loading-sm" />
|
|
156
|
+
) : mode === "login" ? (
|
|
157
|
+
"Sign In →"
|
|
158
|
+
) : (
|
|
159
|
+
"Create Account →"
|
|
160
|
+
)}
|
|
161
|
+
</button>
|
|
162
|
+
</form>
|
|
163
|
+
|
|
164
|
+
{/* Footer note */}
|
|
165
|
+
<p className="text-center text-xs text-base-content/40 mt-6">
|
|
166
|
+
{mode === "login" ? (
|
|
167
|
+
<>
|
|
168
|
+
New here?{" "}
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
onClick={() => setMode("signup")}
|
|
172
|
+
className="text-primary font-bold hover:underline"
|
|
173
|
+
>
|
|
174
|
+
Create an account
|
|
175
|
+
</button>
|
|
176
|
+
</>
|
|
177
|
+
) : (
|
|
178
|
+
<>
|
|
179
|
+
Already have an account?{" "}
|
|
180
|
+
<button
|
|
181
|
+
type="button"
|
|
182
|
+
onClick={() => setMode("login")}
|
|
183
|
+
className="text-primary font-bold hover:underline"
|
|
184
|
+
>
|
|
185
|
+
Sign in
|
|
186
|
+
</button>
|
|
187
|
+
</>
|
|
188
|
+
)}
|
|
189
|
+
</p>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export default Login;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { api } from "../config/api";
|
|
2
|
+
|
|
3
|
+
export const authService = {
|
|
4
|
+
signup: (name, email, password, role = "user") =>
|
|
5
|
+
api.post("/auth/signup", { name, email, password, role }),
|
|
6
|
+
|
|
7
|
+
login: (email, password) =>
|
|
8
|
+
api.post("/auth/login", { email, password }),
|
|
9
|
+
|
|
10
|
+
getMe: () => api.get("/auth/me"),
|
|
11
|
+
|
|
12
|
+
updateMe: (data) => api.put("/auth/me", data),
|
|
13
|
+
|
|
14
|
+
logout: () =>
|
|
15
|
+
api.post("/auth/logout"),
|
|
16
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { authService } from "../services/authService";
|
|
3
|
+
|
|
4
|
+
export const useAuthStore = create((set, get) => ({
|
|
5
|
+
user: null,
|
|
6
|
+
loading: true,
|
|
7
|
+
error: null,
|
|
8
|
+
|
|
9
|
+
signup: async (name, email, password, role = "user") => {
|
|
10
|
+
set({ loading: true, error: null });
|
|
11
|
+
try {
|
|
12
|
+
const { data } = await authService.signup(name, email, password, role);
|
|
13
|
+
if (data.token) {
|
|
14
|
+
localStorage.setItem("token", data.token);
|
|
15
|
+
}
|
|
16
|
+
set({
|
|
17
|
+
user: data,
|
|
18
|
+
loading: false,
|
|
19
|
+
});
|
|
20
|
+
return true;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
set({
|
|
23
|
+
error: err.response?.data?.message || err.message,
|
|
24
|
+
loading: false,
|
|
25
|
+
});
|
|
26
|
+
return false;
|
|
27
|
+
} finally {
|
|
28
|
+
set({ loading: false });
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
login: async (email, password) => {
|
|
33
|
+
set({ loading: true, error: null });
|
|
34
|
+
try {
|
|
35
|
+
const { data } = await authService.login(email, password);
|
|
36
|
+
if (data.token) {
|
|
37
|
+
localStorage.setItem("token", data.token);
|
|
38
|
+
}
|
|
39
|
+
set({
|
|
40
|
+
user: data,
|
|
41
|
+
loading: false,
|
|
42
|
+
});
|
|
43
|
+
return true;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
set({
|
|
46
|
+
error: err.response?.data?.message || err.message,
|
|
47
|
+
loading: false,
|
|
48
|
+
});
|
|
49
|
+
return false;
|
|
50
|
+
} finally {
|
|
51
|
+
set({ loading: false });
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
getMe: async () => {
|
|
56
|
+
set({ loading: true });
|
|
57
|
+
try {
|
|
58
|
+
const { data } = await authService.getMe();
|
|
59
|
+
set({ user: data, loading: false });
|
|
60
|
+
} catch (err) {
|
|
61
|
+
set({ loading: false });
|
|
62
|
+
} finally {
|
|
63
|
+
set({ loading: false });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
updateProfile: async (updates) => {
|
|
68
|
+
set({ loading: true, error: null });
|
|
69
|
+
try {
|
|
70
|
+
const { data } = await authService.updateMe(updates);
|
|
71
|
+
set({ user: data, loading: false });
|
|
72
|
+
return true;
|
|
73
|
+
} catch (err) {
|
|
74
|
+
set({
|
|
75
|
+
error: err.response?.data?.message || err.message,
|
|
76
|
+
loading: false,
|
|
77
|
+
});
|
|
78
|
+
return false;
|
|
79
|
+
} finally {
|
|
80
|
+
set({ loading: false });
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
logout: async () => {
|
|
85
|
+
try {
|
|
86
|
+
await authService.logout();
|
|
87
|
+
} catch (_) {
|
|
88
|
+
// ignore errors — cookie may already be expired
|
|
89
|
+
} finally {
|
|
90
|
+
localStorage.removeItem("token");
|
|
91
|
+
set({ loading: false });
|
|
92
|
+
}
|
|
93
|
+
set({
|
|
94
|
+
user: null,
|
|
95
|
+
error: null,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
}));
|