diff --git a/src/features/visaMasterPayments/api/visaMasterPaymentsApi.ts b/src/features/visaMasterPayments/api/visaMasterPaymentsApi.ts index 24969e2..b6cea99 100644 --- a/src/features/visaMasterPayments/api/visaMasterPaymentsApi.ts +++ b/src/features/visaMasterPayments/api/visaMasterPaymentsApi.ts @@ -25,6 +25,12 @@ export interface PayPayload { paymentPeriod: string; // "YYYY-MM-DD" } +export interface PayResponse { + paymentId?: number; + formUrl?: string; + [key: string]: unknown; +} + /** Kabul ediji + Upgradyý resminamalar (15 sany) — hem UI hem Payload ortak */ export interface IntlPaymentDocs { doc_sberbank_account: string | null; @@ -382,7 +388,9 @@ export const intlPaymentApi = { return data; }, - async pay(id: string, payload: PayPayload): Promise { - await apiClient.post(`/visa-master-payment-orders/${id}/pay`, payload); + async pay(id: string, payload: PayPayload): Promise { + const res = await apiClient.post(`/visa-master-payment-orders/${id}/pay`, payload); + const data = res.data?.data ?? res.data; + return data as PayResponse; }, }; diff --git a/src/features/visaMasterPayments/hooks/useVisaMasterPayments.ts b/src/features/visaMasterPayments/hooks/useVisaMasterPayments.ts index 038c1da..3cbf625 100644 --- a/src/features/visaMasterPayments/hooks/useVisaMasterPayments.ts +++ b/src/features/visaMasterPayments/hooks/useVisaMasterPayments.ts @@ -88,9 +88,15 @@ export function usePayIntlPayment() { const { t } = useTranslation(); return useMutation({ mutationFn: ({ id, payload }: { id: string; payload: PayPayload }) => intlPaymentApi.pay(id, payload), - onSuccess: () => { + onSuccess: (data) => { qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() }); toast.success(t("intlPayment.paySuccess", "Töleg üstünlikli amala aşyryldy")); + if (data?.formUrl) { + const newWindow = window.open(data.formUrl, "_blank"); + if (!newWindow || newWindow.closed || typeof newWindow.closed === "undefined") { + window.location.href = data.formUrl; + } + } }, }); } diff --git a/src/index.css b/src/index.css index f01b9ce..101cfa6 100644 --- a/src/index.css +++ b/src/index.css @@ -90,6 +90,7 @@ --sidebar-accent-foreground: oklch(0.21 0.006 285.885); --sidebar-border: oklch(0.92 0.004 286.32); --sidebar-ring: oklch(0.705 0.015 286.067); + --link-color: #18b69b; } .dark {