Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jan 15, 2024
2 parents ef90e36 + 51b02c2 commit 135f5a9
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 35 deletions.
4 changes: 3 additions & 1 deletion src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,8 @@ export const USER_TYPES_MAP = {
StaffReadOnly: "Staff",
Staff: "Staff",
Doctor: "Doctor",
Nurse: "Nurse",
NurseReadOnly: "Nurse",
WardAdmin: "Ward Admin",
LocalBodyAdmin: "Local Body Admin",
DistrictLabAdmin: "District Lab Admin",
Expand All @@ -1037,7 +1039,7 @@ export const USER_TYPES_MAP = {
StateReadOnlyAdmin: "State Admin",
StateAdmin: "State Admin",
RemoteSpecialist: "Remote Specialist",
};
} as const;

export const AREACODES: Record<string, string[]> = {
CA: [
Expand Down
10 changes: 5 additions & 5 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getDate = (value: any) =>

function AssetFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [facility, setFacility] = useState<FacilityModel>({ name: "" });
const [facility, setFacility] = useState<FacilityModel | null>(null);
const [asset_type, setAssetType] = useState<string>(
filter.asset_type ? filter.asset_type : ""
);
Expand Down Expand Up @@ -51,7 +51,7 @@ function AssetFilter(props: any) {
setLocationId(
facility?.id === qParams.facility ? qParams.location ?? "" : ""
);
}, [facility.id, qParams.facility, qParams.location]);
}, [facility?.id, qParams.facility, qParams.location]);

