feat: UI bind api service toggling
This commit is contained in:
@ -2,7 +2,7 @@ import Breadcrumbs from "@/components/ui/breadcrumbs";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { useAdmin } from "@/store/admin";
|
import { useAdmin } from "@/store/admin";
|
||||||
import { useEffect, type FC } from "react";
|
import { useCallback, useEffect, type FC } from "react";
|
||||||
import { Link, useParams } from "react-router";
|
import { Link, useParams } from "react-router";
|
||||||
|
|
||||||
const InfoCard = ({
|
const InfoCard = ({
|
||||||
@ -29,6 +29,9 @@ const ViewApiServicePage: FC = () => {
|
|||||||
|
|
||||||
const loadService = useAdmin((state) => state.fetchApiService);
|
const loadService = useAdmin((state) => state.fetchApiService);
|
||||||
|
|
||||||
|
const toggling = useAdmin((state) => state.togglingApiService);
|
||||||
|
const toggle = useAdmin((state) => state.toggleApiService);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof serviceId === "string") loadService(serviceId);
|
if (typeof serviceId === "string") loadService(serviceId);
|
||||||
}, [loadService, serviceId]);
|
}, [loadService, serviceId]);
|
||||||
@ -181,7 +184,8 @@ const ViewApiServicePage: FC = () => {
|
|||||||
? "text-red-400 hover:text-red-500"
|
? "text-red-400 hover:text-red-500"
|
||||||
: "text-green-400 hover:text-green-500"
|
: "text-green-400 hover:text-green-500"
|
||||||
}
|
}
|
||||||
onClick={() => {}}
|
onClick={toggle}
|
||||||
|
loading={toggling}
|
||||||
>
|
>
|
||||||
{apiService.is_active ? "Disable" : "Enable"}
|
{apiService.is_active ? "Disable" : "Enable"}
|
||||||
</Button>
|
</Button>
|
||||||
|
Reference in New Issue
Block a user