Skip to content

Commit

Permalink
Minor enhancements (ohcnetwork#9631)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan authored Jan 2, 2025
1 parent 2dfac5c commit b57e25c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/components/Common/UserSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ interface Props {
onChange: (user: UserBase) => void;
placeholder?: string;
noOptionsMessage?: string;
popoverClassName?: string;
}

export default function UserSelector({
selected,
onChange,
placeholder,
noOptionsMessage,
popoverClassName,
}: Props) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
Expand All @@ -55,8 +57,8 @@ export default function UserSelector({
const users = data?.results || [];

return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Popover open={open} onOpenChange={setOpen} modal={true}>
<PopoverTrigger asChild className={popoverClassName}>
<Button
variant="outline"
role="combobox"
Expand All @@ -77,7 +79,11 @@ export default function UserSelector({
<CaretDownIcon className="ml-auto" />
</Button>
</PopoverTrigger>
<PopoverContent className="p-0" align="start">
<PopoverContent
className="p-0 w-[var(--radix-popover-trigger-width)] max-w-[--radix-popover-content-available-width]"
align="start"
sideOffset={4}
>
<Command filter={() => 1}>
<CommandInput
placeholder={t("search")}
Expand Down
19 changes: 16 additions & 3 deletions src/pages/Encounters/EncounterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,23 @@ export function EncounterList({
queryParams: {
...buildQueryParams(status, facilityId, encounterClass, priority),
name,
encounter_id,
external_identifier,
limit: resultsPerPage,
offset: ((qParams.page || 1) - 1) * resultsPerPage,
},
}),
enabled: !propEncounters,
enabled: !propEncounters && !encounter_id,
});

const { data: queryEncounter } = useQuery<Encounter>({
queryKey: ["encounter", encounter_id],
queryFn: query(routes.encounter.get, {
pathParams: { id: encounter_id },
queryParams: {
facility: facilityId,
},
}),
enabled: !!encounter_id,
});

const searchOptions = [
Expand Down Expand Up @@ -220,7 +230,10 @@ export function EncounterList({
},
];

const encounters = propEncounters || queryEncounters?.results || [];
const encounters =
propEncounters ||
queryEncounters?.results ||
(queryEncounter ? [queryEncounter] : []);

const { t } = useTranslation();

Expand Down
6 changes: 3 additions & 3 deletions src/pages/Encounters/tabs/EncounterFilesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Tabs, TabsContent } from "@/components/ui/tabs";
import {
Tooltip,
TooltipContent,
Expand Down Expand Up @@ -490,7 +490,7 @@ export const EncounterFilesTab = (props: EncounterTabProps) => {
>
<div className="mx-2 flex flex-col flex-wrap gap-3 sm:flex-row justify-between">
<div className="flex sm:flex-row flex-wrap flex-col gap-4 sm:items-center">
<TabsList className="flex flex-row flex-wrap gap-2 h-auto">
{/* <TabsList className="flex flex-row flex-wrap gap-2 h-auto">
{fileCategories.map((category) => (
<TabsTrigger
key={category.value}
Expand All @@ -500,7 +500,7 @@ export const EncounterFilesTab = (props: EncounterTabProps) => {
{category.label}
</TabsTrigger>
))}
</TabsList>
</TabsList> */}
<FilterButton />
</div>
<FileUploadButtons />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function LinkFacilityUserSheet({
Link User
</Button>
</SheetTrigger>
<SheetContent>
<SheetContent className="w-full sm:max-w-md overflow-y-auto p-8">
<SheetHeader>
<SheetTitle>Link User to Facility</SheetTitle>
<SheetDescription>
Expand All @@ -131,6 +131,7 @@ export default function LinkFacilityUserSheet({
onChange={handleUserChange}
placeholder="Search for a user"
noOptionsMessage="No users found"
popoverClassName="w-full"
/>
{selectedUser && (
<div className="space-y-4">
Expand Down Expand Up @@ -173,7 +174,13 @@ export default function LinkFacilityUserSheet({
<SelectTrigger className="h-12">
<SelectValue placeholder="Select a role" />
</SelectTrigger>
<SelectContent>
<SelectContent
position="popper"
className="max-h-[calc(100vh-60vh)] w-[var(--radix-select-trigger-width)] max-w-[var(--radix-select-content-available-width)] overflow-y-auto"
sideOffset={4}
side="bottom"
avoidCollisions={true}
>
{roles?.results?.map((role) => (
<SelectItem key={role.id} value={role.id}>
<div className="flex flex-col text-left">
Expand Down
1 change: 1 addition & 0 deletions src/pages/Organization/components/LinkUserSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default function LinkUserSheet({
onChange={handleUserChange}
placeholder="Search for a user"
noOptionsMessage="No users found"
popoverClassName="w-full"
/>
{selectedUser && (
<div className="space-y-4">
Expand Down

0 comments on commit b57e25c

Please sign in to comment.