Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Qualification field for nurse user type #8694

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
38 changes: 28 additions & 10 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 @@ -282,16 +281,15 @@ export default function ManageUsers() {
{user.user_type === "Doctor" && (
<>
<div className="col-span-1">
<UserDetails
id="doctor-qualification"
title="Qualification"
>
{user.doctor_qualification ? (
<UserDetails id="qualification" title="Qualification">
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
{user.qualification ? (
<span className="font-semibold">
{user.doctor_qualification}
{user.qualification}
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
</span>
) : (
<span className="text-secondary-600">Unknown</span>
<span className="text-secondary-600">
{t("unknown")}
</span>
)}
</UserDetails>
</div>
Expand All @@ -307,7 +305,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 +321,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 +337,27 @@ 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="Qualification">
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
{user.qualification ? (
<span className="font-semibold">
{user.qualification}
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
</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="Qualification"
placeholder="Qualification"
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
/>
)}
{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
44 changes: 29 additions & 15 deletions src/Components/Users/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type EditForm = {
phoneNumber: string;
altPhoneNumber: string;
user_type: string | undefined;
doctor_qualification: string | undefined;
qualification: string | undefined;
doctor_experience_commenced_on: number | string | undefined;
doctor_medical_council_registration: string | undefined;
weekly_working_hours: string | null | undefined;
Expand All @@ -54,7 +54,7 @@ type ErrorForm = {
phoneNumber: string;
altPhoneNumber: string;
user_type: string | undefined;
doctor_qualification: string | undefined;
qualification: string | undefined;
doctor_experience_commenced_on: number | string | undefined;
doctor_medical_council_registration: string | undefined;
weekly_working_hours: string | undefined;
Expand All @@ -77,7 +77,7 @@ const initForm: EditForm = {
phoneNumber: "",
altPhoneNumber: "",
user_type: "",
doctor_qualification: undefined,
qualification: undefined,
doctor_experience_commenced_on: undefined,
doctor_medical_council_registration: undefined,
weekly_working_hours: undefined,
Expand Down Expand Up @@ -149,6 +149,7 @@ export default function UserProfile() {
} = useQuery(routes.currentUser, {
onResponse: (result) => {
if (!result || !result.res || !result.data) return;

const formData: EditForm = {
firstName: result.data.first_name,
lastName: result.data.last_name,
Expand All @@ -159,7 +160,7 @@ export default function UserProfile() {
phoneNumber: result.data.phone_number?.toString() || "",
altPhoneNumber: result.data.alt_phone_number?.toString() || "",
user_type: result.data.user_type,
doctor_qualification: result.data.doctor_qualification,
qualification: result.data.qualification,
doctor_experience_commenced_on: dayjs().diff(
dayjs(result.data.doctor_experience_commenced_on),
"years",
Expand Down Expand Up @@ -277,7 +278,16 @@ export default function UserProfile() {
invalidForm = true;
}
return;
case "doctor_qualification":
case "qualification":
if (
(states.form.user_type === "Doctor" ||
states.form.user_type === "Nurse") &&
!states.form[field]
) {
errors[field] = t("field_required");
invalidForm = true;
}
return;
case "doctor_medical_council_registration":
if (states.form.user_type === "Doctor" && !states.form[field]) {
errors[field] = t("field_required");
Expand Down Expand Up @@ -344,9 +354,10 @@ export default function UserProfile() {
alt_phone_number: parsePhoneNumber(states.form.altPhoneNumber) ?? "",
gender: states.form.gender,
date_of_birth: dateQueryString(states.form.date_of_birth),
doctor_qualification:
states.form.user_type === "Doctor"
? states.form.doctor_qualification
qualification:
states.form.user_type === "Doctor" ||
states.form.user_type === "Nurse"
? states.form.qualification
: undefined,
doctor_experience_commenced_on:
states.form.user_type === "Doctor"
Expand Down Expand Up @@ -727,15 +738,18 @@ export default function UserProfile() {
required
type="email"
/>
{(states.form.user_type === "Doctor" ||
states.form.user_type === "Nurse") && (
<TextFormField
{...fieldProps("qualification")}
required
className="col-span-6 sm:col-span-3"
label="Qualification"
placeholder="Qualification"
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
/>
)}
{states.form.user_type === "Doctor" && (
<>
<TextFormField
{...fieldProps("doctor_qualification")}
required
className="col-span-6 sm:col-span-3"
label="Qualification"
placeholder="Doctor's Qualification"
/>
<TextFormField
{...fieldProps("doctor_experience_commenced_on")}
required
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Users/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type UserModel = UserBareMinimum & {
local_body_object?: LocalBodyModel;
district_object?: DistrictModel;
state_object?: StateModel;
doctor_qualification?: string;
qualification?: string;
doctor_experience_commenced_on?: string;
doctor_medical_council_registration?: string;
weekly_working_hours?: string | null;
Expand Down Expand Up @@ -82,7 +82,7 @@ export interface UserAssignedModel extends UserBareMinimum {
verified?: boolean;
home_facility?: string;
home_facility_object?: HomeFacilityObjectModel;
doctor_qualification?: string;
qualification?: string;
doctor_experience_commenced_on?: Date;
doctor_medical_council_registration?: string;
weekly_working_hours?: string;
Expand Down
Loading