MED-56: show specific error when job taken, other small improvements (#58)
* show specific error when job taken, other small improvements * enum name case * enum value case, actually
This commit is contained in:
@@ -86,27 +86,23 @@ export default function AnalysisView({
|
||||
data: DoctorAnalysisFeedbackForm,
|
||||
status: 'DRAFT' | 'COMPLETED',
|
||||
) => {
|
||||
try {
|
||||
const feedbackPromise = giveFeedbackAction({
|
||||
...data,
|
||||
analysisOrderId: order.analysisOrderId,
|
||||
status,
|
||||
});
|
||||
const result = await giveFeedbackAction({
|
||||
...data,
|
||||
analysisOrderId: order.analysisOrderId,
|
||||
status,
|
||||
});
|
||||
|
||||
toast.promise(() => feedbackPromise, {
|
||||
success: <Trans i18nKey={'doctor:updateFeedbackSuccess'} />,
|
||||
error: <Trans i18nKey={'doctor:updateFeedbackError'} />,
|
||||
loading: <Trans i18nKey={'doctor:updateFeedbackLoading'} />,
|
||||
});
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
predicate: (query) => query.queryKey.includes('doctor-jobs'),
|
||||
});
|
||||
|
||||
return setIsConfirmOpen(false);
|
||||
} catch (error) {
|
||||
toast.error(<Trans i18nKey="common:genericServerError" />);
|
||||
if (!result.success) {
|
||||
return toast.error(<Trans i18nKey="common:genericServerError" />);
|
||||
}
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
predicate: (query) => query.queryKey.includes('doctor-jobs'),
|
||||
});
|
||||
|
||||
toast.success(<Trans i18nKey={'doctor:updateFeedbackSuccess'} />);
|
||||
|
||||
return setIsConfirmOpen(false);
|
||||
};
|
||||
|
||||
const handleDraftSubmit = async (e: React.FormEvent) => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
selectJobAction,
|
||||
unselectJobAction,
|
||||
} from '@kit/doctor/actions/doctor-server-actions';
|
||||
import { ErrorReason } from '@kit/doctor/schema/error.type';
|
||||
import { Button, ButtonProps } from '@kit/ui/button';
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
@@ -50,7 +51,14 @@ export default function DoctorJobSelect({
|
||||
onJobUpdate();
|
||||
linkTo && router.push(linkTo);
|
||||
} else {
|
||||
toast.error('common.genericServerError');
|
||||
toast.error(
|
||||
<Trans
|
||||
i18nKey={`doctor:error.${result.reason ?? ErrorReason.UNKNOWN}`}
|
||||
/>,
|
||||
);
|
||||
if (result.reason === ErrorReason.JOB_ASSIGNED) {
|
||||
onJobUpdate();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -64,7 +72,11 @@ export default function DoctorJobSelect({
|
||||
if (result?.success) {
|
||||
onJobUpdate();
|
||||
} else {
|
||||
toast.error('common.genericServerError');
|
||||
toast.error(
|
||||
<Trans
|
||||
i18nKey={`doctor:error.${result.reason ?? ErrorReason.UNKNOWN}`}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user