diff --git a/src/Components/ABDM/ABDMFacilityRecords.tsx b/src/Components/ABDM/ABDMFacilityRecords.tsx
index eadf39b8db7..cd21d269536 100644
--- a/src/Components/ABDM/ABDMFacilityRecords.tsx
+++ b/src/Components/ABDM/ABDMFacilityRecords.tsx
@@ -86,8 +86,8 @@ export default function ABDMFacilityRecords({ facilityId }: IProps) {
consent.expiry,
) < new Date()
? "EXPIRED"
- : consent.consent_artefacts?.[0]?.status ??
- consent.status}
+ : (consent.consent_artefacts?.[0]?.status ??
+ consent.status)}
@@ -102,13 +102,6 @@ export default function ABDMFacilityRecords({ facilityId }: IProps) {
: "-"}
|
- {/*
- {`${consent.requester?.first_name} ${consent.requester?.last_name}`.trim()}
-
- ({consent.requester.username})
-
- | */}
-
{formatDateTime(
consent.consent_artefacts?.[0]?.from_time ??
diff --git a/src/Components/ABDM/ABDMRecordsTab.tsx b/src/Components/ABDM/ABDMRecordsTab.tsx
index d828335cd0d..37ae1a629db 100644
--- a/src/Components/ABDM/ABDMRecordsTab.tsx
+++ b/src/Components/ABDM/ABDMRecordsTab.tsx
@@ -5,7 +5,7 @@ import CareIcon from "../../CAREUI/icons/CareIcon";
import ButtonV2 from "../Common/components/ButtonV2";
import * as Notification from "../../Utils/Notifications.js";
import Loading from "../Common/Loading";
-import { classNames } from "../../Utils/utils";
+import { classNames, formatName } from "../../Utils/utils";
import { Link } from "raviger";
import routes from "../../Redux/api";
import request from "../../Utils/request/request";
@@ -75,7 +75,7 @@ function ConsentRequestCard({ consent }: IConsentRequestCardProps) {
}
- {consent.requester.first_name} {consent.requester.last_name}
+ {formatName(consent.requester)}
diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx
index a9bb6eb78ea..469d1556fb5 100644
--- a/src/Components/Assets/AssetManage.tsx
+++ b/src/Components/Assets/AssetManage.tsx
@@ -10,7 +10,7 @@ import Pagination from "../Common/Pagination";
import { navigate } from "raviger";
import QRCode from "qrcode.react";
import AssetWarrantyCard from "./AssetWarrantyCard";
-import { formatDate, formatDateTime } from "../../Utils/utils";
+import { formatDate, formatDateTime, formatName } from "../../Utils/utils";
import Chip from "../../CAREUI/display/Chip";
import CareIcon from "../../CAREUI/icons/CareIcon";
import ButtonV2 from "../Common/components/ButtonV2";
@@ -148,8 +148,7 @@ const AssetManage = (props: AssetManageProps) => {
|
- {transaction.performed_by.first_name}{" "}
- {transaction.performed_by.last_name}
+ {formatName(transaction.performed_by)}
|
diff --git a/src/Components/Common/RelativeDateUserMention.tsx b/src/Components/Common/RelativeDateUserMention.tsx
index 70eadc5b7ed..541c38c3537 100644
--- a/src/Components/Common/RelativeDateUserMention.tsx
+++ b/src/Components/Common/RelativeDateUserMention.tsx
@@ -1,5 +1,5 @@
import CareIcon from "../../CAREUI/icons/CareIcon";
-import { formatDateTime, relativeDate } from "../../Utils/utils";
+import { formatDateTime, formatName, relativeDate } from "../../Utils/utils";
import { PerformedByModel } from "../HCX/misc";
function RelativeDateUserMention(props: {
@@ -28,7 +28,7 @@ function RelativeDateUserMention(props: {
}`}
>
- {`${props.user.first_name} ${props.user.last_name}`}
+ {formatName(props.user)}
{`@${props.user.username}`}
{props.user.user_type}
diff --git a/src/Components/Common/UserAutocompleteFormField.tsx b/src/Components/Common/UserAutocompleteFormField.tsx
index 442eb0ae4fe..3ff6a3ae7c2 100644
--- a/src/Components/Common/UserAutocompleteFormField.tsx
+++ b/src/Components/Common/UserAutocompleteFormField.tsx
@@ -1,112 +1,158 @@
-import { useAsyncOptions } from "../../Common/hooks/useAsyncOptions";
-import { getFacilityUsers, getUserList } from "../../Redux/actions";
import { Autocomplete } from "../Form/FormFields/Autocomplete";
import FormField from "../Form/FormFields/FormField";
import {
FormFieldBaseProps,
useFormFieldPropsResolver,
} from "../Form/FormFields/Utils";
-import { UserModel } from "../Users/models";
-import { isUserOnline } from "../../Utils/utils";
+import {
+ classNames,
+ formatName,
+ isUserOnline,
+ mergeQueryOptions,
+} from "../../Utils/utils";
import { UserRole } from "../../Common/constants";
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
+import useQuery from "../../Utils/request/useQuery";
+import routes from "../../Redux/api";
+import { UserBareMinimum } from "../Users/models";
-type Props = FormFieldBaseProps & {
+type BaseProps = FormFieldBaseProps & {
placeholder?: string;
- facilityId?: string;
- homeFacility?: string;
userType?: UserRole;
- showActiveStatus?: boolean;
noResultsError?: string;
};
-export default function UserAutocompleteFormField(props: Props) {
+type LinkedFacilitySearchProps = BaseProps & {
+ facilityId: string;
+ homeFacility?: undefined;
+};
+
+type UserSearchProps = BaseProps & {
+ facilityId?: undefined;
+ homeFacility?: string;
+};
+
+export default function UserAutocomplete(props: UserSearchProps) {
const field = useFormFieldPropsResolver(props);
- const { fetchOptions, isLoading, options } = useAsyncOptions(
- "id",
- { queryResponseExtractor: (data) => data.results },
- );
+ const [query, setQuery] = useState("");
+ const [disabled, setDisabled] = useState(false);
- let search_filter: {
- limit: number;
- offset: number;
- home_facility?: string;
- user_type?: string;
- search_text?: string;
- } = { limit: 50, offset: 0 };
+ const { data, loading } = useQuery(routes.userList, {
+ query: {
+ home_facility: props.homeFacility,
+ user_type: props.userType,
+ search_text: query,
+ limit: 50,
+ offset: 0,
+ },
+ });
- if (props.showActiveStatus && props.userType) {
- search_filter = { ...search_filter, user_type: props.userType };
- }
+ useEffect(() => {
+ if (
+ loading ||
+ query ||
+ !field.required ||
+ !props.noResultsError ||
+ !data?.results
+ ) {
+ return;
+ }
- if (props.homeFacility) {
- search_filter = { ...search_filter, home_facility: props.homeFacility };
- }
+ if (data.results.length === 0) {
+ setDisabled(true);
+ field.handleChange(undefined as unknown as UserBareMinimum);
+ }
+ }, [loading, query, field.required, data?.results, props.noResultsError]);
- const getStatusIcon = (option: UserModel) => {
- if (!props.showActiveStatus) return null;
+ return (
+
+ obj.username,
+ )}
+ optionLabel={formatName}
+ optionIcon={userOnlineDot}
+ optionDescription={(option) =>
+ `${option.user_type} - ${option.username}`
+ }
+ optionValue={(option) => option}
+ onQuery={setQuery}
+ isLoading={loading}
+ />
+
+ );
+}
- return (
-
-
-
- );
- };
+export const LinkedFacilityUsers = (props: LinkedFacilitySearchProps) => {
+ const field = useFormFieldPropsResolver(props);
- const items = options(field.value && [field.value]);
+ const [query, setQuery] = useState("");
- useEffect(() => {
- if (props.required && !isLoading && !items.length && props.noResultsError) {
- field.handleChange(undefined as unknown as UserModel);
- }
- }, [isLoading, items, props.required]);
+ const { data, loading } = useQuery(routes.getFacilityUsers, {
+ pathParams: { facility_id: props.facilityId },
+ query: {
+ user_type: props.userType,
+ search_text: query,
+ limit: 50,
+ offset: 0,
+ },
+ });
const noResultError =
- (props.required && !isLoading && !items.length && props.noResultsError) ||
+ (!query &&
+ !loading &&
+ field.required &&
+ !data?.results?.length &&
+ props.noResultsError) ||
undefined;
+ useEffect(() => {
+ if (noResultError) {
+ field.handleChange(undefined as unknown as UserBareMinimum);
+ }
+ }, [noResultError]);
+
return (
-
- `${option.user_type}`}
- optionValue={(option) => option}
- onQuery={(query) =>
- fetchOptions(
- props.facilityId
- ? getFacilityUsers(props.facilityId, {
- ...search_filter,
- search_text: query,
- })
- : getUserList({ ...search_filter, search_text: query }),
- )
- }
- isLoading={isLoading}
- />
-
+ obj.username,
+ )}
+ optionLabel={formatName}
+ optionIcon={userOnlineDot}
+ optionDescription={(option) =>
+ `${option.user_type} - ${option.username}`
+ }
+ optionValue={(option) => option}
+ onQuery={setQuery}
+ isLoading={loading}
+ />
);
-}
-
-const getUserFullName = (user: UserModel) => {
- const personName = user.first_name + " " + user.last_name;
- return personName.trim().length > 0 ? personName : user.username || "";
};
+
+const userOnlineDot = (user: UserBareMinimum) => (
+
+);
diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx
index 40d9741d712..c9339ce685b 100644
--- a/src/Components/Facility/ConsultationForm.tsx
+++ b/src/Components/Facility/ConsultationForm.tsx
@@ -33,8 +33,8 @@ import PatientCategorySelect from "../Patient/PatientCategorySelect";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
-import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
-import { UserModel } from "../Users/models";
+import UserAutocomplete from "../Common/UserAutocompleteFormField";
+import { UserBareMinimum } from "../Users/models";
import { navigate } from "raviger";
import useAppHistory from "../../Common/hooks/useAppHistory";
@@ -90,7 +90,7 @@ type FormDetails = {
referred_by_external?: string;
transferred_from_location?: string;
treating_physician: string;
- treating_physician_object: UserModel | null;
+ treating_physician_object: UserBareMinimum | null;
create_diagnoses: CreateDiagnosis[];
diagnoses: ConsultationDiagnosis[];
symptoms: EncounterSymptom[];
@@ -107,7 +107,7 @@ type FormDetails = {
is_telemedicine: BooleanStrings;
action?: number;
assigned_to: string;
- assigned_to_object: UserModel | null;
+ assigned_to_object: UserBareMinimum | null;
special_instruction: string;
review_interval: number;
weight: string;
@@ -386,8 +386,8 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
admitted: data.admitted ? String(data.admitted) : "false",
admitted_to: data.admitted_to ? data.admitted_to : "",
category: data.category
- ? PATIENT_CATEGORIES.find((i) => i.text === data.category)?.id ??
- ""
+ ? (PATIENT_CATEGORIES.find((i) => i.text === data.category)?.id ??
+ "")
: "",
patient_no: data.patient_no ?? "",
OPconsultation: data.consultation_notes,
@@ -782,7 +782,9 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
}
};
- const handleDoctorSelect = (event: FieldChangeEvent) => {
+ const handleDoctorSelect = (
+ event: FieldChangeEvent,
+ ) => {
if (event.value?.id) {
dispatch({
type: "set_form",
@@ -1430,7 +1432,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
className="col-span-6"
ref={fieldRef["treating_physician"]}
>
- {
state.form.treating_physician_object ?? undefined
}
onChange={handleDoctorSelect}
- showActiveStatus
userType={"Doctor"}
homeFacility={facilityId}
error={state.errors.treating_physician}
@@ -1483,8 +1484,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
className="col-span-6 flex-[2]"
ref={fieldRef["assigned_to"]}
>
-
-
- {user.first_name} {user.last_name}
-
+ {formatName(user)}
- {`${user.first_name} ${user.last_name}`}
+ {formatName(user)}
diff --git a/src/Components/Facility/PatientNoteCard.tsx b/src/Components/Facility/PatientNoteCard.tsx
index 7f00700ff47..7d2a8c6eb70 100644
--- a/src/Components/Facility/PatientNoteCard.tsx
+++ b/src/Components/Facility/PatientNoteCard.tsx
@@ -1,4 +1,9 @@
-import { relativeDate, formatDateTime, classNames } from "../../Utils/utils";
+import {
+ relativeDate,
+ formatDateTime,
+ classNames,
+ formatName,
+} from "../../Utils/utils";
import { USER_TYPES_MAP } from "../../Common/constants";
import { PatientNotesEditModel, PatientNotesModel } from "./models";
import ButtonV2 from "../Common/components/ButtonV2";
@@ -78,8 +83,7 @@ const PatientNoteCard = ({
- {note.created_by_object?.first_name || "Unknown"}{" "}
- {note.created_by_object?.last_name}
+ {formatName(note.created_by_object)}
{note.user_type && (
diff --git a/src/Components/Notifications/NoticeBoard.tsx b/src/Components/Notifications/NoticeBoard.tsx
index db285eb9d6a..98c4daba2c4 100644
--- a/src/Components/Notifications/NoticeBoard.tsx
+++ b/src/Components/Notifications/NoticeBoard.tsx
@@ -1,6 +1,6 @@
import Page from "../Common/components/Page";
import Loading from "../Common/Loading";
-import { formatDateTime } from "../../Utils/utils";
+import { formatDateTime, formatName } from "../../Utils/utils";
import { useTranslation } from "react-i18next";
import CareIcon from "../../CAREUI/icons/CareIcon";
import useQuery from "../../Utils/request/useQuery";
@@ -25,7 +25,7 @@ export const NoticeBoard = () => {
{item.message}
- {`${item.caused_by.first_name} ${item.caused_by.last_name}`} -{" "}
+ {formatName(item.caused_by)} -{" "}
{item.caused_by.user_type}
diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx
index 1bee5a3b245..9482dc103dd 100644
--- a/src/Components/Patient/PatientHome.tsx
+++ b/src/Components/Patient/PatientHome.tsx
@@ -18,6 +18,7 @@ import {
classNames,
formatDate,
formatDateTime,
+ formatName,
formatPatientAge,
isAntenatal,
isPostPartum,
@@ -30,7 +31,7 @@ import { useTranslation } from "react-i18next";
import CircularProgress from "../Common/components/CircularProgress";
import Page from "../Common/components/Page";
import ConfirmDialog from "../Common/ConfirmDialog";
-import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
+import UserAutocomplete from "../Common/UserAutocompleteFormField";
import dayjs from "../../Utils/dayjs";
import { triggerGoal } from "../../Integrations/Plausible";
import useAuthUser from "../../Common/hooks/useAuthUser";
@@ -275,14 +276,9 @@ export const PatientHome = (props: any) => {
Assigned Doctor:
- {
- patientData?.last_consultation?.assigned_to_object
- .first_name
- }
- {
- patientData?.last_consultation?.assigned_to_object
- .last_name
- }
+ {formatName(
+ patientData.last_consultation.assigned_to_object,
+ )}
{patientData?.last_consultation?.assigned_to_object
.alt_phone_number && (
@@ -300,8 +296,7 @@ export const PatientHome = (props: any) => {
Assigned Volunteer:
- {patientData.assigned_to_object.first_name}
- {patientData.assigned_to_object.last_name}
+ {formatName(patientData.assigned_to_object)}
)}
@@ -1395,8 +1390,7 @@ export const PatientHome = (props: any) => {
onClose={() => setOpenAssignVolunteerDialog(false)}
description={
-
{consultation?.treating_physician_object
- ? `${consultation?.treating_physician_object.first_name} ${consultation?.treating_physician_object.last_name}`
+ ? formatName(consultation.treating_physician_object)
: consultation?.deprecated_verified_by}
- {created_by_object?.first_name || "Unknown"}{" "}
- {created_by_object?.last_name}
+ {formatName(created_by_object)}
diff --git a/src/Components/Resource/ResourceBoard.tsx b/src/Components/Resource/ResourceBoard.tsx
index 352942aff83..c80d11bf361 100644
--- a/src/Components/Resource/ResourceBoard.tsx
+++ b/src/Components/Resource/ResourceBoard.tsx
@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import { downloadResourceRequests } from "../../Redux/actions";
import { navigate } from "raviger";
-import { classNames } from "../../Utils/utils";
+import { classNames, formatName } from "../../Utils/utils";
import { useDrag, useDrop } from "react-dnd";
import { formatDateTime } from "../../Utils/utils";
import { ExportButton } from "../Common/Export";
@@ -126,8 +126,7 @@ const ResourceCard = ({ resource }: any) => {
>
- {resource.assigned_to_object.first_name}{" "}
- {resource.assigned_to_object.last_name} -{" "}
+ {formatName(resource.assigned_to_object)} -{" "}
{resource.assigned_to_object.user_type}
diff --git a/src/Components/Resource/ResourceDetails.tsx b/src/Components/Resource/ResourceDetails.tsx
index c719556d561..4c01bdc4b9c 100644
--- a/src/Components/Resource/ResourceDetails.tsx
+++ b/src/Components/Resource/ResourceDetails.tsx
@@ -1,5 +1,5 @@
import { useState, lazy } from "react";
-import { classNames, formatDateTime } from "../../Utils/utils";
+import { classNames, formatDateTime, formatName } from "../../Utils/utils";
import { navigate } from "raviger";
import * as Notification from "../../Utils/Notifications.js";
import CommentSection from "./CommentSection";
@@ -241,8 +241,7 @@ export default function ResourceDetails(props: { id: string }) {
- Assigned to: {data.assigned_to_object.first_name}{" "}
- {data.assigned_to_object.last_name} -{" "}
+ Assigned to: {formatName(data.assigned_to_object)} -{" "}
{data.assigned_to_object.user_type}
@@ -359,8 +358,7 @@ export default function ResourceDetails(props: { id: string }) {
- {data?.created_by_object?.first_name}{" "}
- {data?.created_by_object?.last_name}
+ {formatName(data.created_by_object)}
{data.created_date && formatDateTime(data.created_date)}
@@ -373,8 +371,7 @@ export default function ResourceDetails(props: { id: string }) {
- {data?.last_edited_by_object?.first_name}{" "}
- {data?.last_edited_by_object?.last_name}
+ {formatName(data.last_edited_by_object)}
{data.modified_date && formatDateTime(data.modified_date)}
diff --git a/src/Components/Resource/ResourceDetailsUpdate.tsx b/src/Components/Resource/ResourceDetailsUpdate.tsx
index 89d4d5a15ea..178ab596148 100644
--- a/src/Components/Resource/ResourceDetailsUpdate.tsx
+++ b/src/Components/Resource/ResourceDetailsUpdate.tsx
@@ -13,7 +13,7 @@ import RadioFormField from "../Form/FormFields/RadioFormField";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
-import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
+import UserAutocomplete from "../Common/UserAutocompleteFormField";
import useAppHistory from "../../Common/hooks/useAppHistory";
import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";
@@ -209,7 +209,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
{assignedUserLoading ? (
) : (
-
- {created_by_object?.first_name || t("unknown")}{" "}
- {created_by_object?.last_name}
+ {formatName(created_by_object)}
diff --git a/src/Components/Shifting/ListFilter.tsx b/src/Components/Shifting/ListFilter.tsx
index af98f524ed2..12bb17db09c 100644
--- a/src/Components/Shifting/ListFilter.tsx
+++ b/src/Components/Shifting/ListFilter.tsx
@@ -21,7 +21,7 @@ import useConfig from "../../Common/hooks/useConfig";
import useMergeState from "../../Common/hooks/useMergeState";
import { useTranslation } from "react-i18next";
-import UserAutocompleteFormField from "../Common/UserAutocompleteFormField";
+import UserAutocomplete from "../Common/UserAutocompleteFormField";
import { dateQueryString, parsePhoneNumber } from "../../Utils/utils";
import dayjs from "dayjs";
import useQuery from "../../Utils/request/useQuery";
@@ -165,7 +165,7 @@ export default function ListFilter(props: any) {
patient_phone_number:
patient_phone_number === "+91"
? ""
- : parsePhoneNumber(patient_phone_number) ?? "",
+ : (parsePhoneNumber(patient_phone_number) ?? ""),
created_date_before: dateQueryString(created_date_before),
created_date_after: dateQueryString(created_date_after),
modified_date_before: dateQueryString(modified_date_before),
@@ -268,7 +268,7 @@ export default function ListFilter(props: any) {
{isAssignedLoading ? (
) : (
-
- {t("assigned_to")}: {data?.assigned_to_object.first_name}{" "}
- {data.assigned_to_object.last_name} -{" "}
- {data.assigned_to_object.user_type}
+ {t("assigned_to")}: {formatName(data.assigned_to_object)}{" "}
+ - {data.assigned_to_object.user_type}
diff --git a/src/Components/Shifting/ShiftDetailsUpdate.tsx b/src/Components/Shifting/ShiftDetailsUpdate.tsx
index 35e77066ef4..37adecaedcd 100644
--- a/src/Components/Shifting/ShiftDetailsUpdate.tsx
+++ b/src/Components/Shifting/ShiftDetailsUpdate.tsx
@@ -33,8 +33,8 @@ import CircularProgress from "../Common/components/CircularProgress.js";
import Card from "../../CAREUI/display/Card";
import RadioFormField from "../Form/FormFields/RadioFormField.js";
import Page from "../Common/components/Page.js";
-import UserAutocompleteFormField from "../Common/UserAutocompleteFormField.js";
-import { UserModel } from "../Users/models.js";
+import { LinkedFacilityUsers } from "../Common/UserAutocompleteFormField.js";
+import { UserBareMinimum } from "../Users/models.js";
import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";
import { IShift } from "./models.js";
@@ -57,7 +57,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
const [qParams, _] = useQueryParams();
const [isLoading, setIsLoading] = useState(true);
- const [assignedUser, SetAssignedUser] = useState ();
+ const [assignedUser, SetAssignedUser] = useState();
const [consultationData, setConsultationData] = useState(
{} as ConsultationModel,
@@ -184,7 +184,9 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
return !isInvalidForm;
};
- const handleAssignedUserSelect = (event: FieldChangeEvent) => {
+ const handleAssignedUserSelect = (
+ event: FieldChangeEvent,
+ ) => {
const user = event.value;
const form = { ...state.form };
form["assigned_to"] = user?.id;
@@ -357,7 +359,7 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
(assignedUserLoading ? (
) : (
- {
>
- {shift.assigned_to_object.first_name}{" "}
- {shift.assigned_to_object.last_name} -{" "}
+ {formatName(shift.assigned_to_object)}
+ {" - "}
{shift.assigned_to_object.user_type}
diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx
index 19bafebd115..1acd9ac2a3c 100644
--- a/src/Components/Users/ManageUsers.tsx
+++ b/src/Components/Users/ManageUsers.tsx
@@ -14,7 +14,12 @@ import routes from "../../Redux/api.js";
import * as Notification from "../../Utils/Notifications.js";
import request from "../../Utils/request/request.js";
import useQuery from "../../Utils/request/useQuery.js";
-import { classNames, isUserOnline, relativeTime } from "../../Utils/utils";
+import {
+ classNames,
+ formatName,
+ isUserOnline,
+ relativeTime,
+} from "../../Utils/utils";
import { FacilitySelect } from "../Common/FacilitySelect";
import Pagination from "../Common/Pagination";
import UserDetails from "../Common/UserDetails";
@@ -178,7 +183,7 @@ export default function ManageUsers() {
setUserData({
show: true,
username: user.username,
- name: `${user.first_name} ${user.last_name}`,
+ name: formatName(user),
});
};
@@ -238,7 +243,7 @@ export default function ManageUsers() {
id="name"
className="mt-2 flex items-center gap-3 text-2xl font-bold capitalize"
>
- {`${user.first_name} ${user.last_name}`}
+ {formatName(user)}
{user.last_login && cur_online ? (
{
- return fireRequest("userList", [], params, null, key);
-};
-
-export const getFacilityUsers = (id: string, params?: object) => {
- return fireRequest(
- "getFacilityUsers",
- [],
- { ...params },
- { facility_id: id },
- );
-};
-
// asset bed
export const listAssetBeds = (params: object, altKey?: string) =>
fireRequest("listAssetBeds", [], params, {}, altKey);
|