create-fe-boilerplate 0.3.2 → 0.4.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.
Files changed (109) hide show
  1. package/package.json +1 -1
  2. package/templates/react/js/scss/axios/README.md +73 -0
  3. package/templates/react/js/scss/axios/eslint.config.js +23 -0
  4. package/templates/react/js/scss/axios/index.html +13 -0
  5. package/templates/react/js/scss/axios/package-lock.json +4517 -0
  6. package/templates/react/js/scss/axios/package.json +35 -0
  7. package/templates/react/js/scss/axios/public/vite.svg +1 -0
  8. package/templates/react/js/scss/axios/react-ts-tailwind-axios/.env.example +1 -0
  9. package/templates/react/js/scss/axios/src/App.css +0 -0
  10. package/templates/react/js/scss/axios/src/App.jsx +14 -0
  11. package/templates/react/js/scss/axios/src/api/axios.js +201 -0
  12. package/templates/react/js/scss/axios/src/component/auth/VerifyOtpModal.jsx +60 -0
  13. package/templates/react/js/scss/axios/src/component/common/ui/Toast/Toast.js +58 -0
  14. package/templates/react/js/scss/axios/src/contants/constants.js +45 -0
  15. package/templates/react/js/scss/axios/src/index.css +4 -0
  16. package/templates/react/js/scss/axios/src/main.jsx +12 -0
  17. package/templates/react/js/scss/axios/src/pages/Auth.scss +203 -0
  18. package/templates/react/js/scss/axios/src/pages/Dashboard.jsx +10 -0
  19. package/templates/react/js/scss/axios/src/pages/Login.jsx +69 -0
  20. package/templates/react/js/scss/axios/src/pages/Signup.jsx +74 -0
  21. package/templates/react/js/scss/axios/src/router/AppRoutes.jsx +19 -0
  22. package/templates/react/js/scss/axios/src/styles/global.scss +5 -0
  23. package/templates/react/js/scss/axios/src/utils/utils.js +58 -0
  24. package/templates/react/js/scss/axios/tsconfig.app.json +28 -0
  25. package/templates/react/js/scss/axios/vite.config.js +7 -0
  26. package/templates/react/js/scss/rtk/README.md +73 -0
  27. package/templates/react/js/scss/rtk/eslint.config.js +23 -0
  28. package/templates/react/js/scss/rtk/index.html +13 -0
  29. package/templates/react/js/scss/rtk/package-lock.json +4208 -0
  30. package/templates/react/js/scss/rtk/package.json +35 -0
  31. package/templates/react/js/scss/rtk/public/vite.svg +1 -0
  32. package/templates/react/js/scss/rtk/react-ts-tailwind-axios/.env.example +1 -0
  33. package/templates/react/js/scss/rtk/src/App.css +0 -0
  34. package/templates/react/js/scss/rtk/src/App.jsx +14 -0
  35. package/templates/react/js/scss/rtk/src/api/axios.js +201 -0
  36. package/templates/react/js/scss/rtk/src/component/auth/VerifyOtpModal.jsx +61 -0
  37. package/templates/react/js/scss/rtk/src/component/auth/VerifyOtpModal.scss +62 -0
  38. package/templates/react/js/scss/rtk/src/component/common/ui/Toast/Toast.js +58 -0
  39. package/templates/react/js/scss/rtk/src/contants/constants.js +45 -0
  40. package/templates/react/js/scss/rtk/src/main.jsx +16 -0
  41. package/templates/react/js/scss/rtk/src/pages/Dashboard.jsx +12 -0
  42. package/templates/react/js/scss/rtk/src/pages/Dashboard.scss +13 -0
  43. package/templates/react/js/scss/rtk/src/pages/Login.jsx +75 -0
  44. package/templates/react/js/scss/rtk/src/pages/Login.scss +67 -0
  45. package/templates/react/js/scss/rtk/src/pages/Signup.jsx +73 -0
  46. package/templates/react/js/scss/rtk/src/pages/Signup.scss +66 -0
  47. package/templates/react/js/scss/rtk/src/router/AppRoutes.jsx +19 -0
  48. package/templates/react/js/scss/rtk/src/store/index.js +10 -0
  49. package/templates/react/js/scss/rtk/src/store/services/api.js +34 -0
  50. package/templates/react/js/scss/rtk/src/styles/global.scss +10 -0
  51. package/templates/react/js/scss/rtk/src/utils/utils.js +59 -0
  52. package/templates/react/js/scss/rtk/tsconfig.app.json +28 -0
  53. package/templates/react/js/scss/rtk/vite.config.js +7 -0
  54. package/templates/react/ts/scss/axios/README.md +73 -0
  55. package/templates/react/ts/scss/axios/eslint.config.js +23 -0
  56. package/templates/react/ts/scss/axios/index.html +13 -0
  57. package/templates/react/ts/scss/axios/package-lock.json +4868 -0
  58. package/templates/react/ts/scss/axios/package.json +39 -0
  59. package/templates/react/ts/scss/axios/public/vite.svg +1 -0
  60. package/templates/react/ts/scss/axios/react-ts-tailwind-axios/.env.example +1 -0
  61. package/templates/react/ts/scss/axios/src/App.css +0 -0
  62. package/templates/react/ts/scss/axios/src/App.tsx +14 -0
  63. package/templates/react/ts/scss/axios/src/api/axios.ts +236 -0
  64. package/templates/react/ts/scss/axios/src/component/auth/VerifyOtpModal.tsx +70 -0
  65. package/templates/react/ts/scss/axios/src/component/common/ui/Toast/Toast.ts +58 -0
  66. package/templates/react/ts/scss/axios/src/contants/constants.ts +45 -0
  67. package/templates/react/ts/scss/axios/src/index.css +4 -0
  68. package/templates/react/ts/scss/axios/src/main.tsx +10 -0
  69. package/templates/react/ts/scss/axios/src/pages/Auth.scss +203 -0
  70. package/templates/react/ts/scss/axios/src/pages/Dashboard.tsx +10 -0
  71. package/templates/react/ts/scss/axios/src/pages/Login.tsx +69 -0
  72. package/templates/react/ts/scss/axios/src/pages/Signup.tsx +74 -0
  73. package/templates/react/ts/scss/axios/src/router/AppRoutes.tsx +19 -0
  74. package/templates/react/ts/scss/axios/src/styles/global.scss +5 -0
  75. package/templates/react/ts/scss/axios/src/utils/utils.ts +59 -0
  76. package/templates/react/ts/scss/axios/tsconfig.app.json +28 -0
  77. package/templates/react/ts/scss/axios/tsconfig.json +12 -0
  78. package/templates/react/ts/scss/axios/tsconfig.node.json +26 -0
  79. package/templates/react/ts/scss/axios/vite.config.ts +7 -0
  80. package/templates/react/ts/scss/rtk/README.md +73 -0
  81. package/templates/react/ts/scss/rtk/eslint.config.js +23 -0
  82. package/templates/react/ts/scss/rtk/index.html +13 -0
  83. package/templates/react/ts/scss/rtk/package-lock.json +4218 -0
  84. package/templates/react/ts/scss/rtk/package.json +38 -0
  85. package/templates/react/ts/scss/rtk/public/vite.svg +1 -0
  86. package/templates/react/ts/scss/rtk/react-ts-tailwind-axios/.env.example +1 -0
  87. package/templates/react/ts/scss/rtk/src/App.css +0 -0
  88. package/templates/react/ts/scss/rtk/src/App.tsx +14 -0
  89. package/templates/react/ts/scss/rtk/src/api/axios.ts +236 -0
  90. package/templates/react/ts/scss/rtk/src/component/auth/VerifyOtpModal.scss +62 -0
  91. package/templates/react/ts/scss/rtk/src/component/auth/VerifyOtpModal.tsx +71 -0
  92. package/templates/react/ts/scss/rtk/src/component/common/ui/Toast/Toast.ts +58 -0
  93. package/templates/react/ts/scss/rtk/src/contants/constants.ts +45 -0
  94. package/templates/react/ts/scss/rtk/src/main.tsx +14 -0
  95. package/templates/react/ts/scss/rtk/src/pages/Dashboard.scss +13 -0
  96. package/templates/react/ts/scss/rtk/src/pages/Dashboard.tsx +12 -0
  97. package/templates/react/ts/scss/rtk/src/pages/Login.scss +67 -0
  98. package/templates/react/ts/scss/rtk/src/pages/Login.tsx +75 -0
  99. package/templates/react/ts/scss/rtk/src/pages/Signup.scss +66 -0
  100. package/templates/react/ts/scss/rtk/src/pages/Signup.tsx +73 -0
  101. package/templates/react/ts/scss/rtk/src/router/AppRoutes.tsx +19 -0
  102. package/templates/react/ts/scss/rtk/src/store/index.ts +13 -0
  103. package/templates/react/ts/scss/rtk/src/store/services/api.ts +37 -0
  104. package/templates/react/ts/scss/rtk/src/styles/global.scss +10 -0
  105. package/templates/react/ts/scss/rtk/src/utils/utils.ts +59 -0
  106. package/templates/react/ts/scss/rtk/tsconfig.app.json +28 -0
  107. package/templates/react/ts/scss/rtk/tsconfig.json +12 -0
  108. package/templates/react/ts/scss/rtk/tsconfig.node.json +26 -0
  109. package/templates/react/ts/scss/rtk/vite.config.ts +7 -0
