-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7538099
commit abde28e
Showing
7 changed files
with
44 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
frontend/app/src/shared/components/layout/menu-navigation/domain/get-menu.query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DEFAULT_BRANCH_NAME } from "@/config/constants"; | ||
import { currentBranchAtom } from "@/entities/branches/stores"; | ||
import { getMenu } from "@/shared/components/layout/menu-navigation/domain/get-menu"; | ||
import { queryOptions, useQuery } from "@tanstack/react-query"; | ||
import { useAtomValue } from "jotai"; | ||
|
||
export function menuQueryOptions({ branchName }: { branchName: string }) { | ||
return queryOptions({ | ||
queryKey: [branchName, "menu"], | ||
queryFn: () => getMenu({ branchName }), | ||
}); | ||
} | ||
|
||
export function useMenu() { | ||
const currentBranch = useAtomValue(currentBranchAtom); | ||
|
||
return useQuery(menuQueryOptions({ branchName: currentBranch?.name ?? DEFAULT_BRANCH_NAME })); | ||
} |
18 changes: 18 additions & 0 deletions
18
frontend/app/src/shared/components/layout/menu-navigation/domain/get-menu.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { apiClient } from "@/shared/api/rest/client"; | ||
import { MenuData } from "@/shared/components/layout/menu-navigation/types"; | ||
|
||
type GetMenu = ({ branchName }: { branchName: string }) => Promise<MenuData>; | ||
|
||
export const getMenu: GetMenu = async ({ branchName }) => { | ||
const { data, error } = await apiClient.GET("/api/menu", { | ||
params: { | ||
query: { | ||
branch: branchName, | ||
}, | ||
}, | ||
}); | ||
|
||
if (error) throw error; | ||
|
||
return data as MenuData; | ||
}; |
32 changes: 0 additions & 32 deletions
32
frontend/app/src/shared/components/layout/menu-navigation/get-menu.ts
This file was deleted.
Oops, something went wrong.
5 changes: 2 additions & 3 deletions
5
frontend/app/src/shared/components/layout/menu-navigation/menu-navigation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters