Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions web/components/issues/sidebar-select/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Plus, X } from "lucide-react";
import { IIssue, IIssueLabels } from "types";
// fetch-keys
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
import useToast from "hooks/use-toast";

type Props = {
issueDetails: IIssue | undefined;
Expand All @@ -44,6 +45,9 @@ export const SidebarLabelSelect: React.FC<Props> = ({
const [createLabelForm, setCreateLabelForm] = useState(false);

const router = useRouter();

const { setToastAlert } = useToast();

const { workspaceSlug, projectId } = router.query;

const {
Expand Down Expand Up @@ -79,6 +83,14 @@ export const SidebarLabelSelect: React.FC<Props> = ({
submitChanges({ labels: [...(issueDetails?.labels ?? []), res.id] });

setCreateLabelForm(false);
})
.catch((error) => {
setToastAlert({
title: "Oops!",
type: "error",
message: error?.error ?? "Error while adding the label",
});
reset(formData);
});
};

Expand Down
10 changes: 9 additions & 1 deletion web/components/labels/create-label-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ChevronDown } from "lucide-react";
import type { IIssueLabels, IState } from "types";
// constants
import { LABEL_COLOR_OPTIONS, getRandomLabelColor } from "constants/label";
import useToast from "hooks/use-toast";

// types
type Props = {
Expand Down Expand Up @@ -58,6 +59,8 @@ export const CreateLabelModal: React.FC<Props> = observer((props) => {
reset(defaultValues);
};

const { setToastAlert } = useToast();

const onSubmit = async (formData: IIssueLabels) => {
if (!workspaceSlug) return;

Expand All @@ -68,7 +71,12 @@ export const CreateLabelModal: React.FC<Props> = observer((props) => {
if (onSuccess) onSuccess(res);
})
.catch((error) => {
console.log(error);
setToastAlert({
title: "Oops!",
type: "error",
message: error?.error ?? "Error while adding the label",
});
reset(formData);
});
};

Expand Down
29 changes: 25 additions & 4 deletions web/components/labels/create-update-label-inline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Button, Input } from "@plane/ui";
import { IIssueLabels } from "types";
// fetch-keys
import { getRandomLabelColor, LABEL_COLOR_OPTIONS } from "constants/label";
import useToast from "hooks/use-toast";

type Props = {
labelForm: boolean;
Expand All @@ -39,6 +40,8 @@ export const CreateUpdateLabelInline = observer(
// store
const { projectLabel: projectLabelStore } = useMobxStore();

const { setToastAlert } = useToast();

const {
handleSubmit,
control,
Expand All @@ -60,10 +63,20 @@ export const CreateUpdateLabelInline = observer(
const handleLabelCreate: SubmitHandler<IIssueLabels> = async (formData) => {
if (!workspaceSlug || !projectId || isSubmitting) return;

await projectLabelStore.createLabel(workspaceSlug.toString(), projectId.toString(), formData).then(() => {
handleClose();
reset(defaultValues);
});
await projectLabelStore
.createLabel(workspaceSlug.toString(), projectId.toString(), formData)
.then(() => {
handleClose();
reset(defaultValues);
})
.catch((error) => {
setToastAlert({
title: "Oops!",
type: "error",
message: error?.error ?? "Error while adding the label",
});
reset(formData);
});
};

const handleLabelUpdate: SubmitHandler<IIssueLabels> = async (formData) => {
Expand All @@ -74,6 +87,14 @@ export const CreateUpdateLabelInline = observer(
.then(() => {
reset(defaultValues);
handleClose();
})
.catch((error) => {
setToastAlert({
title: "Oops!",
type: "error",
message: error?.error ?? "Error while updating the label",
});
reset(formData);
});
};

Expand Down