From 88b5bb79bc1d758a27dfd94c037f0b81d2e7e196 Mon Sep 17 00:00:00 2001 From: Deepak Pradhan <37866666+varun2948@users.noreply.github.com> Date: Tue, 28 May 2024 11:21:02 +0545 Subject: [PATCH] Initial commit --- .env.example | 3 + .eslintignore | 8 + .eslintrc.cjs | 54 + .github/pull_request_template.md | 39 + .github/workflows/build_and_deploy.yml | 137 + .gitignore | 28 + .husky/.lintstagedrc | 3 + .husky/commit-msg | 15 + .husky/pre-commit | 21 + .lintstagedrc | 3 + .nvmrc | 1 + .prettierrc.cjs | 9 + README.md | 41 + components.json | 16 + index.html | 28 + package.json | 95 + postcss.config.js | 7 + public/favicon-16x16.png | Bin 0 -> 421 bytes public/favicon-32x32.png | Bin 0 -> 871 bytes public/favicon.ico | Bin 0 -> 15406 bytes scripts/setup-user-module.sh | 30 + src/App.tsx | 98 + src/assets/css/index.css | 18 + src/assets/css/tailwind.css | 134 + src/assets/fonts/ProductSans-Bold.ttf | Bin 0 -> 92096 bytes src/assets/fonts/ProductSans-Regular.ttf | Bin 0 -> 109128 bytes src/assets/images/avatar-images.svg | 10 + src/components/RadixComponents/Button.tsx | 109 + src/components/RadixComponents/Image.tsx | 26 + src/components/RadixComponents/Popover.tsx | 52 + src/components/RadixComponents/Skeleton.tsx | 16 + src/components/RadixComponents/Table.tsx | 125 + src/components/RadixComponents/ToolTip.tsx | 62 + .../common/Charts/BarChart/index.tsx | 137 + .../common/Charts/CaptureComponent/index.tsx | 29 + .../common/Charts/ChartContainer/index.tsx | 110 + .../common/Charts/ChartHeader/index.tsx | 91 + .../common/Charts/ChartLegend/index.tsx | 52 + .../common/Charts/DonutChart/index.tsx | 56 + .../common/Charts/DonutLegendItem/index.tsx | 28 + .../Charts/HorizontalBarChart/index.tsx | 23 + .../Charts/HorizontalBarLabel/index.tsx | 31 + .../common/Charts/LegendItem/index.tsx | 18 + .../common/Charts/NoDataComponent/index.tsx | 13 + .../common/Charts/ScatterChart/index.tsx | 66 + .../common/Charts/StackedChart/index.tsx | 139 + .../common/Charts/constants/index.ts | 33 + src/components/common/Charts/types/index.tsx | 38 + .../Charts/utils/getChartFillOfType.tsx | 20 + .../common/Charts/utils/getChartOfType.tsx | 20 + src/components/common/Charts/utils/index.ts | 232 + src/components/common/Chip/index.tsx | 24 + src/components/common/DataCard/index.tsx | 39 + .../DataTable/DataTablePagination/index.tsx | 80 + .../common/DataTable/TableSkeleton/index.tsx | 33 + src/components/common/DataTable/index.tsx | 193 + src/components/common/ErrorBoundary/index.tsx | 67 + src/components/common/ErrorMessage/index.tsx | 25 + src/components/common/Fallback/index.tsx | 3 + .../common/FormUI/ErrorMessage/index.tsx | 14 + .../common/FormUI/FileUpload/index.tsx | 169 + .../common/FormUI/FormControl/index.tsx | 14 + .../common/FormUI/FormGroup/index.tsx | 9 + src/components/common/FormUI/Input/index.tsx | 29 + src/components/common/FormUI/Label/index.tsx | 19 + .../common/FormUI/MultiSelect/index.tsx | 167 + .../common/FormUI/SearchInput/index.tsx | 48 + src/components/common/FormUI/Select/index.tsx | 187 + src/components/common/FormUI/index.ts | 8 + src/components/common/Icon/index.tsx | 25 + src/components/common/InfoDialog/index.tsx | 36 + src/components/common/Layouts/Flex/index.tsx | 30 + .../common/Layouts/FlexColumn/index.tsx | 22 + .../common/Layouts/FlexRow/index.tsx | 25 + src/components/common/Layouts/Grid/index.tsx | 28 + src/components/common/Layouts/index.tsx | 6 + src/components/common/Layouts/types.ts | 19 + .../MapLibreComponents/AsyncPopup/index.tsx | 99 + .../BaseLayerSwitcher/baseLayers.tsx | 103 + .../BaseLayerSwitcher/index.tsx | 47 + .../MapLibreComponents/Layers/SymbolLayer.ts | 45 + .../MapLibreComponents/Layers/VectorLayer.ts | 50 + .../Layers/VectorTileLayer.ts | 82 + .../MapLibreComponents/MapContainer/index.tsx | 39 + .../MapLibreComponents/PopupUI/index.tsx | 56 + .../helpers/changeLayerOrder.ts | 21 + .../common/MapLibreComponents/index.ts | 2 + .../common/MapLibreComponents/map.css | 12 + .../common/MapLibreComponents/types/index.ts | 74 + .../MapLibreComponents/useDrawTool/index.ts | 137 + .../useMapLibreGLMap/index.ts | 61 + src/components/common/Modal/index.tsx | 111 + src/components/common/PromptDialog/index.tsx | 22 + .../common/RoundedContainer/index.tsx | 23 + src/components/common/Spinner/index.tsx | 27 + src/constants/index.ts | 1 + src/constants/map.ts | 323 + src/constants/modalContents.tsx | 43 + src/hooks/useAuth.ts | 7 + src/hooks/useCustomUpload.ts | 23 + src/hooks/useOutsideClick.ts | 50 + src/hooks/useRouteParamQuery.ts | 10 + src/hooks/useScrollActiveListener.ts | 44 + src/main.tsx | 33 + src/react-app-env.d.ts | 6 + src/routes/ProtectedRoute.tsx | 18 + src/routes/appRoutes.ts | 13 + src/routes/generateRoutes.tsx | 70 + src/routes/testRoutes.ts | 12 + src/routes/types.ts | 10 + src/services/common.ts | 5 + src/services/index.ts | 28 + src/store/actions/common.ts | 9 + src/store/actions/loader.ts | 3 + src/store/hooks/index.ts | 6 + src/store/index.ts | 25 + src/store/persist.ts | 19 + src/store/reducers/index.ts | 23 + src/store/sagas/index.ts | 5 + src/store/selector/common.ts | 1 + src/store/slices/common.ts | 79 + src/store/slices/loader.ts | 27 + src/utils/capitalizeFirstLetter.ts | 6 + src/utils/checkIfLoading.ts | 8 + src/utils/formatNumberWithCommas.ts | 3 + src/utils/hasErrorBoundary.tsx | 26 + src/utils/index.ts | 7 + src/utils/isEmpty.ts | 14 + src/utils/prepareFormData.ts | 21 + src/utils/prepareQueryParam.ts | 9 + src/utils/removeObjectKeys.ts | 10 + src/utils/sagaUtils.ts | 139 + src/views/Dashboard/index.tsx | 3 + tailwind.config.js | 259 + tsconfig.json | 49 + tsconfig.node.json | 9 + vite.config.ts | 52 + yarn.lock | 5883 +++++++++++++++++ 138 files changed, 12045 insertions(+) create mode 100644 .env.example create mode 100644 .eslintignore create mode 100644 .eslintrc.cjs create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/build_and_deploy.yml create mode 100644 .gitignore create mode 100644 .husky/.lintstagedrc create mode 100755 .husky/commit-msg create mode 100755 .husky/pre-commit create mode 100644 .lintstagedrc create mode 100644 .nvmrc create mode 100644 .prettierrc.cjs create mode 100644 README.md create mode 100644 components.json create mode 100644 index.html create mode 100644 package.json create mode 100644 postcss.config.js create mode 100644 public/favicon-16x16.png create mode 100644 public/favicon-32x32.png create mode 100644 public/favicon.ico create mode 100755 scripts/setup-user-module.sh create mode 100644 src/App.tsx create mode 100644 src/assets/css/index.css create mode 100644 src/assets/css/tailwind.css create mode 100644 src/assets/fonts/ProductSans-Bold.ttf create mode 100644 src/assets/fonts/ProductSans-Regular.ttf create mode 100644 src/assets/images/avatar-images.svg create mode 100644 src/components/RadixComponents/Button.tsx create mode 100644 src/components/RadixComponents/Image.tsx create mode 100644 src/components/RadixComponents/Popover.tsx create mode 100644 src/components/RadixComponents/Skeleton.tsx create mode 100644 src/components/RadixComponents/Table.tsx create mode 100644 src/components/RadixComponents/ToolTip.tsx create mode 100644 src/components/common/Charts/BarChart/index.tsx create mode 100644 src/components/common/Charts/CaptureComponent/index.tsx create mode 100644 src/components/common/Charts/ChartContainer/index.tsx create mode 100644 src/components/common/Charts/ChartHeader/index.tsx create mode 100644 src/components/common/Charts/ChartLegend/index.tsx create mode 100644 src/components/common/Charts/DonutChart/index.tsx create mode 100644 src/components/common/Charts/DonutLegendItem/index.tsx create mode 100644 src/components/common/Charts/HorizontalBarChart/index.tsx create mode 100644 src/components/common/Charts/HorizontalBarLabel/index.tsx create mode 100644 src/components/common/Charts/LegendItem/index.tsx create mode 100644 src/components/common/Charts/NoDataComponent/index.tsx create mode 100644 src/components/common/Charts/ScatterChart/index.tsx create mode 100644 src/components/common/Charts/StackedChart/index.tsx create mode 100644 src/components/common/Charts/constants/index.ts create mode 100644 src/components/common/Charts/types/index.tsx create mode 100644 src/components/common/Charts/utils/getChartFillOfType.tsx create mode 100644 src/components/common/Charts/utils/getChartOfType.tsx create mode 100644 src/components/common/Charts/utils/index.ts create mode 100644 src/components/common/Chip/index.tsx create mode 100644 src/components/common/DataCard/index.tsx create mode 100644 src/components/common/DataTable/DataTablePagination/index.tsx create mode 100644 src/components/common/DataTable/TableSkeleton/index.tsx create mode 100644 src/components/common/DataTable/index.tsx create mode 100644 src/components/common/ErrorBoundary/index.tsx create mode 100644 src/components/common/ErrorMessage/index.tsx create mode 100644 src/components/common/Fallback/index.tsx create mode 100644 src/components/common/FormUI/ErrorMessage/index.tsx create mode 100644 src/components/common/FormUI/FileUpload/index.tsx create mode 100644 src/components/common/FormUI/FormControl/index.tsx create mode 100644 src/components/common/FormUI/FormGroup/index.tsx create mode 100644 src/components/common/FormUI/Input/index.tsx create mode 100644 src/components/common/FormUI/Label/index.tsx create mode 100644 src/components/common/FormUI/MultiSelect/index.tsx create mode 100644 src/components/common/FormUI/SearchInput/index.tsx create mode 100644 src/components/common/FormUI/Select/index.tsx create mode 100644 src/components/common/FormUI/index.ts create mode 100644 src/components/common/Icon/index.tsx create mode 100644 src/components/common/InfoDialog/index.tsx create mode 100644 src/components/common/Layouts/Flex/index.tsx create mode 100644 src/components/common/Layouts/FlexColumn/index.tsx create mode 100644 src/components/common/Layouts/FlexRow/index.tsx create mode 100644 src/components/common/Layouts/Grid/index.tsx create mode 100644 src/components/common/Layouts/index.tsx create mode 100644 src/components/common/Layouts/types.ts create mode 100644 src/components/common/MapLibreComponents/AsyncPopup/index.tsx create mode 100644 src/components/common/MapLibreComponents/BaseLayerSwitcher/baseLayers.tsx create mode 100644 src/components/common/MapLibreComponents/BaseLayerSwitcher/index.tsx create mode 100644 src/components/common/MapLibreComponents/Layers/SymbolLayer.ts create mode 100644 src/components/common/MapLibreComponents/Layers/VectorLayer.ts create mode 100644 src/components/common/MapLibreComponents/Layers/VectorTileLayer.ts create mode 100644 src/components/common/MapLibreComponents/MapContainer/index.tsx create mode 100644 src/components/common/MapLibreComponents/PopupUI/index.tsx create mode 100644 src/components/common/MapLibreComponents/helpers/changeLayerOrder.ts create mode 100644 src/components/common/MapLibreComponents/index.ts create mode 100644 src/components/common/MapLibreComponents/map.css create mode 100644 src/components/common/MapLibreComponents/types/index.ts create mode 100644 src/components/common/MapLibreComponents/useDrawTool/index.ts create mode 100644 src/components/common/MapLibreComponents/useMapLibreGLMap/index.ts create mode 100644 src/components/common/Modal/index.tsx create mode 100644 src/components/common/PromptDialog/index.tsx create mode 100644 src/components/common/RoundedContainer/index.tsx create mode 100644 src/components/common/Spinner/index.tsx create mode 100644 src/constants/index.ts create mode 100644 src/constants/map.ts create mode 100644 src/constants/modalContents.tsx create mode 100644 src/hooks/useAuth.ts create mode 100644 src/hooks/useCustomUpload.ts create mode 100644 src/hooks/useOutsideClick.ts create mode 100644 src/hooks/useRouteParamQuery.ts create mode 100644 src/hooks/useScrollActiveListener.ts create mode 100644 src/main.tsx create mode 100644 src/react-app-env.d.ts create mode 100644 src/routes/ProtectedRoute.tsx create mode 100644 src/routes/appRoutes.ts create mode 100644 src/routes/generateRoutes.tsx create mode 100644 src/routes/testRoutes.ts create mode 100644 src/routes/types.ts create mode 100644 src/services/common.ts create mode 100644 src/services/index.ts create mode 100644 src/store/actions/common.ts create mode 100644 src/store/actions/loader.ts create mode 100644 src/store/hooks/index.ts create mode 100644 src/store/index.ts create mode 100644 src/store/persist.ts create mode 100644 src/store/reducers/index.ts create mode 100644 src/store/sagas/index.ts create mode 100644 src/store/selector/common.ts create mode 100644 src/store/slices/common.ts create mode 100644 src/store/slices/loader.ts create mode 100644 src/utils/capitalizeFirstLetter.ts create mode 100644 src/utils/checkIfLoading.ts create mode 100644 src/utils/formatNumberWithCommas.ts create mode 100644 src/utils/hasErrorBoundary.tsx create mode 100644 src/utils/index.ts create mode 100644 src/utils/isEmpty.ts create mode 100644 src/utils/prepareFormData.ts create mode 100644 src/utils/prepareQueryParam.ts create mode 100644 src/utils/removeObjectKeys.ts create mode 100644 src/utils/sagaUtils.ts create mode 100644 src/views/Dashboard/index.tsx create mode 100644 tailwind.config.js create mode 100644 tsconfig.json create mode 100644 tsconfig.node.json create mode 100644 vite.config.ts create mode 100644 yarn.lock diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..4aeda470 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +SITE_NAME="Starter Kit -v3 (Ts)" +BASE_URL=https://admin.naxa.com.np +API_URL_V1=https://admin.naxa.com.np/api/v1 \ No newline at end of file diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..3435e57d --- /dev/null +++ b/.eslintignore @@ -0,0 +1,8 @@ +node_modules +dist +vite.config.ts +src/vite-env.d.ts +src/schemas/types/vite-env.d.ts +src/constants/Proxies.ts +tailwind.config.js +postcss.config.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..45cf4323 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,54 @@ +module.exports = { + env: { + browser: true, + es2021: true, + }, + extends: [ + 'airbnb', + 'plugin:react/recommended', + // 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + overrides: [], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: ['./tsconfig.json'], + + extraFileExtensions: ['.json'], + tsconfigRootDir: __dirname, + }, + plugins: ['react-hooks', 'prettier'], + rules: { + 'prettier/prettier': 'error', + 'no-console': 'error', + 'react/react-in-jsx-scope': 0, + 'react/jsx-props-no-spreading': 'off', + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + 'react/forbid-prop-types': 'off', + 'react/prop-types': 'off', + 'no-unsafe-optional-chaining': 'warn', + 'import/no-import-module-exports': 'off', + 'react/function-component-definition': 'off', + 'react/jsx-filename-extension': 'off', + 'import/prefer-default-export': 'warn', + 'react/require-default-props': 'off', + 'object-curly-newline': 'off', + 'no-undef': 0, + 'import/no-unresolved': 0, + 'prefer-template': 1, + 'react/jsx-no-useless-fragment': 0, + 'import/extensions': 0, + 'no-plusplus': 0, + 'no-unused-vars': 'error', + '@typescript-eslint/no-unused-vars': 'off', + 'class-methods-use-this': 'warn', + 'react/state-in-constructor': 0, + 'react/destructuring-assignment': 0, + 'no-param-reassign': 'warn', + 'jsx-a11y/label-has-associated-control': 'off', + 'jsx-a11y/control-has-associated-label': 'off', + }, +}; diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..b6a38e2b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,39 @@ +## What type of PR is this? (check multiple if applicable) + +- [ ] 🍕 Feature +- [ ] 🐛 Bug Fix +- [ ] 📝 Documentation +- [ ] 🧑💻 Refactor +- [ ] ✅ Test +- [ ] 🤖 Build or CI +- [ ] ❓ Other (please specify) + +## Related Issue + +Example: Fixes #123 + +## Describe this PR + +A brief description of how this solves the issue (in present tense). + +## Screenshots + +Please provide screenshots of the change. + +## Alternative Approaches Considered + +Did you attempt any other approaches that are not documented in code? + +## Review Guide + +Notes for the reviewer. Specific key points and additional information that might be useful to the reviewer in evaluating this pull request. This could include performance considerations,design choices, etc. + +## Checklist before requesting a review ( must have all the items ticked ) + +- [ ] My code adheres to the coding and style guidelines of the project. +- [ ] I have performed a self-review of my own code. +- [ ] I have commented my code, particularly in hard-to-understand areas. +- [ ] I have wrote use cases for complex functions I made. +- [ ] My changes generate no new warnings + +## [optional] What gif best describes this PR or how it makes you feel? diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml new file mode 100644 index 00000000..623f8b01 --- /dev/null +++ b/.github/workflows/build_and_deploy.yml @@ -0,0 +1,137 @@ +name: Build Starterkit Frontend CICD + +on: + push: + branches: + - develop + - staging + - master + workflow_dispatch: + +env: + AUTHOR: naxa + AWS_REGION: ap-south-1 + +jobs: + build: + name: Build Static Files + runs-on: self-hosted + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: 19.x + + - name: Cache node_modules + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Write Environment Variables + id: write_env + run: | + case "${{ github.ref }}" in + refs/heads/develop) + echo ' + SITE_NAME="Starter Kit -v3 (Ts)" + BASE_URL=https://admin.naxa.com.np + API_URL_V1=https://admin.naxa.com.np/api/v1 + ' > .env + ;; + refs/heads/staging) + echo ' + SITE_NAME="Starter Kit -v3 (Ts)" + BASE_URL=https://admin.naxa.com.np + API_URL_V1=https://admin.naxa.com.np/api/v1 + ' > .env + ;; + refs/heads/master) + echo ' + SITE_NAME="Starter Kit -v3 (Ts)" + BASE_URL=https://admin.naxa.com.np + API_URL_V1=https://admin.naxa.com.np/api/v1 + ' > .env + ;; + esac + + - name: Install yarn + run: npm install -g yarn + + - name: Install dependencies + run: yarn install + + - name: Generate build + run: | + yarn build + + - name: Upload Dist as Artifacts + uses: actions/upload-artifact@v3 + if: ${{ github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' }} + with: + name: DFIMS-${{ github.ref_name }} + path: dist + retention-days: 1 + + deploy: + name: Deploy Static Files + needs: + - build + if: ${{ github.ref == 'refs/heads/develop-xxx' || github.ref == 'refs/heads/staging-xxx' || github.ref == 'refs/heads/master-xxx' }} + runs-on: self-hosted + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Get Artifacts + uses: actions/download-artifact@v1 + with: + path: dist + name: DFIMS-${{ github.ref_name }} + + - name: Get VM SSH host and user + id: get_vm_conf + run: | + case "${{ github.ref }}" in + refs/heads/develop) + export SERVER_IP=159.89.164.123 + export SERVER_USERNAME=devops + export PROJECT_PATH=/srv/Projects/react-typescript-starterkit-v3/dist + ;; + refs/heads/staging) + export SERVER_IP=159.89.164.123 + export SERVER_USERNAME=devops + export PROJECT_PATH=/srv/Projects/react-typescript-starterkit-v3/dist + ;; + refs/heads/master) + export SERVER_IP=159.89.164.123 + export SERVER_USERNAME=devops + export PROJECT_PATH=/srv/Projects/react-typescript-starterkit-v3/dist + esac + echo "SERVER_IP=${SERVER_IP}" >> $GITHUB_OUTPUT + echo "SERVER_USERNAME=${SERVER_USERNAME}" >> $GITHUB_OUTPUT + echo "PROJECT_PATH=${PROJECT_PATH}" >> $GITHUB_OUTPUT + + - name: Configure SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 400 ~/.ssh/id_rsa + ssh-keyscan ${{ steps.get_vm_conf.outputs.SERVER_IP }} >> ~/.ssh/known_hosts + + - name: copy static files + run: | + scp -r ./dist/* ${{ steps.get_vm_conf.outputs.SERVER_USERNAME }}@${{ steps.get_vm_conf.outputs.SERVER_IP }}:${{ steps.get_vm_conf.outputs.PROJECT_PATH }} + echo "Build Pass" + + - name: Clean SSH keys + run: | + chmod 700 ~/.ssh/id_rsa + rm -rf ~/.ssh/id_rsa \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..08a5e6b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +.vite/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? +# **/__test__/ +.env +todo.txt \ No newline at end of file diff --git a/.husky/.lintstagedrc b/.husky/.lintstagedrc new file mode 100644 index 00000000..e80e8beb --- /dev/null +++ b/.husky/.lintstagedrc @@ -0,0 +1,3 @@ +{ + "*.{js,jsx,ts,tsx}": "eslint --fix" +} diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..1c448125 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,15 @@ +#!/bin/sh +if head -1 "$1" | grep -qE "Merge .{1,}$"; then + echo $'\e[1;36m Skipping commit check.\e[0m\n' + exit 0 +fi +if ! head -1 "$1" | grep -qE "^(feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|hotfix|asap)(\(.+?\))?: .{1,}$"; then + echo $'\e[1;31m Aborting commit. Your commit message is invalid.\e[0m\n' >&2 + echo $'\e[1;36m Please fix your commit message starting with prefix-\e[0m \e[36m\n feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|hotfix|asap \n followed by ":" and what work did you do.\e[0m \n for example: \e[1;42m feat: your commit message \e[0m\n' + exit 1 +fi +if ! head -1 "$1" | grep -qE "^.{1,200}$"; then + echo $'\n\e[1;31m Aborting commit. Your commit message is too long.\n\e[0m' >&2 + echo $'\e[42m Please keep your commit message short i.e. only upto 200 characters.\e[0m\n' + exit 1 +fi diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..ff8064ee --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,21 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +BRANCH=$(git rev-parse --abbrev-ref HEAD) + +ALLOWED_BRANCHES="staging|master|main|develop" +REGEX="^(feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|prd|hotfix|asap)/.{1,}$" + +if echo "$BRANCH" | grep -Eq "$ALLOWED_BRANCHES"; then + echo $'\e[1;36m Skipping branch check for \e[0m'$'\e[1;31m'$BRANCH$'\e[0m \e[1;36mbranch\e[0m.\n' + exit 0 +fi +if ! echo "$BRANCH" | grep -Eq "$REGEX"; then + echo $'\n\e[1;31m Your commit was rejected due to branching name.\e[0m\n' + echo $'\e[1;36mPlease rename your branch starting with prefix-\e[0m \e[36m\nfeat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|prd|hotfix|asap)\nfollowed by "/" and separated by "-".\e[0m \nfor example: \e[1;42mfeat/check-branch-name\e[0m\n' + exit 1 +fi + +yarn lint-staged + + diff --git a/.lintstagedrc b/.lintstagedrc new file mode 100644 index 00000000..63e1c50e --- /dev/null +++ b/.lintstagedrc @@ -0,0 +1,3 @@ +{ + "*.{js,jsx,ts,tsx}": "eslint --fix" +} diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..8ddbc0c6 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v18.16.0 diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 00000000..70ed30e0 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,9 @@ +module.exports = { + semi: true, + trailingComma: 'all', + singleQuote: true, + printWidth: 80, + endOfLine: 'auto', + arrowParens: 'avoid', + plugins: ['prettier-plugin-tailwindcss'], +}; diff --git a/README.md b/README.md new file mode 100644 index 00000000..762719bd --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ + +## Getting started with the starter kit + + + +1. Do not use npm to install packages, use yarn. If you want to run `npm install` then delete the `yarn.lock` file and install the packages using npm. + +2. Create a .env file and copy .env.sample to .env + +3. Run `yarn dev` to start the development server. + +4. If there is error on "/dashboard" route then comment out the proxy setup part on `vite.config.ts` file. + + + +## Folder Structure + + + +- [API](./src/api/readme.md)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$--> Api's for the project + +- [Wrappers](./src/api/wrappers/readme.md)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$--> Wrappers + +- [Routes](./src/routes/readme.md)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$--> Routes + +- [Utils](./src/utils/readme.md) + +- [UI](./src/ui/readme.md) + + + +## Example to add shadcn component (select component- [link](https://ui.shadcn.com/docs/components/select) ) + + npx shadcn-ui add select +give path as + **./src/ui/atoms/common/** + +- resolve all classes with tailwind prefix +- replace classes with color variables with project color variables +- add missing dependencies ( if npx failed to install dependencies automatically e.g: @radix-ui/react-select ) + diff --git a/components.json b/components.json new file mode 100644 index 00000000..6077d1f3 --- /dev/null +++ b/components.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "default", + "rsc": true, + "tsx": true, + "tailwind": { + "config": "tailwind.config.js", + "css": "src/assets/css/tailwind.css", + "baseColor": "slate", + "cssVariables": true + }, + "aliases": { + "components": "components/RadixComponents", + "utils": "@/lib/utils" + } +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..138bfd7a --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + +
+ + + + + + +Qrws7*py&~0pv4UQ2iD~kcmMzZ literal 0 HcmV?d00001 diff --git a/scripts/setup-user-module.sh b/scripts/setup-user-module.sh new file mode 100755 index 00000000..1f7c4b0c --- /dev/null +++ b/scripts/setup-user-module.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# setup directory path to clone the module +SETUP_DIRECTORY=./src/modules/user-auth-module/ + +# exit if SETUP_DIRECTORY already exists +if [ -d "$SETUP_DIRECTORY" ]; then + echo "Directory already exists!" + echo "Please remove $SETUP_DIRECTORY and run the command again." + exit +fi + +# clone user-auth-module repo without files +git clone --no-checkout --depth=1 --filter=tree:0 \ +git@github.com:naxa-developers/user-auth-module.git $SETUP_DIRECTORY + +# cd into user-auth-module directory +cd $SETUP_DIRECTORY + +# fetch files only from ./src/ directory +git sparse-checkout set --no-cone '/src/*/' + +# fetch the folder and files +git checkout + +# remove .git file to detach tracking +rm -rf .git + +echo "----------------------------------------------" +echo "User module setup successful. Enjoy!" \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 00000000..7f497cf5 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,98 @@ +import { useLocation } from 'react-router-dom'; +import { initDomToCode } from 'dom-to-code'; +import { ToastContainer } from 'react-toastify'; +import { useTypedDispatch, useTypedSelector } from '@Store/hooks'; +import generateRoutes from '@Routes/generateRoutes'; +import appRoutes from '@Routes/appRoutes'; +import testRoutes from '@Routes/testRoutes'; +import { + setModalContent, + setPromptDialogContent, + toggleModal, + togglePromptDialog, +} from '@Store/actions/common'; +import 'react-toastify/dist/ReactToastify.css'; +import Modal from '@Components/common/Modal'; +import PromptDialog from '@Components/common/PromptDialog'; +import { + getModalContent, + getPromptDialogContent, +} from '@Constants/modalContents'; + +export default function App() { + const { pathname } = useLocation(); + const dispatch = useTypedDispatch(); + const showModal = useTypedSelector(state => state.common.showModal); + const modalContent = useTypedSelector(state => state.common.modalContent); + const showPromptDialog = useTypedSelector( + state => state.common.showPromptDialog, + ); + const promptDialogContent = useTypedSelector( + state => state.common.promptDialogContent, + ); + + const routesWithoutSidebar = [ + '/login', + '/sign-up', + '/forgot-password', + '/public-page', + ]; + + const hideSideBar = routesWithoutSidebar.some(url => pathname.includes(url)); + + const handleModalClose = () => { + dispatch(toggleModal()); + setTimeout(() => { + dispatch(setModalContent(null)); + }, 150); + }; + + const handlePromptDialogClose = () => { + dispatch(togglePromptDialog()); + setTimeout(() => { + dispatch(setPromptDialogContent(null)); + }, 150); + }; + + return ( + <> + {process.env.NODE_ENV !== 'production' && + !process.env.DISABLE_DOM_TO_CODE && + initDomToCode()} +
d
z !#7=%y_5W3N)8j@Li@#&$we*dYj
zUiwvf?^93FRN;Gadq}aC{=Rr0#?E>F8nadC?+d2sBWUlWu$D@~%lv)G2O3YizA*8z
zdSUJ9(*Pn6AI8;xr|00wP7*2SP}k)pb6%3v9!EY
3O1&yz2JPfPg?>MF4Yd{<4Wv=lyTKW`7(|4&MLT6#62(w_Lz{4$?@VZJ>IpZdi(
z?RmN`G4mt#$psXP|P
zcu+L98#PkdNga!;0+fEdekdH<7FpKMqLS){q}aCTvH^C@B9f$F!CvQ(uZq>R7K?dV
zS7-Vo<19jnU3aBF%&&z5EIg@wLZlznX$#f-W?U@n)9M(H@K_N}^G=24dlVk=`ZYes
z7V3d6C>uAG{G8?(VL?NbE73d(8WPt9^2@p=zbHSWc@Q+WEXe76dt@3On9n~?!z80&
zVu`L{!0~`p{ZKI-gi@
VaOB
zB6_%y&FhKxUz^ Grtd(0@?
zx^-3mXn*6Hy1F%uI9bKpCVe2uE&wtn$O1={vx!0X24civJV{>hpV&);5ElvjZW68^
zHA$PToUET<`Xp0{@;>450qep4W^a}dSX}Z9nsdJTp9rcM^H;
2WYwRo^`_&7t6x9HpD(Hk82RuqO(N%*%an#F<_l`7NGR}w)bTkru#h6f@
zwT$FATZ5;5Y|S+nt}H%q@?^4PaQBsCni@OL3C
D>lDk`bG#npw`F7O_mJV39@H^j
zPd#FVxQ%RV-4A}S?)JkYzx?IMU3e5QAs;5&DW6qkMreAp@q4$^v#j(kdYC`Eun}wa
zQRGL~DYl1I
bMSqldIGo>#~z`&Oo=B;6&RMbC97Lo4fXzH
zy%mFj@HfJ+A2^1vZT4?PIZ5O4b&)UAKntEQfW!%j#iTVoZQ=x)!H~(br)*$yrhnU-
z6&0P{{%PNnFTih)z3`-Oy1yY&nP}PC(LXaeP_}0i-QL807@u4oY&&SP_QWnQmYIsn
z3>U