mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 18:26:16 +00:00
1 line
4.3 KiB
JavaScript
1 line
4.3 KiB
JavaScript
import{S as e,_ as t,a as n,af as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,nf as p,o as m,p as h,s as g,tf as _,u as v,v as y,x as b,y as x}from"./messages-BvSF842O.js";import{t as S}from"./button-D5xmeb32.js";import{t as C}from"./switch-BajFvU9H.js";import{a as w,c as T,s as E}from"./zod-ClGKjEyB.js";import{a as D,c as O,i as k,l as A,n as j,o as M,r as N,s as P,t as F}from"./form-iIuz3zSX.js";import{t as I}from"./input-CPAfWtuT.js";import{t as L}from"./password-input-Kp1mG33l.js";import{t as R}from"./page-header-D58MnYJU.js";import{a as z,i as B,n as V,t as H}from"./lib-CVxH5aBl.js";var U=r(p(),1),W=_(),G=E({allowTokens:T(),apiUrl:T(),callbackUrl:T().url(s()),enabled:w(),returnUrl:T(),shopId:T().min(1,t()),shopToken:T().min(1,l()),timeoutSeconds:T().min(1,d()).refine(e=>Number.isInteger(Number(e))&&Number(e)>0,{message:a()})});function K(){let e=B(`okpay`),t=z(),r=A({resolver:O(G),defaultValues:{allowTokens:`USDT`,apiUrl:``,callbackUrl:``,enabled:!1,returnUrl:``,shopId:``,shopToken:``,timeoutSeconds:`600`}});(0,U.useEffect)(()=>{let t=e.data?.data;t&&r.reset({allowTokens:q(H(t,`okpay.allow_tokens`,`USDT`)).join(`,`),apiUrl:H(t,`okpay.api_url`),callbackUrl:H(t,`okpay.callback_url`),enabled:[`1`,`true`,`yes`].includes(H(t,`okpay.enabled`).toLowerCase()),returnUrl:H(t,`okpay.return_url`),shopId:H(t,`okpay.shop_id`),shopToken:H(t,`okpay.shop_token`),timeoutSeconds:H(t,`okpay.timeout_seconds`,`600`)})},[e.data,r]);async function a(n){await V(t.mutateAsync,[{group:`okpay`,key:`okpay.enabled`,type:`bool`,value:n.enabled?`true`:`false`},{group:`okpay`,key:`okpay.shop_id`,type:`string`,value:n.shopId},{group:`okpay`,key:`okpay.shop_token`,type:`string`,value:n.shopToken},{group:`okpay`,key:`okpay.timeout_seconds`,type:`int`,value:n.timeoutSeconds},{group:`okpay`,key:`okpay.callback_url`,type:`string`,value:n.callbackUrl}],u()),await e.refetch()}return(0,W.jsx)(F,{...r,children:(0,W.jsxs)(`form`,{className:`space-y-6`,onSubmit:r.handleSubmit(a),children:[(0,W.jsx)(k,{control:r.control,name:`enabled`,render:({field:e})=>(0,W.jsxs)(D,{className:`flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,W.jsx)(M,{children:i()}),(0,W.jsx)(N,{children:x()})]}),(0,W.jsx)(j,{children:(0,W.jsx)(C,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,W.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,W.jsx)(k,{control:r.control,name:`shopId`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:y()}),(0,W.jsx)(j,{children:(0,W.jsx)(I,{autoComplete:`off`,...e})}),(0,W.jsx)(P,{})]})}),(0,W.jsx)(k,{control:r.control,name:`shopToken`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:c()}),(0,W.jsx)(j,{children:(0,W.jsx)(L,{autoComplete:`off`,...e})}),(0,W.jsx)(P,{})]})}),(0,W.jsx)(k,{control:r.control,name:`timeoutSeconds`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:v()}),(0,W.jsx)(j,{children:(0,W.jsx)(I,{inputMode:`numeric`,placeholder:`600`,...e})}),(0,W.jsx)(P,{})]})})]}),(0,W.jsx)(k,{control:r.control,name:`apiUrl`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:f()}),(0,W.jsx)(j,{children:(0,W.jsx)(I,{disabled:!0,placeholder:`https://api.okpay.example`,...e})}),(0,W.jsx)(P,{})]})}),(0,W.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,W.jsx)(k,{control:r.control,name:`callbackUrl`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:h()}),(0,W.jsx)(j,{children:(0,W.jsx)(I,{placeholder:`https://example.com/notify`,...e})}),(0,W.jsx)(P,{})]})}),(0,W.jsx)(k,{control:r.control,name:`returnUrl`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:o()}),(0,W.jsx)(j,{children:(0,W.jsx)(I,{disabled:!0,placeholder:`https://example.com/success`,...e})}),(0,W.jsx)(P,{})]})})]}),(0,W.jsx)(k,{control:r.control,name:`allowTokens`,render:({field:e})=>(0,W.jsxs)(D,{children:[(0,W.jsx)(M,{children:g()}),(0,W.jsx)(j,{children:(0,W.jsx)(I,{disabled:!0,placeholder:`USDT,USDC`,...e})}),(0,W.jsx)(N,{children:m()}),(0,W.jsx)(P,{})]})}),(0,W.jsx)(S,{disabled:t.isPending||e.isLoading,type:`submit`,children:n()})]})})}function q(e){return e.split(/[\s,]+/).map(e=>e.trim().toUpperCase()).filter(Boolean)}function J(){return(0,W.jsx)(R,{description:b(),title:e(),variant:`section`,children:(0,W.jsx)(K,{})})}var Y=J;export{Y as component}; |