fix: proper toast message for lower roles

This commit is contained in:
LAKHAN BAHETI 2023-12-08 16:18:23 +05:30
parent 1ff0538077
commit 24f993dbee
4 changed files with 59 additions and 67 deletions

View File

@ -24,7 +24,10 @@ const cycleService = new CycleService();
export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
const { isOpen, handleClose, data, workspaceSlug, projectId } = props;
// store
const { cycle: cycleStore, trackEvent: { postHogEventTracker } } = useMobxStore();
const {
cycle: cycleStore,
trackEvent: { postHogEventTracker },
} = useMobxStore();
// states
const [activeProject, setActiveProject] = useState<string>(projectId);
// toast
@ -41,26 +44,20 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
title: "Success!",
message: "Cycle created successfully.",
});
postHogEventTracker(
"CYCLE_CREATE",
{
postHogEventTracker("CYCLE_CREATE", {
...res,
state: "SUCCESS",
}
);
});
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Error in creating cycle. Please try again.",
message: err.detail ?? "Error in creating cycle. Please try again.",
});
postHogEventTracker(
"CYCLE_CREATE",
{
postHogEventTracker("CYCLE_CREATE", {
state: "FAILED",
}
);
});
});
};
@ -76,11 +73,11 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
message: "Cycle updated successfully.",
});
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Error in updating cycle. Please try again.",
message: err.detail ?? "Error in updating cycle. Please try again.",
});
});
};

View File

@ -266,11 +266,11 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = observer((prop
if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent));
}
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Issue could not be created. Please try again.",
message: err.detail ?? "Issue could not be created. Please try again.",
});
postHogEventTracker(
"ISSUE_CREATED",
@ -312,11 +312,11 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = observer((prop
if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent));
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Issue could not be created. Please try again.",
message: err.detail ?? "Issue could not be created. Please try again.",
});
});
};
@ -347,11 +347,11 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = observer((prop
}
);
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Issue could not be updated. Please try again.",
message: err.detail ?? "Issue could not be updated. Please try again.",
});
postHogEventTracker(
"ISSUE_UPDATED",

View File

@ -32,7 +32,11 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
const [activeProject, setActiveProject] = useState<string | null>(null);
const { project: projectStore, module: moduleStore, trackEvent: { postHogEventTracker } } = useMobxStore();
const {
project: projectStore,
module: moduleStore,
trackEvent: { postHogEventTracker },
} = useMobxStore();
const projects = workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : undefined;
@ -60,26 +64,20 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
title: "Success!",
message: "Module created successfully.",
});
postHogEventTracker(
"MODULE_CREATED",
{
postHogEventTracker("MODULE_CREATED", {
...res,
state: "SUCCESS"
}
);
state: "SUCCESS",
});
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Module could not be created. Please try again.",
message: err.detail ?? "Module could not be created. Please try again.",
});
postHogEventTracker("MODULE_CREATED", {
state: "FAILED",
});
postHogEventTracker(
"MODULE_CREATED",
{
state: "FAILED"
}
);
});
};
@ -96,26 +94,20 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
title: "Success!",
message: "Module updated successfully.",
});
postHogEventTracker(
"MODULE_UPDATED",
{
postHogEventTracker("MODULE_UPDATED", {
...res,
state: "SUCCESS"
}
);
state: "SUCCESS",
});
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Module could not be updated. Please try again.",
message: err.detail ?? "Module could not be updated. Please try again.",
});
postHogEventTracker("MODULE_UPDATED", {
state: "FAILED",
});
postHogEventTracker(
"MODULE_UPDATED",
{
state: "FAILED"
}
);
});
};

View File

@ -26,7 +26,7 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
const {
page: { createPage, updatePage },
trackEvent: { postHogEventTracker },
workspace: { currentWorkspace }
workspace: { currentWorkspace },
} = useMobxStore();
const { setToastAlert } = useToast();
@ -56,24 +56,25 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
gorupId: currentWorkspace?.id!,
}
);
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Page could not be created. Please try again.",
message: err.detail ?? "Page could not be created. Please try again.",
});
postHogEventTracker("PAGE_CREATED",
postHogEventTracker(
"PAGE_CREATED",
{
state: "FAILED",
},
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
gorupId: currentWorkspace?.id!,
}
);
});
@ -90,7 +91,8 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
title: "Success!",
message: "Page updated successfully.",
});
postHogEventTracker("PAGE_UPDATED",
postHogEventTracker(
"PAGE_UPDATED",
{
...res,
state: "SUCCESS",
@ -98,24 +100,25 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
gorupId: currentWorkspace?.id!,
}
);
})
.catch(() => {
.catch((err) => {
setToastAlert({
type: "error",
title: "Error!",
message: "Page could not be updated. Please try again.",
message: err.detail ?? "Page could not be updated. Please try again.",
});
postHogEventTracker("PAGE_UPDATED",
postHogEventTracker(
"PAGE_UPDATED",
{
state: "FAILED",
},
{
isGrouping: true,
groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id!
gorupId: currentWorkspace?.id!,
}
);
});