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: Loses focus on User Search in users tab #9500

Closed
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d97b99c
Fix: Loses focus on user search
AdityaJ2305 Dec 19, 2024
ba602c0
Fix: Loses focus on user search and updated searchinput comp
AdityaJ2305 Dec 19, 2024
84181ec
Fix: cmd k shortcut trigger for userlistview
AdityaJ2305 Dec 19, 2024
7e073ed
Fix: linting issue
AdityaJ2305 Dec 19, 2024
ff1694d
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 20, 2024
9ed8f11
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 20, 2024
add62f6
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 21, 2024
bcc8553
Undo changes
AdityaJ2305 Dec 21, 2024
6cf326a
Merge branch 'issue/9398/search_bar_loses_focus' of https://github.co…
AdityaJ2305 Dec 21, 2024
ee9293f
Fix: Issue on losing foucs
AdityaJ2305 Dec 21, 2024
77e4170
Fix: take out searchbar and tab change in parent comp
AdityaJ2305 Dec 21, 2024
885677f
Removed unnecessary code and fix import
AdityaJ2305 Dec 21, 2024
ed5bc60
Update to descriptive name
AdityaJ2305 Dec 21, 2024
728bf2c
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 22, 2024
6072d41
Update to new seachinput
AdityaJ2305 Dec 22, 2024
2ffc677
Merge branch 'issue/9398/search_bar_loses_focus' of https://github.co…
AdityaJ2305 Dec 22, 2024
25f9b0a
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 22, 2024
288cd78
just import fix
AdityaJ2305 Dec 22, 2024
e3abd7d
Merge branch 'issue/9398/search_bar_loses_focus' of https://github.co…
AdityaJ2305 Dec 22, 2024
95fc767
just import fix
AdityaJ2305 Dec 22, 2024
ab82beb
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 23, 2024
60a0843
Fix: linting issue
AdityaJ2305 Dec 23, 2024
2c8733f
Update to shadcn tab
AdityaJ2305 Dec 24, 2024
443c192
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 24, 2024
8711143
add lock file
AdityaJ2305 Dec 24, 2024
2112dd1
Merge branch 'issue/9398/search_bar_loses_focus' of https://github.co…
AdityaJ2305 Dec 24, 2024
57a57ae
add lock file
AdityaJ2305 Dec 24, 2024
0b16663
Delete package-lock.json
AdityaJ2305 Dec 24, 2024
da5368c
add lock file
AdityaJ2305 Dec 24, 2024
4ae9bee
add lock file
AdityaJ2305 Dec 24, 2024
55196d3
undo last commit
AdityaJ2305 Dec 24, 2024
218a930
reset lock file
AdityaJ2305 Dec 24, 2024
371827b
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 24, 2024
8cb506d
fix cypress test
AdityaJ2305 Dec 24, 2024
05048de
fix cypress test
AdityaJ2305 Dec 24, 2024
f1e8ebf
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 25, 2024
f1d6fb8
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 25, 2024
a132a46
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 26, 2024
4328dbb
Empty-Commit
AdityaJ2305 Dec 26, 2024
99e010e
Empty-Commit
AdityaJ2305 Dec 27, 2024
e0864a8
add strong type
AdityaJ2305 Dec 27, 2024
e3e57b4
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 27, 2024
2d46fb1
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 28, 2024
b98488b
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 29, 2024
5ca5275
Merge branch 'develop' into issue/9398/search_bar_loses_focus
AdityaJ2305 Dec 30, 2024
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
2 changes: 1 addition & 1 deletion cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ export class UserPage {
}

verifyListView() {
cy.get("#user-list-view").should("have.class", "text-white");
cy.get("#user-list-view").should("have.attr", "data-state", "active");
}
}
99 changes: 99 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-scroll-area": "^1.2.0",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.2",
"@radix-ui/react-toast": "^1.2.4",
"@radix-ui/react-tooltip": "^1.1.6",
"@sentry/browser": "^8.47.0",
Expand Down
71 changes: 60 additions & 11 deletions src/components/Facility/FacilityUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";

import CountBlock from "@/CAREUI/display/Count";
import CareIcon from "@/CAREUI/icons/CareIcon";

import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";

import Loading from "@/components/Common/Loading";
import Page from "@/components/Common/Page";
import SearchByMultipleFields from "@/components/Common/SearchByMultipleFields";
// import Tabs from "@/components/Common/Tabs";
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
import UserListView from "@/components/Users/UserListAndCard";

import useFilters from "@/hooks/useFilters";
Expand All @@ -13,11 +19,14 @@ import useTanStackQueryInstead from "@/Utils/request/useQuery";

