diff --git a/web/components/cycles/modal.tsx b/web/components/cycles/modal.tsx index 652b66098..665f9865b 100644 --- a/web/components/cycles/modal.tsx +++ b/web/components/cycles/modal.tsx @@ -24,7 +24,10 @@ const cycleService = new CycleService(); export const CycleCreateUpdateModal: React.FC = (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(projectId); // toast @@ -41,26 +44,20 @@ export const CycleCreateUpdateModal: React.FC = (props) => { title: "Success!", message: "Cycle created successfully.", }); - postHogEventTracker( - "CYCLE_CREATE", - { - ...res, - state: "SUCCESS", - } - ); + 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", { + state: "FAILED", }); - postHogEventTracker( - "CYCLE_CREATE", - { - state: "FAILED", - } - ); }); }; @@ -76,11 +73,11 @@ export const CycleCreateUpdateModal: React.FC = (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.", }); }); }; diff --git a/web/components/issues/modal.tsx b/web/components/issues/modal.tsx index e195d21bf..b5518b217 100644 --- a/web/components/issues/modal.tsx +++ b/web/components/issues/modal.tsx @@ -266,11 +266,11 @@ export const CreateUpdateIssueModal: React.FC = 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 = 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 = 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", diff --git a/web/components/modules/modal.tsx b/web/components/modules/modal.tsx index 2eda52bc1..da4103833 100644 --- a/web/components/modules/modal.tsx +++ b/web/components/modules/modal.tsx @@ -32,7 +32,11 @@ export const CreateUpdateModuleModal: React.FC = observer((props) => { const [activeProject, setActiveProject] = useState(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 = observer((props) => { title: "Success!", message: "Module created successfully.", }); - postHogEventTracker( - "MODULE_CREATED", - { - ...res, - state: "SUCCESS" - } - ); + postHogEventTracker("MODULE_CREATED", { + ...res, + 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 = observer((props) => { title: "Success!", message: "Module updated successfully.", }); - postHogEventTracker( - "MODULE_UPDATED", - { - ...res, - state: "SUCCESS" - } - ); + postHogEventTracker("MODULE_UPDATED", { + ...res, + 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" - } - ); }); }; diff --git a/web/components/pages/create-update-page-modal.tsx b/web/components/pages/create-update-page-modal.tsx index 979622ec7..519219a7f 100644 --- a/web/components/pages/create-update-page-modal.tsx +++ b/web/components/pages/create-update-page-modal.tsx @@ -26,7 +26,7 @@ export const CreateUpdatePageModal: FC = (props) => { const { page: { createPage, updatePage }, trackEvent: { postHogEventTracker }, - workspace: { currentWorkspace } + workspace: { currentWorkspace }, } = useMobxStore(); const { setToastAlert } = useToast(); @@ -56,24 +56,25 @@ export const CreateUpdatePageModal: FC = (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) => { title: "Success!", message: "Page updated successfully.", }); - postHogEventTracker("PAGE_UPDATED", + postHogEventTracker( + "PAGE_UPDATED", { ...res, state: "SUCCESS", @@ -98,24 +100,25 @@ export const CreateUpdatePageModal: FC = (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!, } ); });