Skip to content

Commit

Permalink
fix(comps): remove invalid /cases/new route on error / invalid inci…
Browse files Browse the repository at this point in the history
…dent id for CaseHistory & CaseFlag

Signed-off-by: Deep Panchal <[email protected]>
  • Loading branch information
deepanchal committed Oct 7, 2024
1 parent 8021175 commit 8f8d63f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/components/work/CaseFlag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ import { What3wordsService } from '../../services/what3words.service';
import useCurrentUser from '../../hooks/useCurrentUser';
import type { CaseFlag } from '@/models/types';
import type Incident from '@/models/Incident';
import { getErrorMessage } from '@/utils/errors';
export default defineComponent({
name: 'CaseFlag',
Expand Down Expand Up @@ -464,8 +465,6 @@ export default defineComponent({
emit('reloadMap', props.worksiteId || route.params.id);
if (props.incidentId) {
emit('clearCase');
} else {
await router.push(`/incident/${route.params.incident_id}/cases/new`);
}
return;
Expand Down Expand Up @@ -559,10 +558,9 @@ export default defineComponent({
props.worksiteId || route.params.id,
props.incidentId || route.params.incident_id,
);
} catch {
await router.push(
`/incident/${props.incidentId || route.params.incident_id}/cases/new`,
);
} catch (error) {
console.error(error);
getErrorMessage(error);
} finally {
ready.value = true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/work/CaseHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import User from '@/models/User';
import Organization from '@/models/Organization';
import { groupBy } from '@/utils/array';
import Worksite from '@/models/Worksite';
import { getErrorMessage } from '@/utils/errors';
export default defineComponent({
name: 'CaseHistory',
Expand Down Expand Up @@ -104,10 +105,9 @@ export default defineComponent({
const result = await Worksite.api().getHistory(props.worksiteId);
worksiteHistory.value = result.response.data;
} catch {
await router.push(
`/incident/${props.incidentId || route.params.incident_id}/cases/new`,
);
} catch (error) {
console.error(error);
getErrorMessage(error);
} finally {
ready.value = true;
}
Expand Down

0 comments on commit 8f8d63f

Please sign in to comment.