1import{j as r}from"./vendor-maps-BkFXKbVz.js";import{u as _}from"./useUser-CA6-g9fl.js";import{d,e as b,n as j,r as N}from"./index-BlFipuMK.js";import{u as E,r as i}from"./vendor-react-iB9ODP_1.js";import{u as S}from"./vendor-i18n-Cw8D5MCt.js";import"./vendor-state-BcIU6khZ.js";import"./vendor-utils-iY4jI3ms.js";import"./vendor-antd-CuXAe93C.js";import"./vendor-forms-j-705dr2.js";import"./vendor-phone-VSINlmNE.js";import"./vendor-animation-DsbV8uj4.js";import"./vendor-realtime-ByZp_ck7.js";const U=()=>{const{t:e}=S(),[o]=E(),{isLoading:s}=_(),[x,l]=i.useState(!1),[y,u]=i.useState(""),[a,c]=i.useState(!1),p=i.useCallback((n,t)=>{if(t==="failed"||t==="canceled"||t==="expired")return e(`payment.error.${t}`)||e("payment.error.default");if(n)switch(n){case"card_declined":return e("payment.error.card_declined");case"insufficient_funds":return e("payment.error.insufficient_funds");case"expired_card":return e("payment.error.expired_card");case"invalid_cvc":return e("payment.error.invalid_cvc");case"processing_error":return e("payment.error.processing_error");case"authentication_required":return e("payment.error.authentication_required");case"rate_limit":return e("payment.error.rate_limit");default:return e("payment.error.default")}return e("payment.error.default")},[e]);i.useEffect(()=>{const n=o.get("error"),t=o.get("status"),g=o.get("ride_id");if(n||t&&["failed","canceled","expired"].includes(t)){l(!0);const m=p(n,t);u(m);return}g&&t!=="paid"&&(c(!0),d.getState().setLoading(!0),b.post(`/passenger/ride/finalize-payment/${g}`).then(()=>{d.getState().setLoading(!1),c(!1)}).catch(m=>{l(!0);const h=m?.response?.data?.message||e("payment.error.default");u(h),d.getState().setLoading(!1),c(!1)}))},[o,e,p]);const f=()=>{s||a||j(N.passenger.home)};return r.jsx("section",{id:"psg-payment-result",className:"mg-t100 mg-b100",children:r.jsx("div",{className:"psg-payment-result-container",children:r.jsx("div",{className:"max-w600 mg-0-auto psg-payment-result-main",children:x?r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-center font-32 font-w900 mg-b50 text-red",children:e("payment.error.title")}),r.jsx("p",{className:"text-center font-18 mg-b30",children:y}),r.jsx("button",{className:"w-100 pr-btn",onClick:f,disabled:s||a,children:e(s||a?"common.loading":"payment.error.button")})]}):r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-center font-32 font-w900 mg-b50",children:e("payment.success.title")}),r.jsx("p",{className:"text-center font-18 mg-b30",children:e("payment.success.message")}),r.jsx("button",{className:"w-100 pr-btn",onClick:f,disabled:s||a,children:e(s||a?"common.loading":"payment.success.button")})]})})})})};export{U as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.