feat: add boards management page (#55)

This commit is contained in:
Manuel
2024-02-09 22:20:28 +01:00
committed by GitHub
parent 81e61b4d6b
commit 5ef79edc1a
8 changed files with 152 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
"use client";
import React from "react";
import { clientApi } from "@homarr/api/client";
import { useI18n } from "@homarr/translation/client";
import { Button } from "@homarr/ui";
import { revalidatePathAction } from "~/app/revalidatePathAction";
export const CreateBoardButton = () => {
const t = useI18n();
const { mutateAsync, isPending } = clientApi.board.create.useMutation({
onSettled: async () => {
await revalidatePathAction("/manage/boards");
},
});
const onClick = React.useCallback(async () => {
await mutateAsync({ name: "default" });
}, [mutateAsync]);
return (
<Button onClick={onClick} loading={isPending}>
{t("management.page.board.button.create")}
</Button>
);
};

View File

@@ -0,0 +1,34 @@
"use client";
import React from "react";
import { clientApi } from "@homarr/api/client";
import { useI18n } from "@homarr/translation/client";
import { Button } from "@homarr/ui";
import { revalidatePathAction } from "~/app/revalidatePathAction";
interface Props {
id: string;
}
export const DeleteBoardButton = ({ id }: Props) => {
const t = useI18n();
const { mutateAsync, isPending } = clientApi.board.delete.useMutation({
onSettled: async () => {
await revalidatePathAction("/manage/boards");
},
});
const onClick = React.useCallback(async () => {
await mutateAsync({
id,
});
}, [id, mutateAsync]);
return (
<Button onClick={onClick} loading={isPending} color="red">
{t("management.page.board.button.delete")}
</Button>
);
};