From 415e86a447a8d29b3fe328ab695fb3ba649cd169 Mon Sep 17 00:00:00 2001 From: Karan Sanjeev Date: Tue, 1 Jun 2021 14:29:32 +0530 Subject: [PATCH] Run prettier on project --- .circleci/config.yml | 4 +- .github/ISSUE_TEMPLATE/bug_report.md | 24 +- .github/ISSUE_TEMPLATE/feature_request.md | 7 +- .github/dependabot.yml | 1 - .github/stale.yml | 2 +- .github/workflows/codeql-analysis.yml | 77 +- .github/workflows/develop.yml | 2 +- .github/workflows/ossar-analysis.yml | 48 +- .github/workflows/production.yml | 2 +- CODE_OF_CONDUCT.md | 26 +- README.md | 18 +- SECURITY.md | 24 +- bsconfig.json | 49 +- build-scripts/generate-build-version.js | 14 +- src/App.tsx | 81 +- src/Common/constants.tsx | 2 +- src/Common/static/countries.json | 2 +- src/Common/static/states.json | 2 +- src/Common/utils.tsx | 41 +- src/Common/validation.tsx | 48 +- src/Components/Auth/ForgetPassword.tsx | 231 +- src/Components/Auth/Register.tsx | 53 +- src/Components/Auth/ResetPassword.tsx | 324 +- src/Components/Auth/index.tsx | 8 +- src/Components/Common/AddCard.tsx | 77 +- src/Components/Common/AlertDialog.tsx | 59 +- src/Components/Common/ConfirmDialog.tsx | 66 +- src/Components/Common/HelperInputFields.tsx | 857 +++--- src/Components/Common/LanguageSelector.tsx | 4 +- src/Components/Common/Loading.tsx | 30 +- .../Common/LocationSearchAndPick.tsx | 235 +- src/Components/Common/NavTabs.tsx | 84 +- src/Components/Common/OnlineDoctorsSelect.tsx | 132 +- src/Components/Common/PageTitle.tsx | 50 +- src/Components/Common/Pagination.tsx | 282 +- src/Components/Common/SlideOver.gen.tsx | 17 +- src/Components/Common/Transition.tsx | 47 +- src/Components/Common/UserSelect.tsx | 148 +- src/Components/Common/VirtualizedTable.tsx | 219 +- .../ExternalResultLocalbodySelector.tsx | 32 +- .../ExternalResult/ExternalResultUpload.tsx | 101 +- src/Components/ExternalResult/ListFilter.tsx | 109 +- src/Components/ExternalResult/ResultItem.tsx | 37 +- src/Components/ExternalResult/ResultList.tsx | 160 +- src/Components/Facility/AddInventoryForm.tsx | 196 +- src/Components/Facility/BedCapacityForm.tsx | 63 +- src/Components/Facility/BedTypeCard.tsx | 2 +- .../Facility/ConsultationDetails.tsx | 6 +- src/Components/Facility/ConsultationForm.tsx | 11 +- .../Facility/DoctorCapacityForm.tsx | 57 +- src/Components/Facility/DoctorsCountCard.tsx | 2 +- .../Facility/DuplicatePatientDialog.tsx | 238 +- .../FacilityFilter/DistrictSelect.tsx | 144 +- .../FacilityFilter/LocalBodySelect.tsx | 147 +- .../Facility/FacilityFilter/index.tsx | 320 +- .../Investigations/Reports/ReportTable.tsx | 35 +- .../Facility/Investigations/Reports/index.tsx | 3 +- .../Facility/Investigations/Reports/types.ts | 24 +- src/Components/Facility/MinQuantityList.tsx | 284 +- src/Components/Facility/SetInventoryForm.tsx | 170 +- .../Facility/TransferPatientDialog.tsx | 357 +-- src/Components/Facility/TriageForm.tsx | 106 +- src/Components/Facility/UpdateMinQuantity.tsx | 260 +- .../Patient/DailyRoundListDetails.tsx | 6 +- src/Components/Patient/DailyRounds.tsx | 876 +++--- src/Components/Patient/ManagePatients.tsx | 8 +- src/Components/Patient/PatientFilter.tsx | 52 +- src/Components/Patient/PatientRegister.tsx | 4 +- src/Components/Patient/SampleDetails.tsx | 269 +- src/Components/Patient/SamplePreview.tsx | 2688 +++++++++++------ src/Components/Patient/SampleTest.tsx | 8 +- src/Components/Patient/SampleViewAdmin.tsx | 249 +- src/Components/Patient/UpdateStatusDialog.tsx | 289 +- src/Components/Patient/models.tsx | 18 +- src/Components/Resource/CommentSection.tsx | 2 +- src/Components/Resource/Commons.tsx | 41 +- src/Components/Resource/ListView.tsx | 14 +- src/Components/Resource/ResourceCreate.tsx | 10 +- src/Components/Resource/ResourceDetails.tsx | 10 +- .../Resource/ResourceDetailsUpdate.tsx | 27 +- src/Components/Shifting/BoardView.tsx | 147 +- src/Components/Shifting/ShiftingBoard.tsx | 259 +- src/Components/Users/LinkFacilityDialog.tsx | 110 +- src/Components/Users/ManageUsers.tsx | 318 +- src/Components/Users/UserAdd.tsx | 178 +- src/Components/Users/models.tsx | 22 +- src/Locale/TRANSLATION_CONTRIBUTION.md | 8 +- src/Locale/en/Auth.json | 64 +- src/Locale/en/Common.json | 28 +- src/Locale/en/Facility.json | 18 +- src/Locale/en/index.js | 10 +- src/Locale/ml/Auth.json | 2 +- src/Locale/ml/Common.json | 2 +- src/Locale/ml/Entities.json | 2 +- src/Locale/ml/Facility.json | 2 +- src/Locale/ml/index.js | 10 +- src/Locale/mr/Auth.json | 2 +- src/Locale/mr/Common.json | 2 +- src/Locale/mr/Entities.json | 2 +- src/Locale/mr/Facility.json | 2 +- src/Locale/mr/index.js | 10 +- src/Locale/ta/Auth.json | 2 +- src/Locale/ta/Common.json | 2 +- src/Locale/ta/Entities.json | 2 +- src/Locale/ta/Facility.json | 2 +- src/Locale/ta/index.js | 10 +- src/Locale/update_locale.js | 85 +- src/Redux/Reducer.tsx | 72 +- src/Utils/Notifications.js | 120 +- src/Utils/build-meta-info.js | 16 +- src/Utils/useRecorder.js | 11 +- src/index.html | 1 - src/index.scss | 11 +- src/index.tsx | 18 +- src/react-phone-input-2.d.ts | 132 +- src/setupTests.ts | 2 +- tsconfig.json | 10 +- webpack.config.js | 2 +- 118 files changed, 7207 insertions(+), 5321 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92b539671dd..4e69aeebcbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ workflows: - aws-eks/update-container-image: cluster-name: "${EKS_CLUSTER_NAME}" aws-region: "${AWS_DEFAULT_REGION}" - container-image-updates: '${EKS_CONTAINER_NAME}=${AWS_ECR_ACCOUNT_URL}/${ECR_REPO_NAME}:${CIRCLE_SHA1}' + container-image-updates: "${EKS_CONTAINER_NAME}=${AWS_ECR_ACCOUNT_URL}/${ECR_REPO_NAME}:${CIRCLE_SHA1}" resource-name: "${EKS_STAGING_RESOURCE_NAME}" requires: - aws-ecr/build-and-push-image @@ -39,7 +39,7 @@ workflows: - aws-eks/update-container-image: cluster-name: "${EKS_CLUSTER_NAME}" aws-region: "${AWS_DEFAULT_REGION}" - container-image-updates: '${EKS_CONTAINER_NAME}=${AWS_ECR_ACCOUNT_URL}/${ECR_REPO_NAME}:${CIRCLE_SHA1}' + container-image-updates: "${EKS_CONTAINER_NAME}=${AWS_ECR_ACCOUNT_URL}/${ECR_REPO_NAME}:${CIRCLE_SHA1}" resource-name: "${EKS_PRODUCTION_RESOURCE_NAME}" requires: - aws-ecr/build-and-push-image diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7824f..9b77ea713f9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,10 +1,9 @@ --- name: Bug report about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] **Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d615..2bc5d5f7118 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,10 +1,9 @@ --- name: Feature request about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8fd5e83498b..b733eed5568 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,4 +12,3 @@ updates: labels: - "npm" - "dependencies" - diff --git a/.github/stale.yml b/.github/stale.yml index 64e259cb5e2..81656b1e71a 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -15,4 +15,4 @@ markComment: > recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to repopen the issue. # Comment to post when closing a stale issue. Set to `false` to disable -closeComment: true \ No newline at end of file +closeComment: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1e52f5e45e0..ca4f6fc18cc 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -7,48 +7,47 @@ on: # The branches below must be a subset of the branches above branches: [develop] schedule: - - cron: '0 22 * * 0' + - cron: "0 22 * * 0" jobs: CodeQL-Build: - runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index ee034ea9a88..ffff54ae475 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -47,7 +47,7 @@ jobs: - name: Push image run: | IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME - + # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') # Strip git ref prefix from version diff --git a/.github/workflows/ossar-analysis.yml b/.github/workflows/ossar-analysis.yml index e047f4c98ce..5cd11a87443 100644 --- a/.github/workflows/ossar-analysis.yml +++ b/.github/workflows/ossar-analysis.yml @@ -15,31 +15,31 @@ jobs: steps: # Checkout your code repository to scan - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} - # Install dotnet, used by OSSAR - - name: Install .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.201' + # Install dotnet, used by OSSAR + - name: Install .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "3.1.201" - # Run open source static analysis tools - - name: Run OSSAR - uses: github/ossar-action@v1 - id: ossar + # Run open source static analysis tools + - name: Run OSSAR + uses: github/ossar-action@v1 + id: ossar - # Upload results to the Security tab - - name: Upload OSSAR results - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: ${{ steps.ossar.outputs.sarifFile }} + # Upload results to the Security tab + - name: Upload OSSAR results + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: ${{ steps.ossar.outputs.sarifFile }} diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 772a2fc7535..204cb2b529e 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -48,7 +48,7 @@ jobs: - name: Push image run: | IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME - + # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 42146b1ebbb..6469414aa5b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities diff --git a/README.md b/README.md index 07c386bbe61..086784888e3 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,30 @@ -# Coronasafe Care Frontend . +# Coronasafe Care Frontend . [![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/0)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/0)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/1)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/1)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/2)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/2)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/3)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/3)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/4)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/4)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/5)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/5)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/6)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/6)[![](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/images/7)](https://sourcerer.io/fame/tomahawk-pilot/coronasafe/care_fe/links/7) - [![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/dashboard?id=coronasafe_care_fe) ![Code scanning - action](https://github.com/coronasafe/care_fe/workflows/Code%20scanning%20-%20action/badge.svg) ![OSSAR](https://github.com/coronasafe/care_fe/workflows/OSSAR/badge.svg) ![Staging Release](https://github.com/coronasafe/care_fe/workflows/CARE%20Develop%20Registry/badge.svg) ![Production Release](https://github.com/coronasafe/care_fe/workflows/Production%20Release/badge.svg) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/200482ab117e4b5397ff3f5ae5719aa2)](https://www.codacy.com/gh/coronasafe/care_fe?utm_source=github.com&utm_medium=referral&utm_content=coronasafe/care_fe&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/200482ab117e4b5397ff3f5ae5719aa2)](https://www.codacy.com/gh/coronasafe/care_fe?utm_source=github.com&utm_medium=referral&utm_content=coronasafe/care_fe&utm_campaign=Badge_Grade) [![CircleCI](https://circleci.com/gh/coronasafe/care_fe.svg?style=svg)](https://circleci.com/gh/coronasafe/care_fe) [![Maintainability](https://api.codeclimate.com/v1/badges/f1438f693aa459805301/maintainability)](https://codeclimate.com/github/coronasafe/care_fe/maintainability) -Auto Deployed to https://care.coronasafe.in for Develop Branch. +Auto Deployed to https://care.coronasafe.in for Develop Branch. All pull request has a preview build powered by @Netlify ### Report bugs at [JIRA SERVICE DESK](https://bugs.coronasafe.in) ### Issue tracker : [JIRA SOFTWARE](https://rakshalife.atlassian.net/browse/CARE) - Auto Deployed to https://care.coronasafe.network for Master Branch Please comment on the issue if you are taking it up and tag pull requests with issues. -tag @coronasafe/code-reviewers for faster resolution. +tag @coronasafe/code-reviewers for faster resolution. attach. a screenshot for all Prs - - ## Available Scripts In the project directory, you can run: @@ -46,14 +42,15 @@ You will also see any lint errors in the console. Builds the app for production to the `build` folder.
It correctly bundles React in production mode and optimizes the build for the best performance. -### `npm run start:Dev` +### `npm run start:Dev` + Starts a production http-server in local to run the project with Service worker The build is minified and the filenames include the hashes.
Your app is ready to be deployed! +## Staging -## Staging BE: https://careapi.coronasafe.in/swagger/ FE: https://care.coronasafe.in/ @@ -70,4 +67,3 @@ user_id: devstaff pass: Coronasafe@123 role: Staff ``` - diff --git a/SECURITY.md b/SECURITY.md index 1a843fad931..0b3730ed9ad 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -9,18 +9,18 @@ ## Supported Browsers -| Browser | Supported | -| ------- | ------------------ | -| Firefox | :white_check_mark: | -| Chrome | :white_check_mark: | -| Brave | :white_check_mark: | -| opera | :white_check_mark: | -| Edge | :white_check_mark: | -| Internet Explorer | :x: | -| Safari | :x: | -| Uc Browser | :x: | -| Tor | :x: | - +| Browser | Supported | +| ----------------- | ------------------ | +| Firefox | :white_check_mark: | +| Chrome | :white_check_mark: | +| Brave | :white_check_mark: | +| opera | :white_check_mark: | +| Edge | :white_check_mark: | +| Internet Explorer | :x: | +| Safari | :x: | +| Uc Browser | :x: | +| Tor | :x: | ## Reporting a Vulnerability + Please create a ticket at https://support.coronasafe.network diff --git a/bsconfig.json b/bsconfig.json index e6c09dc2165..8bb0d8de119 100644 --- a/bsconfig.json +++ b/bsconfig.json @@ -1,28 +1,25 @@ { - "name": "care_fe", - "reason": { "react-jsx": 3 }, - "bsc-flags": ["-bs-super-errors"], - "sources": [ - { - "dir": "src", - "subdirs": true - } - ], - "package-specs": [ - { - "module": "es6", - "in-source": true - } - ], - "suffix": ".bs.js", - "namespace": true, - "bs-dependencies": [ - "reason-react", - "@coronasafe/prescription-builder" - ], - "ppx-flags": [], - "refmt": 3, - "gentypeconfig": { - "language": "typescript" + "name": "care_fe", + "reason": { "react-jsx": 3 }, + "bsc-flags": ["-bs-super-errors"], + "sources": [ + { + "dir": "src", + "subdirs": true } -} \ No newline at end of file + ], + "package-specs": [ + { + "module": "es6", + "in-source": true + } + ], + "suffix": ".bs.js", + "namespace": true, + "bs-dependencies": ["reason-react", "@coronasafe/prescription-builder"], + "ppx-flags": [], + "refmt": 3, + "gentypeconfig": { + "language": "typescript" + } +} diff --git a/build-scripts/generate-build-version.js b/build-scripts/generate-build-version.js index de4bf5873c6..36e7ea1162a 100644 --- a/build-scripts/generate-build-version.js +++ b/build-scripts/generate-build-version.js @@ -1,24 +1,24 @@ #!/usr/bin/env node -const fs = require('fs'); -const { v4: uuidv4 } = require('uuid'); +const fs = require("fs"); +const { v4: uuidv4 } = require("uuid"); const appVersion = uuidv4(); const jsonData = { - version: appVersion + version: appVersion, }; const jsonContent = JSON.stringify(jsonData); fs.writeFile( - './public/build-meta.json', + "./public/build-meta.json", jsonContent, - { flag: 'w+', encoding: 'utf8' }, - err => { + { flag: "w+", encoding: "utf8" }, + (err) => { if (err) { return console.log(err); } return null; } -); \ No newline at end of file +); diff --git a/src/App.tsx b/src/App.tsx index 1d3a20b2ab4..08d65297101 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,57 +1,60 @@ -import React, { useState, useEffect } from 'react'; -import loadable from '@loadable/component'; -import SessionRouter from './Router/SessionRouter'; -import AppRouter from './Router/AppRouter'; -import { useDispatch, useSelector } from 'react-redux'; -import { getCurrentUser } from './Redux/actions'; -import './App.scss'; -const Loading = loadable( () => import("./Components/Common/Loading")); -import { useAbortableEffect, statusType } from './Common/utils'; -import axios from 'axios'; +import React, { useState, useEffect } from "react"; +import loadable from "@loadable/component"; +import SessionRouter from "./Router/SessionRouter"; +import AppRouter from "./Router/AppRouter"; +import { useDispatch, useSelector } from "react-redux"; +import { getCurrentUser } from "./Redux/actions"; +import "./App.scss"; +const Loading = loadable(() => import("./Components/Common/Loading")); +import { useAbortableEffect, statusType } from "./Common/utils"; +import axios from "axios"; const App: React.FC = () => { const dispatch: any = useDispatch(); - const state: any = useSelector(state => state); + const state: any = useSelector((state) => state); const { currentUser } = state; const [user, setUser] = useState(null); const updateRefreshToken = () => { - const refresh = localStorage.getItem('care_refresh_token'); - const access = localStorage.getItem('care_access_token'); - if (!access && refresh){ - localStorage.removeItem('care_refresh_token'); - document.location.reload(); - return; - } - if (!refresh) { - return; - } - axios.post('/api/v1/auth/token/refresh/', { - refresh - }).then((resp: any) => { - localStorage.setItem('care_access_token', resp.data.access) - localStorage.setItem('care_refresh_token', resp.data.refresh); - }).catch( (ex:any)=> { + const refresh = localStorage.getItem("care_refresh_token"); + const access = localStorage.getItem("care_access_token"); + if (!access && refresh) { + localStorage.removeItem("care_refresh_token"); + document.location.reload(); + return; + } + if (!refresh) { + return; + } + axios + .post("/api/v1/auth/token/refresh/", { + refresh, + }) + .then((resp: any) => { + localStorage.setItem("care_access_token", resp.data.access); + localStorage.setItem("care_refresh_token", resp.data.refresh); + }) + .catch((ex: any) => { // console.error('Error while refreshing',ex); }); - - } + }; useEffect(() => { updateRefreshToken(); - setInterval(updateRefreshToken , 5 * 60 * 1000) + setInterval(updateRefreshToken, 5 * 60 * 1000); }, [0]); - useAbortableEffect(async (status: statusType) => { - const res = await dispatch(getCurrentUser()); - if (!status.aborted && res && res.statusCode === 200) { - setUser(res.data); - } - }, [dispatch]); + useAbortableEffect( + async (status: statusType) => { + const res = await dispatch(getCurrentUser()); + if (!status.aborted && res && res.statusCode === 200) { + setUser(res.data); + } + }, + [dispatch] + ); if (!currentUser || currentUser.isFetching) { - return ( - - ); + return ; } if (currentUser && currentUser.data) { return ; diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index c4e7703ebbb..f239402a6c0 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -434,7 +434,7 @@ export const RESOURCE_SUBCATEGORIES: Array = [ { id: 120, text: "B TYPE OXYGEN CYLINDER" }, { id: 130, text: "C TYPE OXYGEN CYLINDER" }, { id: 140, text: "JUMBO D TYPE OXYGEN CYLINDER" }, - { id: 1000, text: "UNSPECIFIED" } + { id: 1000, text: "UNSPECIFIED" }, ]; export const RESOURCE_FILTER_ORDER: Array = [ diff --git a/src/Common/static/countries.json b/src/Common/static/countries.json index 13f1dd6f628..76b1e367683 100644 --- a/src/Common/static/countries.json +++ b/src/Common/static/countries.json @@ -248,4 +248,4 @@ "Yugoslavia", "Zambia", "Zimbabwe" -] \ No newline at end of file +] diff --git a/src/Common/static/states.json b/src/Common/static/states.json index a6a254b6de4..5649303a884 100644 --- a/src/Common/static/states.json +++ b/src/Common/static/states.json @@ -36,4 +36,4 @@ "Uttar Pradesh", "Uttarakhand", "West Bengal" -] \ No newline at end of file +] diff --git a/src/Common/utils.tsx b/src/Common/utils.tsx index e1b4226b167..76180bc4753 100644 --- a/src/Common/utils.tsx +++ b/src/Common/utils.tsx @@ -2,27 +2,30 @@ import { useEffect } from "react"; import { OptionsType } from "./constants"; -export interface statusType { - aborted?: boolean +export interface statusType { + aborted?: boolean; } -export const useAbortableEffect = (effect: Function, dependencies: Array) => { - const status: statusType = {}; // mutable status object - useEffect(() => { - status.aborted = false; - // pass the mutable object to the effect callback - // store the returned value for cleanup - const cleanUpFn = effect(status); - return () => { - // mutate the object to signal the consumer - // this effect is cleaning up - status.aborted = true; - if (typeof cleanUpFn === "function") { - // run the cleanup function - cleanUpFn(); - } - }; - }, [...dependencies]); +export const useAbortableEffect = ( + effect: Function, + dependencies: Array +) => { + const status: statusType = {}; // mutable status object + useEffect(() => { + status.aborted = false; + // pass the mutable object to the effect callback + // store the returned value for cleanup + const cleanUpFn = effect(status); + return () => { + // mutate the object to signal the consumer + // this effect is cleaning up + status.aborted = true; + if (typeof cleanUpFn === "function") { + // run the cleanup function + cleanUpFn(); + } + }; + }, [...dependencies]); }; export const parseOptionId: ( diff --git a/src/Common/validation.tsx b/src/Common/validation.tsx index b7e0c91929c..d597f508530 100644 --- a/src/Common/validation.tsx +++ b/src/Common/validation.tsx @@ -1,42 +1,48 @@ export const phonePreg = (phone: string) => { - const pattern = /^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$/; - return pattern.test(phone); + const pattern = /^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$/; + return pattern.test(phone); }; export const validateLocationCoordinates = (location: string) => { - const pattern = /^-?([1-8]?[1-9]|[1-9]0)\.{1}\d{1,6}/; - return pattern.test(location); + const pattern = /^-?([1-8]?[1-9]|[1-9]0)\.{1}\d{1,6}/; + return pattern.test(location); }; export const validateEmailAddress = (email: string) => { - const pattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return pattern.test(email); + const pattern = + /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return pattern.test(email); }; -export const getArrayValueByKey = (arr: Array, attr: string, value: string | number) => { - for (let i = 0; i < arr.length; i++) { - if (arr[i][attr] == value) { - return i; - } +export const getArrayValueByKey = ( + arr: Array, + attr: string, + value: string | number +) => { + for (let i = 0; i < arr.length; i++) { + if (arr[i][attr] == value) { + return i; } - return -1; + } + return -1; }; export const getRandomNumbers = (min: number, max: number) => { - return Math.floor(Math.random() * max) + min; + return Math.floor(Math.random() * max) + min; }; export const validateUsername = (username: string) => { - const pattern = /^[\w.@+-]+[^.@+_-]$/; - return pattern.test(username); + const pattern = /^[\w.@+-]+[^.@+_-]$/; + return pattern.test(username); }; export const validatePassword = (password: string) => { - const pattern = /(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$/; - return pattern.test(password); -} + const pattern = + /(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$/; + return pattern.test(password); +}; export const validatePincode = (pincode: string) => { - const pattern = /^[1-9][0-9]{5}$/; - return pattern.test(pincode); - }; \ No newline at end of file + const pattern = /^[1-9][0-9]{5}$/; + return pattern.test(pincode); +}; diff --git a/src/Components/Auth/ForgetPassword.tsx b/src/Components/Auth/ForgetPassword.tsx index f2fa343758a..f564d34cdce 100644 --- a/src/Components/Auth/ForgetPassword.tsx +++ b/src/Components/Auth/ForgetPassword.tsx @@ -1,126 +1,129 @@ -import { Button, CardActions, CardContent } from '@material-ui/core'; -import { Link } from 'raviger'; -import loadable from '@loadable/component'; -import React, { useState } from 'react'; -import { useDispatch } from 'react-redux'; -import { postForgotPassword } from '../../Redux/actions'; -import { TextInputField } from '../Common/HelperInputFields'; +import { Button, CardActions, CardContent } from "@material-ui/core"; +import { Link } from "raviger"; +import loadable from "@loadable/component"; +import React, { useState } from "react"; +import { useDispatch } from "react-redux"; +import { postForgotPassword } from "../../Redux/actions"; +import { TextInputField } from "../Common/HelperInputFields"; import * as Notification from "../../Utils/Notifications.js"; -import { withTranslation } from 'react-i18next'; -const Loading = loadable( () => import("../Common/Loading")); +import { withTranslation } from "react-i18next"; +const Loading = loadable(() => import("../Common/Loading")); const ForgotPasswordPage = (props: any) => { - const dispatch: any = useDispatch(); - const initForm: any = { - username: '', - }; - const initErr: any = {}; - const [form, setForm] = useState(initForm); - const [errors, setErrors] = useState(initErr); - const [disableBtn, setDisableBtn] = useState(false); - const [showLoader, setShowLoader] = useState(false); - const { t } = props; + const dispatch: any = useDispatch(); + const initForm: any = { + username: "", + }; + const initErr: any = {}; + const [form, setForm] = useState(initForm); + const [errors, setErrors] = useState(initErr); + const [disableBtn, setDisableBtn] = useState(false); + const [showLoader, setShowLoader] = useState(false); + const { t } = props; - const handleChange = (e: any) => { - const { value, name } = e.target; - const fieldValue = Object.assign({}, form); - const errorField = Object.assign({}, errors); - if (errorField[name]) { - errorField[name] = null; - setErrors(errorField); - } - fieldValue[name] = value; - setForm(fieldValue); - }; - - const validateData = () => { - let hasError = false; - const err = Object.assign({}, errors); - Object.keys(form).forEach((key) => { - if (typeof (form[key]) === 'string') { - if (!form[key].match(/\w/)) { - hasError = true; - err[key] = t("field_request"); - } - } - if (!form[key]) { - hasError = true; - err[key] = t("field_request"); - } + const handleChange = (e: any) => { + const { value, name } = e.target; + const fieldValue = Object.assign({}, form); + const errorField = Object.assign({}, errors); + if (errorField[name]) { + errorField[name] = null; + setErrors(errorField); + } + fieldValue[name] = value; + setForm(fieldValue); + }; - }); - if (hasError) { - setErrors(err); - return false; + const validateData = () => { + let hasError = false; + const err = Object.assign({}, errors); + Object.keys(form).forEach((key) => { + if (typeof form[key] === "string") { + if (!form[key].match(/\w/)) { + hasError = true; + err[key] = t("field_request"); } - return form; - }; + } + if (!form[key]) { + hasError = true; + err[key] = t("field_request"); + } + }); + if (hasError) { + setErrors(err); + return false; + } + return form; + }; - const handleSubmit = (e: any) => { - e.preventDefault(); - const valid = validateData(); - if (valid) { - setShowLoader(true) - setDisableBtn(true); - dispatch(postForgotPassword(valid)).then((resp: any) => { - setShowLoader(false) - const res = resp && resp.data; - if (res && res.status === 'OK') { - Notification.Success({ - msg: t("password_sent") - }); - } else if (res && res.data) { - setErrors(res.data); - } else { - Notification.Error({ - msg: t("something_wrong") - }); - } - setDisableBtn(false); - }); + const handleSubmit = (e: any) => { + e.preventDefault(); + const valid = validateData(); + if (valid) { + setShowLoader(true); + setDisableBtn(true); + dispatch(postForgotPassword(valid)).then((resp: any) => { + setShowLoader(false); + const res = resp && resp.data; + if (res && res.status === "OK") { + Notification.Success({ + msg: t("password_sent"), + }); + } else if (res && res.data) { + setErrors(res.data); + } else { + Notification.Error({ + msg: t("something_wrong"), + }); } - }; - if (showLoader) { - return ; + setDisableBtn(false); + }); } - return ( -
-
-
{ - handleSubmit(e); - }}> -
- {t("forget_password")} -
- - {t("forget_password_instruction")} - - + }; + if (showLoader) { + return ; + } + return ( +
+
+ { + handleSubmit(e); + }} + > +
+ {t("forget_password")} +
+ + {t("forget_password_instruction")} + + - - - - - {t("already_a_member")} {t("login")} - - -
-
- ); + + + + + {t("already_a_member")} {t("login")} + + +
+
+ ); }; -export const ForgotPassword = withTranslation()(ForgotPasswordPage) \ No newline at end of file +export const ForgotPassword = withTranslation()(ForgotPasswordPage); diff --git a/src/Components/Auth/Register.tsx b/src/Components/Auth/Register.tsx index 71d0f058709..6462ca0f4c2 100644 --- a/src/Components/Auth/Register.tsx +++ b/src/Components/Auth/Register.tsx @@ -1,17 +1,26 @@ -import loadable from '@loadable/component'; -import { Button, Card, CardActions, CardContent, FormControl, Grid, InputLabel, MenuItem, Select } from "@material-ui/core"; +import loadable from "@loadable/component"; +import { + Button, + Card, + CardActions, + CardContent, + FormControl, + Grid, + InputLabel, + MenuItem, + Select, +} from "@material-ui/core"; import { makeStyles, Theme } from "@material-ui/core/styles"; -import { parsePhoneNumberFromString } from 'libphonenumber-js'; +import { parsePhoneNumberFromString } from "libphonenumber-js"; import React, { useState } from "react"; import ReCaptcha from "react-google-recaptcha"; -import { withTranslation } from 'react-i18next'; +import { withTranslation } from "react-i18next"; import { useDispatch } from "react-redux"; import { DISTRICT_CHOICES, GENDER_TYPES } from "../../Common/constants"; import { validateEmailAddress } from "../../Common/validation"; import { signupUser } from "../../Redux/actions"; import { PhoneNumberField, TextInputField } from "../Common/HelperInputFields"; -const PageTitle = loadable( () => import("../Common/PageTitle")); - +const PageTitle = loadable(() => import("../Common/PageTitle")); const optionalFields = [ "first_name", @@ -26,16 +35,16 @@ const optionalFields = [ const useStyles = makeStyles((theme: Theme) => ({ formTop: { marginTop: "80px", - marginBottom: "70px" + marginBottom: "70px", }, pdLogo: { height: "345px", - border: "solid 3px white" + border: "solid 3px white", }, cardActions: { padding: 0, - paddingTop: 16 - } + paddingTop: 16, + }, })); const RegisterPage = (props: any) => { @@ -59,7 +68,7 @@ const RegisterPage = (props: any) => { const [errors, setErrors] = useState(initErr); const [isCaptchaEnabled, setCaptcha] = useState(false); const { t } = props; - const captchaKey = '6LdvxuQUAAAAADDWVflgBqyHGfq-xmvNJaToM0pN'; + const captchaKey = "6LdvxuQUAAAAADDWVflgBqyHGfq-xmvNJaToM0pN"; const validateForm = () => { const oldError: any = {}; @@ -122,7 +131,9 @@ const RegisterPage = (props: any) => { if (validForm) { const data = { ...form, - phone_number: parsePhoneNumberFromString(form.phone_number)?.format('E.164'), + phone_number: parsePhoneNumberFromString(form.phone_number)?.format( + "E.164" + ), }; dispatch(signupUser(data)).then((res: any) => { if (res.status === 201) { @@ -167,7 +178,7 @@ const RegisterPage = (props: any) => { -
handleSubmit(e)}> + handleSubmit(e)}> { handleValueChange(value, 'phone_number')} + onChange={(value: any) => + handleValueChange(value, "phone_number") + } errors={errors.phone_number} /> @@ -243,7 +256,7 @@ const RegisterPage = (props: any) => { None - {DISTRICT_CHOICES.map(district => { + {DISTRICT_CHOICES.map((district) => { return ( { None - {GENDER_TYPES.map(gender => { + {GENDER_TYPES.map((gender) => { return ( {gender.text} @@ -304,7 +317,7 @@ const RegisterPage = (props: any) => { placeholder="" variant="outlined" margin="dense" - autoComplete='new-password' + autoComplete="new-password" value={form.password} onChange={handleChange} errors={errors.password} @@ -316,7 +329,7 @@ const RegisterPage = (props: any) => { placeholder="" variant="outlined" margin="dense" - autoComplete='new-password' + autoComplete="new-password" value={form.c_password} onChange={handleChange} errors={errors.c_password} @@ -340,7 +353,7 @@ const RegisterPage = (props: any) => { color="primary" variant="contained" type="submit" - onClick={e => handleSubmit(e)} + onClick={(e) => handleSubmit(e)} > {t("register_hospital")} @@ -356,4 +369,4 @@ const RegisterPage = (props: any) => { ); }; -export const Register = withTranslation()(RegisterPage); \ No newline at end of file +export const Register = withTranslation()(RegisterPage); diff --git a/src/Components/Auth/ResetPassword.tsx b/src/Components/Auth/ResetPassword.tsx index 55f0d0573d5..e3a943ad05c 100644 --- a/src/Components/Auth/ResetPassword.tsx +++ b/src/Components/Auth/ResetPassword.tsx @@ -1,174 +1,184 @@ -import React, { useState } from 'react'; -import { Typography, Grid, Card, CardHeader, CardContent, CardActions, Button } from '@material-ui/core'; -import { TextInputField, ErrorHelperText } from '../Common/HelperInputFields'; -import { useDispatch } from 'react-redux'; +import React, { useState } from "react"; +import { + Typography, + Grid, + Card, + CardHeader, + CardContent, + CardActions, + Button, +} from "@material-ui/core"; +import { TextInputField, ErrorHelperText } from "../Common/HelperInputFields"; +import { useDispatch } from "react-redux"; import * as Notification from "../../Utils/Notifications.js"; -import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'; -import ExpansionPanel from '@material-ui/core/ExpansionPanel'; -import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; -import {postResetPassword} from "../../Redux/actions"; -import {navigate} from "raviger"; -import { withTranslation } from 'react-i18next'; +import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"; +import ExpansionPanel from "@material-ui/core/ExpansionPanel"; +import ExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails"; +import { postResetPassword } from "../../Redux/actions"; +import { navigate } from "raviger"; +import { withTranslation } from "react-i18next"; -const useStyles = makeStyles(theme => ({ - formTop:{ - marginTop: '100px', - } +const useStyles = makeStyles((theme) => ({ + formTop: { + marginTop: "100px", + }, })); const panelStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - width: '100%' - }, - heading: { - fontSize: theme.typography.pxToRem(15), - fontWeight: theme.typography.fontWeightRegular - } - }) + createStyles({ + root: { + width: "100%", + }, + heading: { + fontSize: theme.typography.pxToRem(15), + fontWeight: theme.typography.fontWeightRegular, + }, + }) ); - const ResetPasswordPage = (props: any) => { - const classes = useStyles(); - const panel = panelStyles(); + const classes = useStyles(); + const panel = panelStyles(); - const dispatch: any = useDispatch(); - const initForm: any = { - password: '', - confirm: '' - }; + const dispatch: any = useDispatch(); + const initForm: any = { + password: "", + confirm: "", + }; - const initErr: any = {}; - const [ form, setForm ] = useState(initForm); - const [ errors, setErrors ] = useState(initErr); - const [passReg, setPassReg] = useState(0); - const { t } = props; - const handleChange = (e: any) => { - const { value, name } = e.target; - const fieldValue = Object.assign({}, form); - const errorField = Object.assign({}, errors); - if (errorField[name]) { - errorField[name] = null; - setErrors(errorField); - } - fieldValue[name] = value; - setPassReg(0) - setForm(fieldValue); - }; - - const validateData = () => { - let hasError = false; - const err = Object.assign({}, errors); - if (form.password !== form.confirm) { - hasError = true; - setPassReg(1) - err.confirm = t("password_mismatch") - } + const initErr: any = {}; + const [form, setForm] = useState(initForm); + const [errors, setErrors] = useState(initErr); + const [passReg, setPassReg] = useState(0); + const { t } = props; + const handleChange = (e: any) => { + const { value, name } = e.target; + const fieldValue = Object.assign({}, form); + const errorField = Object.assign({}, errors); + if (errorField[name]) { + errorField[name] = null; + setErrors(errorField); + } + fieldValue[name] = value; + setPassReg(0); + setForm(fieldValue); + }; - const regex = /^(?=.*[a-z]+)(?=.*[A-Z]+)(?=.*[0-9]+)(?=.*[!@#$%^&*]).{8,}$/; - if (!regex.test(form.password)) { - hasError = true; - err.password = t("invalid_password"); - } + const validateData = () => { + let hasError = false; + const err = Object.assign({}, errors); + if (form.password !== form.confirm) { + hasError = true; + setPassReg(1); + err.confirm = t("password_mismatch"); + } - Object.keys(form).forEach((key) => { - if (!form[key]) { - hasError = true; - err[key] = t("field_required"); - } - }); - if (hasError) { - setErrors(err); - return false; - } - return form; - }; + const regex = /^(?=.*[a-z]+)(?=.*[A-Z]+)(?=.*[0-9]+)(?=.*[!@#$%^&*]).{8,}$/; + if (!regex.test(form.password)) { + hasError = true; + err.password = t("invalid_password"); + } + Object.keys(form).forEach((key) => { + if (!form[key]) { + hasError = true; + err[key] = t("field_required"); + } + }); + if (hasError) { + setErrors(err); + return false; + } + return form; + }; - const handleSubmit = (e: any) => { - e.preventDefault(); - const valid = validateData(); - if (valid) { - valid.token = props.token; - dispatch(postResetPassword(valid)).then((resp: any) => { - const res = resp && resp.data; - if (res && res.status === 'OK') { - localStorage.removeItem('care_access_token'); - Notification.Success({ - msg: t("password_reset_success") - }); - navigate('/login'); - } else if (res && res.data) { - setErrors(res.data); - } else { - Notification.Error({ - msg: t("password_reset_failure") - }); - } - }); + const handleSubmit = (e: any) => { + e.preventDefault(); + const valid = validateData(); + if (valid) { + valid.token = props.token; + dispatch(postResetPassword(valid)).then((resp: any) => { + const res = resp && resp.data; + if (res && res.status === "OK") { + localStorage.removeItem("care_access_token"); + Notification.Success({ + msg: t("password_reset_success"), + }); + navigate("/login"); + } else if (res && res.data) { + setErrors(res.data); + } else { + Notification.Error({ + msg: t("password_reset_failure"), + }); } + }); } - return ( -
- - - - {handleSubmit(e)}}> - - - - { - passReg === 0 && -
- - - -
  • Minimum password length 8
  • -
  • Require at least one digit
  • -
  • Require at least one upper case
  • -
  • Require at least one lower case letter
  • -
  • Require at least one symbol
  • -
    -
    -
    -
    - } - - -
    + }; + return ( +
    + + + + { + handleSubmit(e); + }} + > + + + + {passReg === 0 && ( +
    + + + +
  • Minimum password length 8
  • +
  • Require at least one digit
  • +
  • Require at least one upper case
  • +
  • Require at least one lower case letter
  • +
  • Require at least one symbol
  • +
    +
    +
    +
    + )} + + +
    - - - - -
    -
    -
    -
    - ); -} -export const ResetPassword = withTranslation()(ResetPasswordPage) \ No newline at end of file + + + + +
    +
    +
    +
    + ); +}; +export const ResetPassword = withTranslation()(ResetPasswordPage); diff --git a/src/Components/Auth/index.tsx b/src/Components/Auth/index.tsx index 59dffff4c30..ecf93254104 100644 --- a/src/Components/Auth/index.tsx +++ b/src/Components/Auth/index.tsx @@ -1,4 +1,4 @@ -export {Login} from './Login'; -export {Register} from './Register'; -export {ResetPassword} from './ResetPassword'; -export {ForgotPassword} from './ForgetPassword'; +export { Login } from "./Login"; +export { Register } from "./Register"; +export { ResetPassword } from "./ResetPassword"; +export { ForgotPassword } from "./ForgetPassword"; diff --git a/src/Components/Common/AddCard.tsx b/src/Components/Common/AddCard.tsx index 64f7639338c..578bcf2eb19 100644 --- a/src/Components/Common/AddCard.tsx +++ b/src/Components/Common/AddCard.tsx @@ -1,45 +1,50 @@ -import React from 'react'; -import { Box, Card, Grid, Typography } from '@material-ui/core'; -import { makeStyles } from '@material-ui/core/styles'; +import React from "react"; +import { Box, Card, Grid, Typography } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; interface AddCardProps { - title: string; - onClick: any + title: string; + onClick: any; } -const useStyles = makeStyles(theme => ({ - card: { - background: '#ffffff', - border: 'dashed 1px #333', - cursor: 'pointer', - minHeight: '120px', - lineHeight: '120px', - }, - addPaper: { - padding: '25px', - height: 160, - background: '#FFFFFF', - }, - box: { - height:120 - } +const useStyles = makeStyles((theme) => ({ + card: { + background: "#ffffff", + border: "dashed 1px #333", + cursor: "pointer", + minHeight: "120px", + lineHeight: "120px", + }, + addPaper: { + padding: "25px", + height: 160, + background: "#FFFFFF", + }, + box: { + height: 120, + }, })); - const AddCard = (props: AddCardProps) => { - const { title, onClick } = props; - const classes = useStyles(); - return ( - - onClick()}> - - - {title} - - - - - ) + const { title, onClick } = props; + const classes = useStyles(); + return ( + + onClick()} + > + + {title} + + + + ); }; -export default AddCard; \ No newline at end of file +export default AddCard; diff --git a/src/Components/Common/AlertDialog.tsx b/src/Components/Common/AlertDialog.tsx index 6dbfc662ad1..2792e5916b1 100644 --- a/src/Components/Common/AlertDialog.tsx +++ b/src/Components/Common/AlertDialog.tsx @@ -1,36 +1,37 @@ -import React from 'react'; -import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@material-ui/core'; +import React from "react"; +import { + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@material-ui/core"; interface Props { - title: string; - message: string; - handleClose: () => void; - handleCancel?: () => void; + title: string; + message: string; + handleClose: () => void; + handleCancel?: () => void; } const AlertDialog = (props: Props) => { - const { title, message, handleClose, handleCancel } = props; - return ( - - {title || ''} - - - {message} - - - - {handleCancel && ( - - )} - - - - ); + const { title, message, handleClose, handleCancel } = props; + return ( + + {title || ""} + + + {message} + + + + {handleCancel && } + + + + ); }; export default AlertDialog; diff --git a/src/Components/Common/ConfirmDialog.tsx b/src/Components/Common/ConfirmDialog.tsx index e98cda53c26..955c7d4c7b4 100644 --- a/src/Components/Common/ConfirmDialog.tsx +++ b/src/Components/Common/ConfirmDialog.tsx @@ -1,42 +1,40 @@ -import React from 'react'; +import React from "react"; import { - Dialog, - DialogTitle, - DialogContent, - DialogContentText, - DialogActions, - Button -} from '@material-ui/core'; + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, + Button, +} from "@material-ui/core"; interface ConfirmDialogProps { - title: string; - message: string; - handleCancel: () => void; - handleOk: () => void; + title: string; + message: string; + handleCancel: () => void; + handleOk: () => void; } const ConfirmDialog = (props: ConfirmDialogProps) => { - const { title, message, handleCancel, handleOk } = props; - return ( - - {title || ''} - - - {message} - - - - - - - - ); -} + const { title, message, handleCancel, handleOk } = props; + return ( + + {title || ""} + + + {message} + + + + + + + + ); +}; export default ConfirmDialog; diff --git a/src/Components/Common/HelperInputFields.tsx b/src/Components/Common/HelperInputFields.tsx index 868725acab3..4d3f9b4a0f9 100644 --- a/src/Components/Common/HelperInputFields.tsx +++ b/src/Components/Common/HelperInputFields.tsx @@ -1,430 +1,545 @@ -import DateFnsUtils from '@date-io/date-fns'; -import { Checkbox, Chip, CircularProgress, FormControlLabel, FormControlLabelProps, Input, InputLabel, ListItemText, MenuItem, NativeSelect, Radio, Select, TextField, TextFieldProps } from '@material-ui/core'; -import Box from '@material-ui/core/Box'; -import FormControl from '@material-ui/core/FormControl'; -import { NativeSelectInputProps } from '@material-ui/core/NativeSelect/NativeSelectInput'; -import { SelectProps } from '@material-ui/core/Select'; -import Autocomplete from '@material-ui/lab/Autocomplete'; -import { DatePickerProps, KeyboardDatePicker, KeyboardDateTimePicker, KeyboardTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers'; -import { MaterialUiPickersDate } from '@material-ui/pickers/typings/date'; -import { debounce } from 'lodash'; -import React, { ChangeEvent } from 'react'; -import PhoneInput, { ICountryData } from 'react-phone-input-2'; -import 'react-phone-input-2/lib/high-res.css'; +import DateFnsUtils from "@date-io/date-fns"; +import { + Checkbox, + Chip, + CircularProgress, + FormControlLabel, + FormControlLabelProps, + Input, + InputLabel, + ListItemText, + MenuItem, + NativeSelect, + Radio, + Select, + TextField, + TextFieldProps, +} from "@material-ui/core"; +import Box from "@material-ui/core/Box"; +import FormControl from "@material-ui/core/FormControl"; +import { NativeSelectInputProps } from "@material-ui/core/NativeSelect/NativeSelectInput"; +import { SelectProps } from "@material-ui/core/Select"; +import Autocomplete from "@material-ui/lab/Autocomplete"; +import { + DatePickerProps, + KeyboardDatePicker, + KeyboardDateTimePicker, + KeyboardTimePicker, + MuiPickersUtilsProvider, +} from "@material-ui/pickers"; +import { MaterialUiPickersDate } from "@material-ui/pickers/typings/date"; +import { debounce } from "lodash"; +import React, { ChangeEvent } from "react"; +import PhoneInput, { ICountryData } from "react-phone-input-2"; +import "react-phone-input-2/lib/high-res.css"; -export interface DefaultSelectInputProps extends Omit { - options: Array; - optionArray?: boolean; - placeholder?: string; - label?: string; - margin?: 'dense' | 'none'; - optionKey?: string, - optionValue?: string, - onChange?: (e: any, child?: any) => void, - name: string; - labelId?: string; - errors?: string; - showEmpty?: boolean; +export interface DefaultSelectInputProps extends Omit { + options: Array; + optionArray?: boolean; + placeholder?: string; + label?: string; + margin?: "dense" | "none"; + optionKey?: string; + optionValue?: string; + onChange?: (e: any, child?: any) => void; + name: string; + labelId?: string; + errors?: string; + showEmpty?: boolean; } -export interface MultiSelectInputProps extends Omit { - options: Array; - optionArray?: boolean; - placeholder?: string; - label?: string; - margin?: 'dense' | 'none'; - optionKey?: string, - optionValue?: string, - onChange?: (e: any, child?: any) => void, +export interface MultiSelectInputProps extends Omit { + options: Array; + optionArray?: boolean; + placeholder?: string; + label?: string; + margin?: "dense" | "none"; + optionKey?: string; + optionValue?: string; + onChange?: (e: any, child?: any) => void; } export interface DefaultNativeSelectInputProps extends NativeSelectInputProps { - options: Array<{ id: string | number, text?: string }>, - placeholder?: string; - label?: string; - optionKey?: string, - optionValue?: string, + options: Array<{ id: string | number; text?: string }>; + placeholder?: string; + label?: string; + optionKey?: string; + optionValue?: string; } // Type Declarations -type TextFieldPropsExtended = TextFieldProps & { errors: string } -type Option = { text: string; score: number; } +type TextFieldPropsExtended = TextFieldProps & { errors: string }; +type Option = { text: string; score: number }; interface InputProps { - options: Array