Skip to content

Commit

Permalink
feat(dashboard/invoice): made create invoice modal route to invoice v…
Browse files Browse the repository at this point in the history
…iew after completion
  • Loading branch information
CodeNamedRobin committed Aug 14, 2024
1 parent 2ce49d1 commit 5ad7b98
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ import { createInvoiceSchema } from "@/utils/validation-schema";
import UserLink from "@/components/UserLink.vue";
import InputSpan from "@/components/InputSpan.vue";
import {useInvoiceStore} from "@/stores/invoice.store";
import type {CreateInvoiceRequest} from "@sudosos/sudosos-client";
import type {CreateInvoiceRequest, InvoiceResponse} from "@sudosos/sudosos-client";
import {handleError} from "@/utils/errorUtils";
import {useToast} from "primevue/usetoast";
import {useRouter} from "vue-router";
const props = defineProps({
form: {
Expand All @@ -87,6 +88,7 @@ const props = defineProps({
const { t } = useI18n();
const invoiceStore = useInvoiceStore();
const toast = useToast();
const router = useRouter();
const emit = defineEmits(['submit:success', 'submit:error']);
Expand All @@ -105,7 +107,8 @@ setSubmit(props.form, props.form.context.handleSubmit(async (values) => {
country: values.country,
attention: values.attention,
};
await invoiceStore.createInvoice(request).then(() => {
await invoiceStore.createInvoice(request).then((res: InvoiceResponse) => {
const invoiceId = res.id;
emit('submit:success', request);
toast.add({
severity: 'success',
Expand All @@ -114,6 +117,7 @@ setSubmit(props.form, props.form.context.handleSubmit(async (values) => {
life: 3000,
});
props.form.context.resetForm();
router.push({ name: "invoiceInfo", params: { id: invoiceId } });
}).catch((err) => {
emit('submit:error', err);
handleError(err, toast);
Expand Down

0 comments on commit 5ad7b98

Please sign in to comment.