draft toast modification done for production
This commit is contained in:
parent
c7ffc475f9
commit
1391e2d2f5
@ -234,10 +234,6 @@ function AppRoutes({ onLogout }: AppProps) {
|
|||||||
setDynamicRequests([...dynamicRequests, newCustomRequest]);
|
setDynamicRequests([...dynamicRequests, newCustomRequest]);
|
||||||
|
|
||||||
navigate('/my-requests');
|
navigate('/my-requests');
|
||||||
toast.success('Request Submitted Successfully!', {
|
|
||||||
description: `Your request "${requestData.title}" (${requestId}) has been created and sent for approval.`,
|
|
||||||
duration: 5000,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleApprovalSubmit = (action: 'approve' | 'reject', _comment: string) => {
|
const handleApprovalSubmit = (action: 'approve' | 'reject', _comment: string) => {
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import { FormData, RequestTemplate } from '@/hooks/useCreateRequestForm';
|
import { FormData, RequestTemplate } from '@/hooks/useCreateRequestForm';
|
||||||
import {
|
import {
|
||||||
buildCreatePayload,
|
buildCreatePayload,
|
||||||
@ -72,6 +73,12 @@ export function useCreateRequestSubmission({
|
|||||||
documentsToDelete
|
documentsToDelete
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Show toast after backend confirmation
|
||||||
|
toast.success('Request Submitted Successfully!', {
|
||||||
|
description: `Your request "${formData.title}" has been submitted and sent for approval.`,
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
onSubmit?.({
|
onSubmit?.({
|
||||||
...formData,
|
...formData,
|
||||||
backendId: editRequestId,
|
backendId: editRequestId,
|
||||||
@ -87,14 +94,24 @@ export function useCreateRequestSubmission({
|
|||||||
|
|
||||||
const result = await createAndSubmitWorkflow(createPayload, documents);
|
const result = await createAndSubmitWorkflow(createPayload, documents);
|
||||||
|
|
||||||
|
// Show toast after backend confirmation
|
||||||
|
toast.success('Request Submitted Successfully!', {
|
||||||
|
description: `Your request "${formData.title}" has been created and sent for approval.`,
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
onSubmit?.({
|
onSubmit?.({
|
||||||
...formData,
|
...formData,
|
||||||
backendId: result.id,
|
backendId: result.id,
|
||||||
template: selectedTemplate,
|
template: selectedTemplate,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.error('Failed to submit workflow:', error);
|
console.error('Failed to submit workflow:', error);
|
||||||
|
toast.error('Failed to Submit Request', {
|
||||||
|
description: error?.response?.data?.message || error?.message || 'An error occurred while submitting the request.',
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -130,6 +147,11 @@ export function useCreateRequestSubmission({
|
|||||||
documentsToDelete
|
documentsToDelete
|
||||||
);
|
);
|
||||||
|
|
||||||
|
toast.success('Draft Saved Successfully!', {
|
||||||
|
description: `Your request "${formData.title}" has been saved as draft.`,
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
onSubmit?.({
|
onSubmit?.({
|
||||||
...formData,
|
...formData,
|
||||||
backendId: editRequestId,
|
backendId: editRequestId,
|
||||||
@ -145,14 +167,23 @@ export function useCreateRequestSubmission({
|
|||||||
|
|
||||||
const result = await createWorkflow(createPayload, documents);
|
const result = await createWorkflow(createPayload, documents);
|
||||||
|
|
||||||
|
toast.success('Draft Saved Successfully!', {
|
||||||
|
description: `Your request "${formData.title}" has been saved as draft.`,
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
onSubmit?.({
|
onSubmit?.({
|
||||||
...formData,
|
...formData,
|
||||||
backendId: result.id,
|
backendId: result.id,
|
||||||
template: selectedTemplate,
|
template: selectedTemplate,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.error('Failed to save draft:', error);
|
console.error('Failed to save draft:', error);
|
||||||
|
toast.error('Failed to Save Draft', {
|
||||||
|
description: error?.response?.data?.message || error?.message || 'An error occurred while saving the draft.',
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
setSavingDraft(false);
|
setSavingDraft(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user