export default function FacilityUsers(props: { facilityId: number }) {
const { t } = useTranslation();

let usersList: JSX.Element = <></>;

const { qParams, updateQuery, Pagination, resultsPerPage } = useFilters({
limit: 18,
cacheBlacklist: ["username"],
});
const [activeTab, setActiveTab] = useState(0);
const [activeTab, setActiveTab] = useState("cardView");
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
const { facilityId } = props;

const { data: facilityData } = useTanStackQueryInstead(
Expand All @@ -43,6 +52,20 @@ export default function FacilityUsers(props: { facilityId: number }) {
prefetch: facilityId !== undefined,
});

if (userListLoading || !userListData) {
usersList = <Loading />;
} else {
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
usersList = (
<div>
<UserListView
users={userListData?.results ?? []}
activeTab={activeTab}
/>
<Pagination totalCount={userListData.count} />
</div>
);
}

return (
<Page
title={`${t("users")} - ${facilityData?.name}`}
Expand All @@ -56,16 +79,42 @@ export default function FacilityUsers(props: { facilityId: number }) {
icon="d-people"
className="my-3 flex flex-col items-center sm:items-start"
/>

<UserListView
users={userListData?.results ?? []}
onSearch={(username) => updateQuery({ username })}
searchValue={qParams.username}
activeTab={activeTab}
onTabChange={setActiveTab}
/>

<Pagination totalCount={userListData?.count ?? 0} />
<div className="mb-4 flex flex-col items-center justify-between gap-3 sm:flex-row">
<div className="flex-grow w-full">
<SearchByMultipleFields
id="search-by-username"
className="w-full"
onSearch={(key, value) => updateQuery({ username: value })}
options={[
{
key: "username",
label: "username",
type: "text" as const,
placeholder: t("search_by_username"),
value: qParams.username || "",
shortcutKey: "u",
},
]}
/>
</div>
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList>
<TabsTrigger value="cardView" id="user-card-view">
<div className="flex items-center gap-2">
<CareIcon icon="l-credit-card" className="text-lg" />
<span>Card</span>
</div>
</TabsTrigger>
<TabsTrigger value="listView" id="user-list-view">
<div className="flex items-center gap-2">
<CareIcon icon="l-list-ul" className="text-lg" />
<span>List</span>
</div>
</TabsTrigger>
</TabsList>
</Tabs>
</div>
<div>{usersList}</div>
</Page>
);
}
74 changes: 56 additions & 18 deletions src/components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import CountBlock from "@/CAREUI/display/Count";
import CareIcon from "@/CAREUI/icons/CareIcon";
import { AdvancedFilterButton } from "@/CAREUI/interactive/FiltersSlideover";

import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";

import ButtonV2 from "@/components/Common/ButtonV2";
import Loading from "@/components/Common/Loading";
import Page from "@/components/Common/Page";
import SearchByMultipleFields from "@/components/Common/SearchByMultipleFields";
// import Tabs from "@/components/Common/Tabs";
import UserFilter from "@/components/Users/UserFilter";
import UserListView from "@/components/Users/UserListAndCard";

Expand All @@ -29,17 +33,18 @@ export default function ManageUsers() {
FilterBadges,
advancedFilter,
resultsPerPage,
clearSearch,
} = useFilters({
limit: 18,
cacheBlacklist: ["username"],
});
let manageUsers: JSX.Element = <></>;
let usersList: JSX.Element = <></>;
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
const authUser = useAuthUser();
const userIndex = USER_TYPES.indexOf(authUser.user_type);
const userTypes = authUser.is_superuser
? [...USER_TYPES]
: USER_TYPES.slice(0, userIndex + 1);
const [activeTab, setActiveTab] = useState(0);
const [activeTab, setActiveTab] = useState("cardView");

const { data: homeFacilityData } = useTanStackQueryInstead(
routes.getAnyFacility,
Expand Down Expand Up @@ -94,23 +99,20 @@ export default function ManageUsers() {
</ButtonV2>
);

if (userListLoading || districtDataLoading || !userListData?.results) {
return <Loading />;
if (userListLoading || districtDataLoading || !userListData) {
usersList = <Loading />;
} else {
usersList = (
<div>
<UserListView
users={userListData?.results ?? []}
activeTab={activeTab}
/>
<Pagination totalCount={userListData.count} />
</div>
);
}

manageUsers = (
<div>
<UserListView
users={userListData?.results ?? []}
onSearch={(username) => updateQuery({ username })}
searchValue={qParams.username}
activeTab={activeTab}
onTabChange={setActiveTab}
/>
<Pagination totalCount={userListData.count} />
</div>
);

return (
<Page title={t("user_management")} hideBack={true} breadcrumbs={false}>
<div className="mt-5 flex flex-col items-center justify-between gap-3 sm:flex-row">
Expand Down Expand Up @@ -170,7 +172,43 @@ export default function ManageUsers() {
</div>

<div className="pt-4">
<div>{manageUsers}</div>
<div className="mb-4 flex flex-col items-center justify-between gap-3 sm:flex-row">
<div className="flex-grow w-full">
<SearchByMultipleFields
id="search-by-username"
className="w-full"
onSearch={(key, value) => updateQuery({ username: value })}
options={[
{
key: "username",
label: "username",
type: "text" as const,
placeholder: t("search_by_username"),
value: qParams.username || "",
shortcutKey: "u",
},
]}
clearSearch={clearSearch}
/>
</div>
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList>
<TabsTrigger value="cardView" id="user-card-view">
<div className="flex items-center gap-2">
<CareIcon icon="l-credit-card" className="text-lg" />
<span>Card</span>
</div>
</TabsTrigger>
<TabsTrigger value="listView" id="user-list-view">
<div className="flex items-center gap-2" id="user-list-view">
<CareIcon icon="l-list-ul" className="text-lg" />
<span>List</span>
</div>
</TabsTrigger>
</TabsList>
</Tabs>
</div>
<div>{usersList}</div>
</div>
</Page>
);
Expand Down
Loading
Loading