Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahendar0701 committed Dec 18, 2024
1 parent 71ac706 commit db15f8b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/Routers/routes/ShiftingRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { getDefaultView } from "@/Utils/viewStorageUtils";

const ShiftingRoutes: AppRoutes = {
"/shifting": () => (
<Redirect
to={`/shifting/${getDefaultView("defaultShiftingView", "board")}`}
/>
<Redirect to={`/shifting/${getDefaultView("defaultShiftView", "board")}`} />
),
"/shifting/board": () => <BoardView />,
"/shifting/list": () => <ListView />,
Expand Down
5 changes: 1 addition & 4 deletions src/Routers/routes/UserRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import UserHome from "@/components/Users/UserHome";
import UserProfile from "@/components/Users/UserProfile";

import { AppRoutes } from "@/Routers/AppRouter";
import { getDefaultView } from "@/Utils/viewStorageUtils";

const UserRoutes: AppRoutes = {
"/users": () => (
<ManageUsers defaultView={getDefaultView("usersDefaultView", "card")} />
),
"/users": () => <ManageUsers />,
"/users/add": () => <UserAdd />,
"/users/:username": ({ username }) => (
<UserHome username={username} tab={"profile"} />
Expand Down
3 changes: 2 additions & 1 deletion src/components/Resource/ResourceBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { RESOURCE_CHOICES } from "@/common/constants";

import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import { setDefaultView } from "@/Utils/viewStorageUtils";

const KanbanBoard = lazy(
() => import("@/components/Kanban/Board"),
Expand All @@ -47,7 +48,7 @@ export default function BoardView() {

const onListViewBtnClick = () => {
navigate("/resource/list", { query: qParams });
localStorage.setItem("defaultResourceView", "list");
setDefaultView("defaultResourceView", "list");
};

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Resource/ResourceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import useTanStackQueryInstead from "@/Utils/request/useQuery";
import { formatDateTime } from "@/Utils/utils";
import { setDefaultView } from "@/Utils/viewStorageUtils";

export default function ListView() {
const {
Expand All @@ -37,7 +38,7 @@ export default function ListView() {

const onBoardViewBtnClick = () => {
navigate("/resource/board", { query: qParams });
localStorage.setItem("defaultResourceView", "board");
setDefaultView("defaultResourceView", "board");
};
const appliedFilters = formatFilter(qParams);

Expand Down
3 changes: 2 additions & 1 deletion src/components/Shifting/ShiftingBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {

import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import { setDefaultView } from "@/Utils/viewStorageUtils";

const KanbanBoard = lazy(
() => import("@/components/Kanban/Board"),
Expand Down Expand Up @@ -78,7 +79,7 @@ export default function BoardView() {
const { t } = useTranslation();
const onListViewBtnClick = () => {
navigate("/shifting/list", { query: qParams });
localStorage.setItem("defaultShiftView", "list");
setDefaultView("defaultShiftView", "list");
};

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Shifting/ShiftingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import useFilters from "@/hooks/useFilters";
import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import useTanStackQueryInstead from "@/Utils/request/useQuery";
import { setDefaultView } from "@/Utils/viewStorageUtils";

import ShiftingTable from "./ShiftingTable";

Expand All @@ -35,7 +36,7 @@ export default function ListView() {
const { t } = useTranslation();
const onBoardViewBtnClick = () => {
navigate("/shifting/board", { query: qParams });
localStorage.setItem("defaultShiftView", "board");
setDefaultView("defaultShiftView", "board");
};
const {
data: shiftData,
Expand Down
8 changes: 5 additions & 3 deletions src/components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import useTanStackQueryInstead from "@/Utils/request/useQuery";
import { classNames } from "@/Utils/utils";
import { setDefaultView } from "@/Utils/viewStorageUtils";
import { getDefaultView, setDefaultView } from "@/Utils/viewStorageUtils";

export default function ManageUsers({ defaultView }: { defaultView: string }) {
export default function ManageUsers() {
const { t } = useTranslation();
const {
qParams,
Expand All @@ -48,7 +48,9 @@ export default function ManageUsers({ defaultView }: { defaultView: string }) {
const userTypes = authUser.is_superuser
? [...USER_TYPES]
: USER_TYPES.slice(0, userIndex + 1);
const [activeTab, setActiveTab] = useState(defaultView === "list" ? 1 : 0);
const [activeTab, setActiveTab] = useState(
getDefaultView("usersDefaultView", "card") === "list" ? 1 : 0,
);

const { data: homeFacilityData } = useTanStackQueryInstead(
routes.getAnyFacility,
Expand Down

0 comments on commit db15f8b

Please sign in to comment.