- Merge client update into test-beta
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
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/client";
|
||||
import { DELETE_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
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/client";
|
||||
import {DELETE_SCOREBOARD_ENTRY} from "../../graphql/scoreboard.queries";
|
||||
import {logImEXEvent} from "../../firebase/firebase.utils";
|
||||
|
||||
export default function ScoreboardRemoveButton({ scoreboardId }) {
|
||||
const { t } = useTranslation();
|
||||
const [deleteScoreboardEntry] = useMutation(DELETE_SCOREBOARD_ENTRY);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const handleDelete = async (e) => {
|
||||
logImEXEvent("scoreboard_remove_job");
|
||||
export default function ScoreboardRemoveButton({scoreboardId}) {
|
||||
const {t} = useTranslation();
|
||||
const [deleteScoreboardEntry] = useMutation(DELETE_SCOREBOARD_ENTRY);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const handleDelete = async (e) => {
|
||||
logImEXEvent("scoreboard_remove_job");
|
||||
|
||||
e.stopPropagation();
|
||||
setLoading(true);
|
||||
const result = await deleteScoreboardEntry({
|
||||
variables: { sbId: scoreboardId },
|
||||
awaitRefetchQueries: true,
|
||||
refetchQueries: ["QUERY_SCOREBOARD_PAGINATED"],
|
||||
});
|
||||
e.stopPropagation();
|
||||
setLoading(true);
|
||||
const result = await deleteScoreboardEntry({
|
||||
variables: {sbId: scoreboardId},
|
||||
awaitRefetchQueries: true,
|
||||
refetchQueries: ["QUERY_SCOREBOARD_PAGINATED"],
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("scoreboard.errors.removing", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("scoreboard.successes.removed"),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
return (
|
||||
<Button onClick={handleDelete} loading={loading}>
|
||||
<DeleteFilled />
|
||||
</Button>
|
||||
);
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("scoreboard.errors.removing", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("scoreboard.successes.removed"),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
return (
|
||||
<Button onClick={handleDelete} loading={loading}>
|
||||
<DeleteFilled/>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user