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) => { export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
const { isOpen, handleClose, data, workspaceSlug, projectId } = props; const { isOpen, handleClose, data, workspaceSlug, projectId } = props;
// store // store
const { cycle: cycleStore, trackEvent: { postHogEventTracker } } = useMobxStore(); const {
cycle: cycleStore,
trackEvent: { postHogEventTracker },
} = useMobxStore();
// states // states
const [activeProject, setActiveProject] = useState<string>(projectId); const [activeProject, setActiveProject] = useState<string>(projectId);
// toast // toast
@ -41,26 +44,20 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
title: "Success!", title: "Success!",
message: "Cycle created successfully.", message: "Cycle created successfully.",
}); });
postHogEventTracker( postHogEventTracker("CYCLE_CREATE", {
"CYCLE_CREATE",
{
...res, ...res,
state: "SUCCESS", state: "SUCCESS",
} });
);
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: "Error in creating cycle. Please try again.", message: err.detail ?? "Error in creating cycle. Please try again.",
}); });
postHogEventTracker( postHogEventTracker("CYCLE_CREATE", {
"CYCLE_CREATE",
{
state: "FAILED", state: "FAILED",
} });
);
}); });
}; };
@ -76,11 +73,11 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
message: "Cycle updated successfully.", message: "Cycle updated successfully.",
}); });
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "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)); if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent));
} }
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: "Issue could not be created. Please try again.", message: err.detail ?? "Issue could not be created. Please try again.",
}); });
postHogEventTracker( postHogEventTracker(
"ISSUE_CREATED", "ISSUE_CREATED",
@ -312,11 +312,11 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = observer((prop
if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent)); if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent));
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "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({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: "Issue could not be updated. Please try again.", message: err.detail ?? "Issue could not be updated. Please try again.",
}); });
postHogEventTracker( postHogEventTracker(
"ISSUE_UPDATED", "ISSUE_UPDATED",

View File

@ -32,7 +32,11 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
const [activeProject, setActiveProject] = useState<string | null>(null); 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; const projects = workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : undefined;
@ -60,26 +64,20 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
title: "Success!", title: "Success!",
message: "Module created successfully.", message: "Module created successfully.",
}); });
postHogEventTracker( postHogEventTracker("MODULE_CREATED", {
"MODULE_CREATED",
{
...res, ...res,
state: "SUCCESS" state: "SUCCESS",
} });
);
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "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!", title: "Success!",
message: "Module updated successfully.", message: "Module updated successfully.",
}); });
postHogEventTracker( postHogEventTracker("MODULE_UPDATED", {
"MODULE_UPDATED",
{
...res, ...res,
state: "SUCCESS" state: "SUCCESS",
} });
);
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "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 { const {
page: { createPage, updatePage }, page: { createPage, updatePage },
trackEvent: { postHogEventTracker }, trackEvent: { postHogEventTracker },
workspace: { currentWorkspace } workspace: { currentWorkspace },
} = useMobxStore(); } = useMobxStore();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -56,24 +56,25 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
{ {
isGrouping: true, isGrouping: true,
groupType: "Workspace_metrics", groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id! gorupId: currentWorkspace?.id!,
} }
); );
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "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", state: "FAILED",
}, },
{ {
isGrouping: true, isGrouping: true,
groupType: "Workspace_metrics", groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id! gorupId: currentWorkspace?.id!,
} }
); );
}); });
@ -90,7 +91,8 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
title: "Success!", title: "Success!",
message: "Page updated successfully.", message: "Page updated successfully.",
}); });
postHogEventTracker("PAGE_UPDATED", postHogEventTracker(
"PAGE_UPDATED",
{ {
...res, ...res,
state: "SUCCESS", state: "SUCCESS",
@ -98,24 +100,25 @@ export const CreateUpdatePageModal: FC<Props> = (props) => {
{ {
isGrouping: true, isGrouping: true,
groupType: "Workspace_metrics", groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id! gorupId: currentWorkspace?.id!,
} }
); );
}) })
.catch(() => { .catch((err) => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "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", state: "FAILED",
}, },
{ {
isGrouping: true, isGrouping: true,
groupType: "Workspace_metrics", groupType: "Workspace_metrics",
gorupId: currentWorkspace?.id! gorupId: currentWorkspace?.id!,
} }
); );
}); });