Skip to content

Commit

Permalink
Merge branch 'develop' into remove-clickElementById/ohcnetwork#8929
Browse files Browse the repository at this point in the history
  • Loading branch information
AnveshNalimela committed Nov 9, 2024
2 parents b7950cd + 84fdffe commit 7aaa96a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 35 deletions.
9 changes: 5 additions & 4 deletions cypress/e2e/facility_spec/FacilityLocation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { v4 as uuidv4 } from "uuid";

import { AssetPage } from "../../pageobject/Asset/AssetCreation";
import { UserCreationPage } from "../../pageobject/Users/UserCreation";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityLocation from "../../pageobject/Facility/FacilityLocation";
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import { v4 as uuidv4 } from "uuid";
import FacilityLocation from "../../pageobject/Facility/FacilityLocation";
import { UserCreationPage } from "../../pageobject/Users/UserCreation";

describe("Location Management Section", () => {
const assetPage = new AssetPage();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/users_spec/UsersProfile.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LoginPage from "../../pageobject/Login/LoginPage";
import UserProfilePage from "../../pageobject/Users/UserProfilePage";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import UserProfilePage from "../../pageobject/Users/UserProfilePage";

describe("Manage User Profile", () => {
const loginPage = new LoginPage();
Expand Down
5 changes: 2 additions & 3 deletions cypress/pageobject/Patient/PatientPredefined.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// PatientPredefined.js

import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory";
import {
generatePhoneNumber,
generateEmergencyPhoneNumber,
generatePhoneNumber,
} from "../utils/constants";

class PatientPredefined {
Expand Down
15 changes: 12 additions & 3 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
"compilerOptions": {
"baseUrl": "./",
"target": "es5",
"lib": ["es5", "dom", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020"],
"lib": [
"es5",
"dom",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020"
],
"typeRoots": ["./support"],
"resolveJsonModule": true
},
"include": ["**/*.cy.ts", "support/commands.ts","**/*.ts"],
}
"include": ["**/*.cy.ts", "support/commands.ts", "**/*.ts"]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"prepare": "husky",
"lint": "eslint ./src",
"lint-fix": "eslint ./src --fix",
"format": "prettier ./src --write",
"format": "prettier ./src ./cypress --write",
"sort-locales": "node ./scripts/sort-locales.js"
},
"dependencies": {
Expand Down Expand Up @@ -166,12 +166,12 @@
"eslint --fix",
"git update-index --again"
],
"src/Locale/*.json": [
"public/locale/*.json": [
"npm run sort-locales"
]
},
"engines": {
"node": ">=22.11.0"
},
"packageManager": "[email protected]"
}
}
2 changes: 1 addition & 1 deletion scripts/sort-locales.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs");

const file = "src/Locale/en.json";
const file = "public/locale/en.json";

const data = JSON.parse(fs.readFileSync(file, "utf8"));

Expand Down
13 changes: 13 additions & 0 deletions src/components/Common/UserAutocompleteFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
mergeQueryOptions,
} from "@/Utils/utils";

import { Avatar } from "./Avatar";

type BaseProps = FormFieldBaseProps<UserBareMinimum> & {
placeholder?: string;
userType?: UserRole;
Expand Down Expand Up @@ -67,6 +69,16 @@ export default function UserAutocomplete(props: UserSearchProps) {
}
}, [loading, field.required, data?.results, props.noResultsError]);

const getAvatar = (option: UserBareMinimum) => {
return (
<Avatar
className="h-11 w-11 rounded-full"
name={formatName(option)}
imageUrl={option.read_profile_picture_url}
/>
);
};

return (
<FormField field={field}>
<Autocomplete
Expand All @@ -83,6 +95,7 @@ export default function UserAutocomplete(props: UserSearchProps) {
)}
optionLabel={formatName}
optionIcon={userOnlineDot}
optionImage={getAvatar}
optionDescription={(option) =>
`${option.user_type} - ${option.username}`
}
Expand Down
47 changes: 27 additions & 20 deletions src/components/Form/FormFields/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ComboboxOption,
ComboboxOptions,
} from "@headlessui/react";
import { useEffect, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
Expand All @@ -29,6 +29,7 @@ type AutocompleteFormFieldProps<T, V> = FormFieldBaseProps<V> & {
optionValue?: OptionCallback<T, V>;
optionDescription?: OptionCallback<T, string>;
optionIcon?: OptionCallback<T, React.ReactNode>;
optionImage?: OptionCallback<T, ReactNode | undefined>;
optionDisabled?: OptionCallback<T, boolean>;
minQueryLength?: number;
onQuery?: (query: string) => void;
Expand All @@ -55,6 +56,7 @@ const AutocompleteFormField = <T, V>(
placeholder={props.placeholder}
optionLabel={props.optionLabel}
optionIcon={props.optionIcon}
optionImage={props.optionImage}
optionValue={props.optionValue}
optionDescription={props.optionDescription}
optionDisabled={props.optionDisabled}
Expand All @@ -79,6 +81,7 @@ type AutocompleteProps<T, V = T> = {
placeholder?: string;
optionLabel: OptionCallback<T, string>;
optionIcon?: OptionCallback<T, React.ReactNode>;
optionImage?: OptionCallback<T, ReactNode | undefined>;
optionValue?: OptionCallback<T, V>;
optionDescription?: OptionCallback<T, React.ReactNode>;
optionDisabled?: OptionCallback<T, boolean>;
Expand All @@ -89,7 +92,6 @@ type AutocompleteProps<T, V = T> = {
isLoading?: boolean;
allowRawInput?: boolean;
error?: string;
avatar?: boolean;
} & (
| {
required?: false;
Expand Down Expand Up @@ -124,6 +126,7 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
description,
search: label.toLowerCase(),
icon: props.optionIcon?.(option),
image: props.optionImage?.(option),
value: props.optionValue ? props.optionValue(option) : option,
disabled: props.optionDisabled?.(option),
};
Expand All @@ -143,6 +146,7 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
description: undefined,
search: query.toLowerCase(),
icon: <CareIcon icon="l-plus" />,
image: undefined,
value: query,
disabled: undefined,
},
Expand Down Expand Up @@ -241,25 +245,28 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
disabled={option.disabled}
>
{({ focus }) => (
<div className="flex flex-col">
<div className="flex justify-between">
<span>{option.label}</span>
<span>{option.icon}</span>
</div>
{option.description && (
<div
className={classNames(
"text-sm font-normal",
option.disabled
? "text-secondary-700"
: focus
? "text-primary-200"
: "text-secondary-700",
)}
>
{option.description}
<div className="flex flex-row gap-2">
{option?.image}
<div className="flex flex-grow flex-col">
<div className="flex justify-between">
<span>{option.label}</span>
<span>{option.icon}</span>
</div>
)}
{option.description && (
<div
className={classNames(
"text-sm font-normal",
option.disabled
? "text-secondary-700"
: focus
? "text-primary-200"
: "text-secondary-700",
)}
>
{option.description}
</div>
)}
</div>
</div>
)}
</ComboboxOption>
Expand Down

0 comments on commit 7aaa96a

Please sign in to comment.