@@ -0,0 +1,75 @@
1
+ import { useState } from "react";
2
+ import { Link, useNavigate } from "react-router-dom";
3
+ import VerifyOtpModal from "../component/auth/VerifyOtpModal";
4
+ import { useLoginMutation } from "../store/services/api";
5
+ import "./Login.scss";
6
+
7
+ const Login = () => {
8
+ const navigate = useNavigate();
9
+ const [login, { isLoading }] = useLoginMutation();
10
+
11
+ const [showOtp, setShowOtp] = useState(false);
12
+
13
+ const [form, setForm] = useState({
14
+ email: "",
15
+ password: "",
16
+ });
17
+
18
+ const handleLogin = async () => {
19
+ // await login({
20
+ // email: "test@test.com",
21
+ // password: "123456",
22
+ // });
23
+ setShowOtp(true);
24
+ };
25
+
26
+ const handleOtpSuccess = () => {
27
+ localStorage.setItem("token", "dummy-token");
28
+ navigate("/dashboard");
29
+ };
30
+
31
+ return (
32
+ <div className="login-container">
33
+ <div className="auth-card">
34
+ <h2 className="auth-title">Login</h2>
35
+
36
+ <input
37
+ className="auth-input"
38
+ placeholder="Email"
39
+ value={form.email}
40
+ onChange={(e) => setForm({ ...form, email: e.target.value })}
41
+ />
42
+
43
+ <input
44
+ type="password"
45
+ className="auth-input password-input"
46
+ placeholder="Password"
47
+ value={form.password}
48
+ onChange={(e) => setForm({ ...form, password: e.target.value })}
49
+ />
50
+
51
+ <button
52
+ className="auth-button"
53
+ onClick={handleLogin}
54
+ disabled={isLoading}
55
+ >
56
+ {isLoading ? "Loading..." : "Login"}
57
+ </button>
58
+ <span className="auth-footer">
59
+ Dont have an account?{" "}
60
+ <Link to="/signup" className="auth-link">
61
+ Signup
62
+ </Link>
63
+ </span>
64
+ </div>
65
+
66
+ <VerifyOtpModal
67
+ isOpen={showOtp}
68
+ onClose={() => setShowOtp(false)}
69
+ onVerifySuccess={handleOtpSuccess}
70
+ />
71
+ </div>
72
+ );
73
+ };
74
+
75
+ export default Login;
@@ -0,0 +1,66 @@
1
+ .signup-container {
2
+ min-height: 100vh;
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ background-color: #f3f4f6;
7
+
8
+ .auth-card {
9
+ width: 24rem; // w-96
10
+ padding: 1.5rem; // p-6
11
+ background-color: #ffffff;
12
+ border-radius: 0.375rem; // rounded
13
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); // shadow
14
+
15
+ .auth-title {
16
+ font-size: 1.25rem; // text-xl
17
+ font-weight: 700; // font-bold
18
+ margin-bottom: 1rem; // mb-4
19
+ }
20
+
21
+ .auth-input {
22
+ width: 100%;
23
+ padding: 0.5rem; // p-2
24
+ margin-bottom: 0.5rem; // mb-2
25
+ border: 1px solid #d1d5db; // border
26
+ border-radius: 0.25rem; // rounded
27
+
28
+ &.password-input {
29
+ margin-bottom: 1rem; // mb-4
30
+ }
31
+ }
32
+
33
+ .auth-button {
34
+ width: 100%;
35
+ background-color: #059669; // green-600
36
+ color: #ffffff;
37
+ padding: 0.5rem 0;
38
+ border-radius: 0.25rem;
39
+ border: none;
40
+ cursor: pointer;
41
+ font-weight: 600;
42
+
43
+ &:hover {
44
+ background-color: #047857;
45
+ }
46
+ }
47
+
48
+ .auth-footer {
49
+ display: block;
50
+ text-align: center;
51
+ margin-top: 0.5rem; // mt-2
52
+ font-size: 0.875rem; // text-sm
53
+ color: #4b5563; // text-gray-600
54
+
55
+ .auth-link {
56
+ color: #2563eb; // text-blue-600
57
+ text-decoration: none;
58
+ cursor: pointer;
59
+
60
+ &:hover {
61
+ text-decoration: underline;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,73 @@
1
+ import { useState } from "react";
2
+ import { Link, useNavigate } from "react-router-dom";
3
+ import VerifyOtpModal from "../component/auth/VerifyOtpModal";
4
+ import "./Signup.scss";
5
+
6
+ const Signup = () => {
7
+ const navigate = useNavigate();
8
+ const [showOtp, setShowOtp] = useState(false);
9
+
10
+ const [form, setForm] = useState({
11
+ email: "",
12
+ password: "",
13
+ });
14
+
15
+ const handleSignup = async () => {
16
+ // const res = await apiCallPost(
17
+ // "/auth/signup",
18
+ // form,
19
+ // {},
20
+ // true
21
+ // );
22
+
23
+ // if (res?.success) {
24
+ // setRefId(res?.data?.refId || "");
25
+ setShowOtp(true);
26
+ // }
27
+ };
28
+
29
+ const handleOtpSuccess = () => {
30
+ navigate("/login");
31
+ };
32
+
33
+ return (
34
+ <div className="signup-container">
35
+ <div className="auth-card">
36
+ <h2 className="auth-title">Signup</h2>
37
+
38
+ <input
39
+ className="auth-input"
40
+ placeholder="Email"
41
+ value={form.email}
42
+ onChange={(e) => setForm({ ...form, email: e.target.value })}
43
+ />
44
+
45
+ <input
46
+ type="password"
47
+ className="auth-input password-input"
48
+ placeholder="Password"
49
+ value={form.password}
50
+ onChange={(e) => setForm({ ...form, password: e.target.value })}
51
+ />
52
+
53
+ <button onClick={handleSignup} className="auth-button">
54
+ Create Account
55
+ </button>
56
+ <span className="auth-footer">
57
+ Already have an account?{" "}
58
+ <Link to="/login" className="auth-link">
59
+ Login
60
+ </Link>
61
+ </span>
62
+ </div>
63
+
64
+ <VerifyOtpModal
65
+ isOpen={showOtp}
66
+ onClose={() => setShowOtp(false)}
67
+ onVerifySuccess={handleOtpSuccess}
68
+ />
69
+ </div>
70
+ );
71
+ };
72
+
73
+ export default Signup;
@@ -0,0 +1,19 @@
1
+ import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
2
+ import Login from "../pages/Login";
3
+ import Signup from "../pages/Signup";
4
+ import Dashboard from "../pages/Dashboard";
5
+
6
+ const AppRouter = () => {
7
+ return (
8
+ <BrowserRouter>
9
+ <Routes>
10
+ <Route path="/" element={<Navigate to="/login" />} />
11
+ <Route path="/login" element={<Login />} />
12
+ <Route path="/signup" element={<Signup />} />
13
+ <Route path="/dashboard" element={<Dashboard />} />
14
+ </Routes>
15
+ </BrowserRouter>
16
+ );
17
+ };
18
+
19
+ export default AppRouter;
@@ -0,0 +1,13 @@
1
+ import { configureStore } from "@reduxjs/toolkit";
2
+ import { api } from "./services/api";
3
+
4
+ export const store = configureStore({
5
+ reducer: {
6
+ [api.reducerPath]: api.reducer
7
+ },
8
+ middleware: (getDefaultMiddleware) =>
9
+ getDefaultMiddleware().concat(api.middleware)
10
+ });
11
+
12
+ export type RootState = ReturnType<typeof store.getState>;
13
+ export type AppDispatch = typeof store.dispatch;
@@ -0,0 +1,37 @@
1
+ import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
2
+
3
+ export const api = createApi({
4
+ reducerPath: "api",
5
+ baseQuery: fetchBaseQuery({
6
+ baseUrl: import.meta.env.VITE_API_HOST
7
+ }),
8
+ endpoints: (builder) => ({
9
+ login: builder.mutation({
10
+ query: (body) => ({
11
+ url: "/auth/login",
12
+ method: "POST",
13
+ body
14
+ })
15
+ }),
16
+ signup: builder.mutation({
17
+ query: (body) => ({
18
+ url: "/auth/signup",
19
+ method: "POST",
20
+ body
21
+ })
22
+ }),
23
+ verifyOtp: builder.mutation({
24
+ query: (body) => ({
25
+ url: "/auth/verify-otp",
26
+ method: "POST",
27
+ body
28
+ })
29
+ })
30
+ })
31
+ });
32
+
33
+ export const {
34
+ useLoginMutation,
35
+ useSignupMutation,
36
+ useVerifyOtpMutation
37
+ } = api;
@@ -0,0 +1,10 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ body {
6
+ margin: 0;
7
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
8
+ background: #f4f6f8;
9
+ color: #222;
10
+ }
@@ -0,0 +1,59 @@
1
+ import * as CryptoJS from "crypto-js";
2
+ import ENVIRONMENT from "../contants/constants";
3
+
4
+ /**
5
+ * Function to get prime numbers in range (start, end)
6
+ */
7
+ function getPrimeNumbersInRange(start: number, end: number): number[] {
8
+ const isPrime = (num: number) => {
9
+ for (let i = 2, s = Math.sqrt(num); i <= s; i++) {
10
+ if (num % i === 0) return false;
11
+ }
12
+ return num > 1;
13
+ };
14
+
15
+ const primes = [];
16
+ for (let i = start; i <= end; i++) {
17
+ if (isPrime(i)) primes.push(i);
18
+ }
19
+ return primes;
20
+ }
21
+
22
+ export function getKey(value: number): string {
23
+ const key = ENVIRONMENT.STRING || "asdfasdfasd";
24
+
25
+ // Function to get prime numbers in range (1, value)
26
+ const primeNumbers = getPrimeNumbersInRange(1, value);
27
+
28
+ // Get the string according to the prime numbers
29
+ const resultString = primeNumbers
30
+ .map((num) => key[num % key.length])
31
+ .join("");
32
+
33
+ return resultString;
34
+ }
35
+
36
+ const key = getKey(50);
37
+
38
+ const encryptData = (data: any) => {
39
+ if (data) {
40
+ const stringData = JSON.stringify(data);
41
+ const encrypted = CryptoJS.AES.encrypt(stringData, key).toString();
42
+ return encrypted;
43
+ }
44
+ };
45
+
46
+ const decryptData = (data: any) => {
47
+ if (data) {
48
+ const decrypted = CryptoJS.AES.decrypt(data, key);
49
+ const stringData = decrypted.toString(CryptoJS.enc.Utf8);
50
+ try {
51
+ return JSON.parse(stringData);
52
+ } catch (e) {
53
+ console.error("Failed to parse decrypted data", e);
54
+ return null;
55
+ }
56
+ }
57
+ };
58
+
59
+ export { encryptData, decryptData };
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "types": ["vite/client"],
9
+ "skipLibCheck": true,
10
+
11
+ /* Bundler mode */
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "moduleDetection": "force",
16
+ "noEmit": true,
17
+ "jsx": "react-jsx",
18
+
19
+ /* Linting */
20
+ "strict": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "erasableSyntaxOnly": true,
24
+ "noFallthroughCasesInSwitch": true,
25
+ "noUncheckedSideEffectImports": true
26
+ },
27
+ "include": ["src"]
28
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ],
7
+ "compilerOptions": {
8
+ "strict": true,
9
+ "moduleResolution": "bundler",
10
+ "types": ["vite/client"]
11
+ }
12
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "types": ["node"],
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "erasableSyntaxOnly": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noUncheckedSideEffectImports": true
24
+ },
25
+ "include": ["vite.config.ts"]
26
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ })