mirror of
https://github.com/rustfs/console.git
synced 2026-08-29 03:52:28 +08:00
29 lines
712 B
TypeScript
29 lines
712 B
TypeScript
"use client"
|
|
|
|
import { useCallback } from "react"
|
|
import { useApi } from "@/contexts/api-context"
|
|
import type { ModuleSwitchPayload, ModuleSwitchSnapshot } from "@/lib/module-switches"
|
|
|
|
export function useModuleSwitches() {
|
|
const api = useApi()
|
|
|
|
const getModuleSwitches = useCallback(
|
|
async (options?: { suppress403Redirect?: boolean }) => {
|
|
return (await api.get("/module-switches", options)) as ModuleSwitchSnapshot
|
|
},
|
|
[api],
|
|
)
|
|
|
|
const saveModuleSwitches = useCallback(
|
|
async (payload: ModuleSwitchPayload) => {
|
|
return (await api.put("/module-switches", payload)) as ModuleSwitchSnapshot
|
|
},
|
|
[api],
|
|
)
|
|
|
|
return {
|
|
getModuleSwitches,
|
|
saveModuleSwitches,
|
|
}
|
|
}
|