const clearFilter = useCallback(() => {
removeFilters([
Expand Down Expand Up @@ -81,8 +81,8 @@ function AssetFilter(props: any) {
onChange(data);
};

const handleFacilitySelect = (selected: FacilityModel) => {
setFacility(selected ? selected : facility);
const handleFacilitySelect = (selected: FacilityModel | null) => {
setFacility(selected);
handleLocationSelect("");
};
const handleLocationSelect = (selectedId: string) => {
Expand All @@ -107,7 +107,7 @@ function AssetFilter(props: any) {
<FacilitySelect
name="Facilities"
setSelected={(selected) =>
handleFacilitySelect(selected as FacilityModel)
handleFacilitySelect(selected as FacilityModel | null)
}
selected={facility}
errors=""
Expand Down
14 changes: 8 additions & 6 deletions src/Components/Facility/FacilityUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ export default function FacilityUsers(props: any) {
</span>
</div>
</div>
<div className="mt-2 text-2xl font-bold capitalize">
<div
id="name"
className="mt-2 flex gap-3 text-2xl font-bold capitalize"
>
{`${user.first_name} ${user.last_name}`}

{user.last_login && isUserOnline(user) ? (
Expand All @@ -306,13 +309,12 @@ export default function FacilityUsers(props: any) {
></i>
) : null}
{showUserDelete(authUser, user) && (
<button
type="button"
className="focus:ring-blue m-3 w-20 self-end rounded-md border border-red-500 bg-white px-3 py-2 text-center text-sm font-medium leading-4 text-red-700 transition duration-150 ease-in-out hover:text-red-500 hover:shadow focus:border-red-300 focus:outline-none active:bg-gray-50 active:text-red-800"
<div
className="w-8 cursor-pointer rounded-lg bg-red-50 text-xl text-red-600 hover:bg-red-50 hover:text-red-700"
onClick={() => handleDelete(user)}
>
Delete
</button>
<CareIcon icon="l-trash" className="ml-[5px]" />
</div>
)}
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TestRow = ({ data, i, onChange, showForm, value, isChanged }: any) => {
<td className="whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-900">
{data?.investigation_object?.name || "---"}
</td>
<td className="whitespace-nowrap px-6 py-4 text-right text-sm text-gray-700">
<td className="whitespace-nowrap px-6 py-4 text-sm text-gray-700">
{showForm ? (
data?.investigation_object?.investigation_type === "Choice" ? (
<SelectFormField
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AssetData, AssetLocationType } from "../Assets/AssetTypes";
import { UserBareMinimum } from "../Users/models";
import { RouteToFacility } from "../Common/RouteToFacilitySelect";
import { ConsultationDiagnosis, CreateDiagnosis } from "../Diagnosis/types";
import { ConsultationSuggestionValue } from "../../Common/constants";
import { ConsultationSuggestionValue, UserRole } from "../../Common/constants";

export interface LocalBodyModel {
id: number;
Expand Down Expand Up @@ -494,7 +494,7 @@ export interface PatientNotesModel {
note: string;
facility: BaseFacilityModel;
created_by_object: BaseUserModel;
user_type?: string;
user_type?: UserRole | "RemoteSpecialist";
created_date: string;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Components/Patient/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export const FileUpload = (props: FileUploadProps) => {

const handleClose = () => {
setDownloadURL("");
setPreviewImage(null);
setFileState({
...file_state,
open: false,
Expand Down Expand Up @@ -1212,6 +1213,7 @@ export const FileUpload = (props: FileUploadProps) => {
</ButtonV2>
<Submit
onClick={() => {
setPreviewImage(null);
setModalOpenForCamera(false);
}}
className="m-2"
Expand Down Expand Up @@ -1272,6 +1274,7 @@ export const FileUpload = (props: FileUploadProps) => {
<Submit
onClick={() => {
setModalOpenForCamera(false);
setPreviewImage(null);
}}
>
{t("submit")}
Expand Down
16 changes: 8 additions & 8 deletions src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ export default function ManageUsers() {
)}
</div>
</div>
<div id="name" className="mt-2 text-2xl font-bold capitalize">
<div
id="name"
className="mt-2 flex gap-3 text-2xl font-bold capitalize"
>
{`${user.first_name} ${user.last_name}`}

{user.last_login && cur_online ? (
Expand All @@ -228,15 +231,12 @@ export default function ManageUsers() {
></i>
) : null}
{showUserDelete(authUser, user) && (
<ButtonV2
variant="danger"
ghost
border
className="float-right"
<div
className="w-8 cursor-pointer rounded-lg bg-red-50 text-xl text-red-600 hover:bg-red-50 hover:text-red-700"
onClick={() => handleDelete(user)}
>
Delete
</ButtonV2>
<CareIcon icon="l-trash" className="ml-[5px]" />
</div>
)}
</div>

Expand Down
23 changes: 12 additions & 11 deletions src/Components/Users/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type EditForm = {
doctor_qualification: string | undefined;
doctor_experience_commenced_on: number | string | undefined;
doctor_medical_council_registration: string | undefined;
weekly_working_hours: string | undefined;
weekly_working_hours: string | null;
};
type ErrorForm = {
firstName: string;
Expand Down Expand Up @@ -253,13 +253,11 @@ export default function UserProfile() {
}
return;
case "weekly_working_hours":
if (!states.form[field]) {
errors[field] = "This field is required";
invalidForm = true;
} else if (
Number(states.form[field]) < 0 ||
Number(states.form[field]) > 168 ||
!/^\d+$/.test(states.form[field] ?? "")
if (
states.form[field] &&
(Number(states.form[field]) < 0 ||
Number(states.form[field]) > 168 ||
!/^\d+$/.test(states.form[field] ?? ""))
) {
errors[field] =
"Average weekly working hours must be a number between 0 and 168";
Expand Down Expand Up @@ -331,7 +329,11 @@ export default function UserProfile() {
states.form.user_type === "Doctor"
? states.form.doctor_medical_council_registration
: undefined,
weekly_working_hours: states.form.weekly_working_hours,
weekly_working_hours:
states.form.weekly_working_hours &&
states.form.weekly_working_hours !== ""
? states.form.weekly_working_hours
: null,
};
const { res } = await request(routes.partialUpdateUser, {
pathParams: { username: authUser.username },
Expand Down Expand Up @@ -588,7 +590,7 @@ export default function UserProfile() {
Average weekly working hours
</dt>
<dd className="mt-1 text-sm leading-5 text-gray-900">
{userData?.weekly_working_hours || "-"}
{userData?.weekly_working_hours ?? "-"}
</dd>
</div>
<div
Expand Down Expand Up @@ -707,7 +709,6 @@ export default function UserProfile() {
)}
<TextFormField
{...fieldProps("weekly_working_hours")}
required
label="Average weekly working hours"
className="col-span-6 sm:col-span-3"
type="number"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Users/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type UserModel = UserBareMinimum & {
doctor_qualification?: string;
doctor_experience_commenced_on?: string;
doctor_medical_council_registration?: string;
weekly_working_hours?: string;
weekly_working_hours?: string | null;
};

export interface SkillObjectModel {
Expand Down

0 comments on commit 135f5a9

Please sign in to comment.