Skip to content

Commit

Permalink
Merge branch 'ohcnetwork:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jash2606 authored Oct 3, 2024
2 parents 2ba28fc + ae6856d commit 33d1878
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 66 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/users_spec/UsersCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe("User Creation", () => {
userCreationPage.setInputDate("date_of_birth", "date-input", "25081999");
userCreationPage.selectDropdownOption("user_type", "Doctor");
userCreationPage.typeIntoElementById("c_password", "Test@123");
userCreationPage.typeIntoElementById("doctor_qualification", "MBBS");
userCreationPage.typeIntoElementById("qualification", "MBBS");
userCreationPage.typeIntoElementById("doctor_experience_commenced_on", "2");
userCreationPage.typeIntoElementById(
"doctor_medical_council_registration",
Expand All @@ -172,7 +172,7 @@ describe("User Creation", () => {
"home_facility",
"Dummy Shifting Center",
);
userCreationPage.verifyElementContainsText("doctor-qualification", "MBBS");
userCreationPage.verifyElementContainsText("qualification", "MBBS");
userCreationPage.verifyElementContainsText("doctor-experience", "2");
userCreationPage.verifyElementContainsText(
"medical-council-registration",
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/users_spec/UsersProfile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Manage User Profile", () => {
const email = "test@example.com";
const phone = "+918899887788";
const workinghours = "8";
const doctorQualification = "MBBS";
const qualification = "MBBS";
const doctorYoE = "10";
const medicalCouncilRegistration = "1234567890";

Expand Down Expand Up @@ -40,7 +40,7 @@ describe("Manage User Profile", () => {
userProfilePage.typePhone(phone);
userProfilePage.typeWhatsApp(phone);
userProfilePage.typeWorkingHours(workinghours);
userProfilePage.typeDoctorQualification(doctorQualification);
userProfilePage.typeQualification(qualification);
userProfilePage.typeDoctorYoE(doctorYoE);
userProfilePage.typeMedicalCouncilRegistration(medicalCouncilRegistration);

Expand Down
4 changes: 2 additions & 2 deletions cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default class UserProfilePage {
cy.get("#weekly_working_hours").click().clear().type(workinghours);
}

typeDoctorQualification = (doctorQualification: string) => {
cy.get("#doctor_qualification").click().clear().type(doctorQualification);
typeQualification = (qualification: string) => {
cy.get("#qualification").click().clear().type(qualification);
};

typeDoctorYoE = (doctorYoE: string) => {
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"browserslist-useragent-regexp": "^4.1.3",
"cross-env": "^7.0.3",
"dayjs": "^1.11.11",
"echarts": "^5.5.0",
"echarts": "^5.5.1",
"echarts-for-react": "^3.0.2",
"events": "^3.3.0",
"hi-profiles": "^1.0.6",
Expand All @@ -75,7 +75,7 @@
"react-dnd-scrolling": "^1.3.8",
"react-dom": "18.3.1",
"react-google-recaptcha": "^3.1.0",
"react-i18next": "^13.0.1",
"react-i18next": "^15.0.2",
"react-infinite-scroll-component": "^6.1.0",
"react-markdown": "^8.0.7",
"react-pdf": "^9.1.0",
Expand Down
40 changes: 32 additions & 8 deletions src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export default function ManageUsers() {
};

let userList: any[] = [];

userListData?.results &&
userListData.results.length &&
(userList = userListData.results.map((user: any, idx) => {
Expand Down Expand Up @@ -283,15 +282,17 @@ export default function ManageUsers() {
<>
<div className="col-span-1">
<UserDetails
id="doctor-qualification"
title="Qualification"
id="qualification"
title={t("qualification")}
>
{user.doctor_qualification ? (
{user.qualification ? (
<span className="font-semibold">
{user.doctor_qualification}
{user.qualification}
</span>
) : (
<span className="text-secondary-600">Unknown</span>
<span className="text-secondary-600">
{t("unknown")}
</span>
)}
</UserDetails>
</div>
Expand All @@ -307,7 +308,9 @@ export default function ManageUsers() {
years
</span>
) : (
<span className="text-secondary-600">Unknown</span>
<span className="text-secondary-600">
{t("unknown")}
</span>
)}
</UserDetails>
</div>
Expand All @@ -321,7 +324,9 @@ export default function ManageUsers() {
{user.doctor_medical_council_registration}
</span>
) : (
<span className="text-secondary-600">Unknown</span>
<span className="text-secondary-600">
{t("unknown")}
</span>
)}
</UserDetails>
</div>
Expand All @@ -335,11 +340,30 @@ export default function ManageUsers() {
</div>
</UserDetails>
)}

<div
className={`${
isExtremeSmallScreen ? "flex flex-wrap" : "grid grid-cols-2"
}`}
>
{user.user_type === "Nurse" && (
<div className="row-span-1">
<UserDetails
id="qualification"
title={t("qualification")}
>
{user.qualification ? (
<span className="font-semibold">
{user.qualification}
</span>
) : (
<span className="text-secondary-600">
{t("unknown")}
</span>
)}
</UserDetails>
</div>
)}
{user.created_by && (
<div className="col-span-1">
<UserDetails id="created_by" title="Created by">
Expand Down
38 changes: 24 additions & 14 deletions src/Components/Users/UserAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField";
import { useTranslation } from "react-i18next";

const Loading = lazy(() => import("../Common/Loading"));

interface UserProps {
userId?: number;
}
Expand Down Expand Up @@ -72,7 +71,7 @@ type UserForm = {
state: number;
district: number;
local_body: number;
doctor_qualification: string | undefined;
qualification: string | undefined;
doctor_experience_commenced_on: string | undefined;
doctor_medical_council_registration: string | undefined;
};
Expand All @@ -95,7 +94,7 @@ const initForm: UserForm = {
state: 0,
district: 0,
local_body: 0,
doctor_qualification: undefined,
qualification: undefined,
doctor_experience_commenced_on: undefined,
doctor_medical_council_registration: undefined,
};
Expand Down Expand Up @@ -372,7 +371,16 @@ export const UserAdd = (props: UserProps) => {
invalidForm = true;
}
return;
case "doctor_qualification":
case "qualification":
if (
(state.form.user_type === "Doctor" ||
state.form.user_type === "Nurse") &&
!state.form[field]
) {
errors[field] = t("field_required");
invalidForm = true;
}
return;
case "doctor_medical_council_registration":
if (state.form.user_type === "Doctor" && !state.form[field]) {
errors[field] = t("field_required");
Expand Down Expand Up @@ -553,9 +561,9 @@ export const UserAdd = (props: UserProps) => {
: state.form.alt_phone_number,
) ?? "",
date_of_birth: dateQueryString(state.form.date_of_birth),
doctor_qualification:
state.form.user_type === "Doctor"
? state.form.doctor_qualification
qualification:
state.form.user_type === "Doctor" || state.form.user_type == "Nurse"
? state.form.qualification
: undefined,
doctor_experience_commenced_on:
state.form.user_type === "Doctor"
Expand Down Expand Up @@ -650,15 +658,17 @@ export const UserAdd = (props: UserProps) => {
optionValue={(o) => o.id}
/>

{(state.form.user_type === "Doctor" ||
state.form.user_type === "Nurse") && (
<TextFormField
{...field("qualification")}
required
label={t("qualification")}
placeholder={t("qualification")}
/>
)}
{state.form.user_type === "Doctor" && (
<>
<TextFormField
{...field("doctor_qualification")}
required
label="Qualification"
placeholder="Qualification of the Doctor"
/>

<TextFormField
{...field("doctor_experience_commenced_on")}
required
Expand Down
Loading

0 comments on commit 33d1878

Please sign in to comment.