Added remove from scoreboard functionality BOD-91

This commit is contained in:
Patrick Fic
2020-06-29 09:58:54 -07:00
parent 3df456e2dd
commit 5650a66916
8 changed files with 217 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { Button, notification } from "antd";
import { DeleteFilled } from "@ant-design/icons";
import { useMutation } from "@apollo/react-hooks";
import { DELETE_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries";
export default function ScoreboardRemoveButton({ scoreboardId }) {
const { t } = useTranslation();
const [deleteScoreboardEntry] = useMutation(DELETE_SCOREBOARD_ENTRY);
const [loading, setLoading] = useState(false);
const handleDelete = async (e) => {
e.stopPropagation();
setLoading(true);
const result = await deleteScoreboardEntry({
variables: { sbId: scoreboardId },
});
if (!!result.errors) {
notification["error"]({
message: t("scoreboard.errors.removing", {
message: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
};
return (
<Button onClick={handleDelete} loading={loading}>
<DeleteFilled />
</Button>
);
}