azirid-react 0.10.4 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -16
- package/dist/index.cjs +472 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +472 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -119,6 +119,7 @@ var SUFFIXES = {
|
|
|
119
119
|
checkout: "billing/checkout",
|
|
120
120
|
billingPortal: "billing/portal",
|
|
121
121
|
invoices: "billing/invoices",
|
|
122
|
+
uploadTransferProof: "billing/upload-proof",
|
|
122
123
|
submitTransferProof: "billing/transfer-proof",
|
|
123
124
|
transferProofs: "billing/transfer-proofs",
|
|
124
125
|
payphoneConfirm: "billing/payphone/confirm",
|
|
@@ -1164,7 +1165,7 @@ var LoginForm = react.forwardRef(
|
|
|
1164
1165
|
submitText: submitTextProp,
|
|
1165
1166
|
footer,
|
|
1166
1167
|
forgotPassword,
|
|
1167
|
-
showSocialButtons =
|
|
1168
|
+
showSocialButtons = false,
|
|
1168
1169
|
labels,
|
|
1169
1170
|
defaultValues
|
|
1170
1171
|
}, ref) => {
|
|
@@ -1350,7 +1351,7 @@ var SignupForm = react.forwardRef(
|
|
|
1350
1351
|
logo: logoProp,
|
|
1351
1352
|
submitText: submitTextProp,
|
|
1352
1353
|
footer,
|
|
1353
|
-
showSocialButtons =
|
|
1354
|
+
showSocialButtons = false,
|
|
1354
1355
|
labels
|
|
1355
1356
|
}, ref) => {
|
|
1356
1357
|
const msg = useMessages();
|
|
@@ -3245,6 +3246,81 @@ function usePayButton({
|
|
|
3245
3246
|
error: currentError
|
|
3246
3247
|
};
|
|
3247
3248
|
}
|
|
3249
|
+
function useUploadTransferProof(options) {
|
|
3250
|
+
const client = useAccessClient();
|
|
3251
|
+
const [isUploading, setIsUploading] = react.useState(false);
|
|
3252
|
+
const [publicUrl, setPublicUrl] = react.useState(null);
|
|
3253
|
+
const [error, setError] = react.useState(null);
|
|
3254
|
+
const upload = react.useCallback(
|
|
3255
|
+
async (file) => {
|
|
3256
|
+
setIsUploading(true);
|
|
3257
|
+
setError(null);
|
|
3258
|
+
try {
|
|
3259
|
+
const presigned = await client.post(
|
|
3260
|
+
client.paths.uploadTransferProof,
|
|
3261
|
+
{
|
|
3262
|
+
contentType: file.type,
|
|
3263
|
+
fileSize: file.size
|
|
3264
|
+
}
|
|
3265
|
+
);
|
|
3266
|
+
const uploadRes = await fetch(presigned.uploadUrl, {
|
|
3267
|
+
method: "PUT",
|
|
3268
|
+
headers: { "Content-Type": file.type },
|
|
3269
|
+
body: file
|
|
3270
|
+
});
|
|
3271
|
+
if (!uploadRes.ok) {
|
|
3272
|
+
throw new Error(`Upload failed: ${uploadRes.status}`);
|
|
3273
|
+
}
|
|
3274
|
+
setPublicUrl(presigned.publicUrl);
|
|
3275
|
+
options?.onSuccess?.(presigned);
|
|
3276
|
+
return presigned;
|
|
3277
|
+
} catch (err) {
|
|
3278
|
+
const error2 = err instanceof Error ? err : new Error("Upload failed");
|
|
3279
|
+
setError(error2);
|
|
3280
|
+
options?.onError?.(error2);
|
|
3281
|
+
throw error2;
|
|
3282
|
+
} finally {
|
|
3283
|
+
setIsUploading(false);
|
|
3284
|
+
}
|
|
3285
|
+
},
|
|
3286
|
+
[client, options]
|
|
3287
|
+
);
|
|
3288
|
+
const reset = react.useCallback(() => {
|
|
3289
|
+
setPublicUrl(null);
|
|
3290
|
+
setError(null);
|
|
3291
|
+
setIsUploading(false);
|
|
3292
|
+
}, []);
|
|
3293
|
+
return react.useMemo(
|
|
3294
|
+
() => ({ upload, isUploading, publicUrl, error, reset }),
|
|
3295
|
+
[upload, isUploading, publicUrl, error, reset]
|
|
3296
|
+
);
|
|
3297
|
+
}
|
|
3298
|
+
function useSubmitTransferProof(options) {
|
|
3299
|
+
const client = useAccessClient();
|
|
3300
|
+
const queryClient = reactQuery.useQueryClient();
|
|
3301
|
+
const mutation = reactQuery.useMutation({
|
|
3302
|
+
mutationFn: (data) => client.post(client.paths.submitTransferProof, data),
|
|
3303
|
+
onSuccess: (data) => {
|
|
3304
|
+
void queryClient.invalidateQueries({ queryKey: ["transferProofs"] });
|
|
3305
|
+
options?.onSuccess?.(data);
|
|
3306
|
+
},
|
|
3307
|
+
onError: options?.onError
|
|
3308
|
+
});
|
|
3309
|
+
const submit = react.useCallback(
|
|
3310
|
+
(data) => {
|
|
3311
|
+
mutation.mutate(data);
|
|
3312
|
+
},
|
|
3313
|
+
[mutation]
|
|
3314
|
+
);
|
|
3315
|
+
return react.useMemo(() => ({ ...mutation, submit }), [mutation, submit]);
|
|
3316
|
+
}
|
|
3317
|
+
function useTransferProofs() {
|
|
3318
|
+
const client = useAccessClient();
|
|
3319
|
+
return reactQuery.useQuery({
|
|
3320
|
+
queryKey: ["transferProofs"],
|
|
3321
|
+
queryFn: () => client.get(client.paths.transferProofs)
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3248
3324
|
var PROVIDER_LABELS3 = {
|
|
3249
3325
|
STRIPE: { en: "Credit/Debit Card", es: "Tarjeta de cr\xE9dito/d\xE9bito" },
|
|
3250
3326
|
PAYPAL: { en: "PayPal", es: "PayPal" },
|
|
@@ -3344,89 +3420,366 @@ function ProviderModal({
|
|
|
3344
3420
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: modalStyles.cancelButton, onClick: onClose, children: labels?.cancel ?? "Cancel" })
|
|
3345
3421
|
] }) });
|
|
3346
3422
|
}
|
|
3347
|
-
|
|
3423
|
+
var ACCEPTED_FILE_TYPES = "image/png,image/jpeg,image/webp,application/pdf";
|
|
3424
|
+
var MAX_FILE_SIZE_MB = 10;
|
|
3425
|
+
function TransferModal2({ data, onClose, onProofSubmitted, labels }) {
|
|
3348
3426
|
const bankDetails = data.bankDetails;
|
|
3349
3427
|
const plan = data.plan;
|
|
3350
3428
|
const intent = data.intent;
|
|
3351
3429
|
const displayAmount = plan ? formatAmount(plan.amount, plan.currency) : intent ? formatAmount(intent.amount, intent.currency) : "";
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
style:
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
+
const amount = plan?.amount ?? intent?.amount ?? 0;
|
|
3431
|
+
const currency = plan?.currency ?? intent?.currency ?? "USD";
|
|
3432
|
+
const intentId = intent?.id;
|
|
3433
|
+
const [step, setStep] = react.useState("details");
|
|
3434
|
+
const [selectedFile, setSelectedFile] = react.useState(null);
|
|
3435
|
+
const [previewUrl, setPreviewUrl] = react.useState(null);
|
|
3436
|
+
const [errorMessage, setErrorMessage] = react.useState(null);
|
|
3437
|
+
const fileInputRef = react.useRef(null);
|
|
3438
|
+
const { upload, isUploading } = useUploadTransferProof({
|
|
3439
|
+
onError: (err) => {
|
|
3440
|
+
setErrorMessage(err.message);
|
|
3441
|
+
setStep("error");
|
|
3442
|
+
}
|
|
3443
|
+
});
|
|
3444
|
+
const { submit, isPending: isSubmitting } = useSubmitTransferProof({
|
|
3445
|
+
onSuccess: (proof) => {
|
|
3446
|
+
setStep("submitted");
|
|
3447
|
+
onProofSubmitted?.(proof);
|
|
3448
|
+
},
|
|
3449
|
+
onError: (err) => {
|
|
3450
|
+
setErrorMessage(err.message);
|
|
3451
|
+
setStep("error");
|
|
3452
|
+
}
|
|
3453
|
+
});
|
|
3454
|
+
const handleFileSelect = (e) => {
|
|
3455
|
+
const file = e.target.files?.[0];
|
|
3456
|
+
if (!file) return;
|
|
3457
|
+
if (file.size > MAX_FILE_SIZE_MB * 1024 * 1024) {
|
|
3458
|
+
setErrorMessage(`File size exceeds ${MAX_FILE_SIZE_MB}MB limit`);
|
|
3459
|
+
return;
|
|
3460
|
+
}
|
|
3461
|
+
setSelectedFile(file);
|
|
3462
|
+
setErrorMessage(null);
|
|
3463
|
+
if (file.type.startsWith("image/")) {
|
|
3464
|
+
const url = URL.createObjectURL(file);
|
|
3465
|
+
setPreviewUrl(url);
|
|
3466
|
+
} else {
|
|
3467
|
+
setPreviewUrl(null);
|
|
3468
|
+
}
|
|
3469
|
+
};
|
|
3470
|
+
const handleSubmit = async () => {
|
|
3471
|
+
if (!selectedFile) return;
|
|
3472
|
+
try {
|
|
3473
|
+
setStep("uploading");
|
|
3474
|
+
const result = await upload(selectedFile);
|
|
3475
|
+
setStep("submitting");
|
|
3476
|
+
submit({
|
|
3477
|
+
intentId,
|
|
3478
|
+
fileUrl: result.publicUrl,
|
|
3479
|
+
fileName: selectedFile.name,
|
|
3480
|
+
fileType: selectedFile.type,
|
|
3481
|
+
amount,
|
|
3482
|
+
currency
|
|
3483
|
+
});
|
|
3484
|
+
} catch {
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
const handleRetry = () => {
|
|
3488
|
+
setStep("details");
|
|
3489
|
+
setErrorMessage(null);
|
|
3490
|
+
};
|
|
3491
|
+
const isProcessing = isUploading || isSubmitting;
|
|
3492
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: modalStyles.overlay, onClick: isProcessing ? void 0 : onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3493
|
+
"div",
|
|
3494
|
+
{
|
|
3495
|
+
style: { ...modalStyles.card, maxHeight: "90vh", overflowY: "auto" },
|
|
3496
|
+
onClick: (e) => e.stopPropagation(),
|
|
3497
|
+
children: [
|
|
3498
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: modalStyles.title, children: labels?.bankTransfer ?? "Bank Transfer" }),
|
|
3499
|
+
displayAmount && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3500
|
+
"div",
|
|
3501
|
+
{
|
|
3502
|
+
style: {
|
|
3503
|
+
textAlign: "center",
|
|
3504
|
+
padding: "16px",
|
|
3505
|
+
backgroundColor: "#f9fafb",
|
|
3506
|
+
borderRadius: "8px",
|
|
3507
|
+
marginBottom: "20px"
|
|
3508
|
+
},
|
|
3509
|
+
children: [
|
|
3510
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "32px", fontWeight: 700, color: "#111827" }, children: displayAmount }),
|
|
3511
|
+
plan?.name && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: "#6b7280" }, children: plan.name }),
|
|
3512
|
+
intent?.description && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: "#6b7280" }, children: intent.description })
|
|
3513
|
+
]
|
|
3514
|
+
}
|
|
3515
|
+
),
|
|
3516
|
+
bankDetails && Object.keys(bankDetails).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
3517
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3518
|
+
"div",
|
|
3519
|
+
{
|
|
3520
|
+
style: {
|
|
3521
|
+
fontSize: "14px",
|
|
3522
|
+
fontWeight: 600,
|
|
3523
|
+
color: "#111827",
|
|
3524
|
+
marginBottom: "8px"
|
|
3525
|
+
},
|
|
3526
|
+
children: labels?.bankDetails ?? "Bank Details"
|
|
3527
|
+
}
|
|
3528
|
+
),
|
|
3529
|
+
Object.entries(bankDetails).filter(([, v]) => v).map(([key, value]) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3530
|
+
"div",
|
|
3531
|
+
{
|
|
3532
|
+
style: {
|
|
3533
|
+
display: "flex",
|
|
3534
|
+
justifyContent: "space-between",
|
|
3535
|
+
padding: "6px 0",
|
|
3536
|
+
borderBottom: "1px solid #f3f4f6",
|
|
3537
|
+
fontSize: "13px"
|
|
3538
|
+
},
|
|
3539
|
+
children: [
|
|
3540
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#6b7280" }, children: key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()) }),
|
|
3541
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#111827", fontWeight: 500 }, children: value })
|
|
3542
|
+
]
|
|
3543
|
+
},
|
|
3544
|
+
key
|
|
3545
|
+
))
|
|
3546
|
+
] }),
|
|
3547
|
+
data.transferInstructions && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3548
|
+
"div",
|
|
3549
|
+
{
|
|
3550
|
+
style: {
|
|
3551
|
+
padding: "12px",
|
|
3552
|
+
backgroundColor: "#eff6ff",
|
|
3553
|
+
borderRadius: "6px",
|
|
3554
|
+
fontSize: "13px",
|
|
3555
|
+
color: "#1e40af",
|
|
3556
|
+
lineHeight: 1.5,
|
|
3557
|
+
marginBottom: "16px"
|
|
3558
|
+
},
|
|
3559
|
+
children: data.transferInstructions
|
|
3560
|
+
}
|
|
3561
|
+
),
|
|
3562
|
+
step === "submitted" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3563
|
+
"div",
|
|
3564
|
+
{
|
|
3565
|
+
style: {
|
|
3566
|
+
textAlign: "center",
|
|
3567
|
+
padding: "20px",
|
|
3568
|
+
backgroundColor: "#f0fdf4",
|
|
3569
|
+
borderRadius: "8px",
|
|
3570
|
+
marginBottom: "16px"
|
|
3571
|
+
},
|
|
3572
|
+
children: [
|
|
3573
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "32px", marginBottom: "8px" }, children: "\u2705" }),
|
|
3574
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "16px", fontWeight: 600, color: "#166534" }, children: labels?.proofSubmitted ?? "Proof submitted successfully" }),
|
|
3575
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "13px", color: "#15803d", margin: "8px 0 0 0" }, children: labels?.proofPendingReview ?? "Your payment proof is under review. You will be notified once it is verified." })
|
|
3576
|
+
]
|
|
3577
|
+
}
|
|
3578
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
3579
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3580
|
+
"div",
|
|
3581
|
+
{
|
|
3582
|
+
style: {
|
|
3583
|
+
fontSize: "14px",
|
|
3584
|
+
fontWeight: 600,
|
|
3585
|
+
color: "#111827",
|
|
3586
|
+
marginBottom: "8px"
|
|
3587
|
+
},
|
|
3588
|
+
children: labels?.uploadProof ?? "Upload proof of payment"
|
|
3589
|
+
}
|
|
3590
|
+
),
|
|
3591
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3592
|
+
"input",
|
|
3593
|
+
{
|
|
3594
|
+
ref: fileInputRef,
|
|
3595
|
+
type: "file",
|
|
3596
|
+
accept: ACCEPTED_FILE_TYPES,
|
|
3597
|
+
style: { display: "none" },
|
|
3598
|
+
onChange: handleFileSelect
|
|
3599
|
+
}
|
|
3600
|
+
),
|
|
3601
|
+
!selectedFile ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3602
|
+
"button",
|
|
3603
|
+
{
|
|
3604
|
+
type: "button",
|
|
3605
|
+
style: {
|
|
3606
|
+
width: "100%",
|
|
3607
|
+
padding: "24px 16px",
|
|
3608
|
+
border: "2px dashed #d1d5db",
|
|
3609
|
+
borderRadius: "8px",
|
|
3610
|
+
backgroundColor: "#fafafa",
|
|
3611
|
+
cursor: "pointer",
|
|
3612
|
+
textAlign: "center",
|
|
3613
|
+
fontFamily: "inherit"
|
|
3614
|
+
},
|
|
3615
|
+
onClick: () => fileInputRef.current?.click(),
|
|
3616
|
+
children: [
|
|
3617
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "28px", marginBottom: "8px" }, children: "\u{1F4C4}" }),
|
|
3618
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "14px", color: "#374151", fontWeight: 500 }, children: labels?.selectFile ?? "Click to select file" }),
|
|
3619
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "12px", color: "#9ca3af", marginTop: "4px" }, children: labels?.acceptedFormats ?? "PNG, JPG, WebP or PDF (max 10MB)" })
|
|
3620
|
+
]
|
|
3621
|
+
}
|
|
3622
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3623
|
+
"div",
|
|
3624
|
+
{
|
|
3625
|
+
style: {
|
|
3626
|
+
border: "1px solid #e5e7eb",
|
|
3627
|
+
borderRadius: "8px",
|
|
3628
|
+
padding: "12px",
|
|
3629
|
+
backgroundColor: "#fafafa"
|
|
3630
|
+
},
|
|
3631
|
+
children: [
|
|
3632
|
+
previewUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3633
|
+
"img",
|
|
3634
|
+
{
|
|
3635
|
+
src: previewUrl,
|
|
3636
|
+
alt: "Transfer proof preview",
|
|
3637
|
+
style: {
|
|
3638
|
+
width: "100%",
|
|
3639
|
+
maxHeight: "200px",
|
|
3640
|
+
objectFit: "contain",
|
|
3641
|
+
borderRadius: "6px",
|
|
3642
|
+
marginBottom: "8px"
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
),
|
|
3646
|
+
selectedFile.type === "application/pdf" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3647
|
+
"div",
|
|
3648
|
+
{
|
|
3649
|
+
style: {
|
|
3650
|
+
display: "flex",
|
|
3651
|
+
alignItems: "center",
|
|
3652
|
+
gap: "8px",
|
|
3653
|
+
padding: "12px",
|
|
3654
|
+
backgroundColor: "#fef2f2",
|
|
3655
|
+
borderRadius: "6px",
|
|
3656
|
+
marginBottom: "8px"
|
|
3657
|
+
},
|
|
3658
|
+
children: [
|
|
3659
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "24px" }, children: "\u{1F4C4}" }),
|
|
3660
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3661
|
+
"span",
|
|
3662
|
+
{
|
|
3663
|
+
style: {
|
|
3664
|
+
fontSize: "13px",
|
|
3665
|
+
color: "#991b1b",
|
|
3666
|
+
fontWeight: 500,
|
|
3667
|
+
overflow: "hidden",
|
|
3668
|
+
textOverflow: "ellipsis",
|
|
3669
|
+
whiteSpace: "nowrap"
|
|
3670
|
+
},
|
|
3671
|
+
children: selectedFile.name
|
|
3672
|
+
}
|
|
3673
|
+
)
|
|
3674
|
+
]
|
|
3675
|
+
}
|
|
3676
|
+
),
|
|
3677
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3678
|
+
"div",
|
|
3679
|
+
{
|
|
3680
|
+
style: {
|
|
3681
|
+
display: "flex",
|
|
3682
|
+
justifyContent: "space-between",
|
|
3683
|
+
alignItems: "center"
|
|
3684
|
+
},
|
|
3685
|
+
children: [
|
|
3686
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "12px", color: "#6b7280" }, children: [
|
|
3687
|
+
selectedFile.name,
|
|
3688
|
+
" (",
|
|
3689
|
+
(selectedFile.size / 1024 / 1024).toFixed(2),
|
|
3690
|
+
" MB)"
|
|
3691
|
+
] }),
|
|
3692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3693
|
+
"button",
|
|
3694
|
+
{
|
|
3695
|
+
type: "button",
|
|
3696
|
+
style: {
|
|
3697
|
+
fontSize: "12px",
|
|
3698
|
+
color: "#3b82f6",
|
|
3699
|
+
background: "none",
|
|
3700
|
+
border: "none",
|
|
3701
|
+
cursor: "pointer",
|
|
3702
|
+
fontFamily: "inherit",
|
|
3703
|
+
padding: 0
|
|
3704
|
+
},
|
|
3705
|
+
onClick: () => {
|
|
3706
|
+
setSelectedFile(null);
|
|
3707
|
+
setPreviewUrl(null);
|
|
3708
|
+
if (fileInputRef.current) fileInputRef.current.value = "";
|
|
3709
|
+
},
|
|
3710
|
+
disabled: isProcessing,
|
|
3711
|
+
children: labels?.changeFile ?? "Change"
|
|
3712
|
+
}
|
|
3713
|
+
)
|
|
3714
|
+
]
|
|
3715
|
+
}
|
|
3716
|
+
)
|
|
3717
|
+
]
|
|
3718
|
+
}
|
|
3719
|
+
),
|
|
3720
|
+
errorMessage && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3721
|
+
"div",
|
|
3722
|
+
{
|
|
3723
|
+
style: {
|
|
3724
|
+
marginTop: "8px",
|
|
3725
|
+
padding: "8px 12px",
|
|
3726
|
+
backgroundColor: "#fef2f2",
|
|
3727
|
+
borderRadius: "6px",
|
|
3728
|
+
fontSize: "13px",
|
|
3729
|
+
color: "#dc2626"
|
|
3730
|
+
},
|
|
3731
|
+
children: errorMessage
|
|
3732
|
+
}
|
|
3733
|
+
),
|
|
3734
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3735
|
+
"button",
|
|
3736
|
+
{
|
|
3737
|
+
type: "button",
|
|
3738
|
+
style: {
|
|
3739
|
+
display: "block",
|
|
3740
|
+
width: "100%",
|
|
3741
|
+
marginTop: "12px",
|
|
3742
|
+
padding: "12px",
|
|
3743
|
+
border: "none",
|
|
3744
|
+
borderRadius: "8px",
|
|
3745
|
+
backgroundColor: !selectedFile || isProcessing ? "#d1d5db" : "#111827",
|
|
3746
|
+
color: "#fff",
|
|
3747
|
+
fontSize: "14px",
|
|
3748
|
+
fontWeight: 600,
|
|
3749
|
+
cursor: !selectedFile || isProcessing ? "not-allowed" : "pointer",
|
|
3750
|
+
fontFamily: "inherit"
|
|
3751
|
+
},
|
|
3752
|
+
onClick: handleSubmit,
|
|
3753
|
+
disabled: !selectedFile || isProcessing,
|
|
3754
|
+
children: isUploading ? labels?.uploading ?? "Uploading..." : isSubmitting ? labels?.submitting ?? "Submitting..." : step === "error" ? labels?.retry ?? "Retry" : labels?.submitProof ?? "Submit proof of payment"
|
|
3755
|
+
}
|
|
3756
|
+
),
|
|
3757
|
+
step === "error" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3758
|
+
"button",
|
|
3759
|
+
{
|
|
3760
|
+
type: "button",
|
|
3761
|
+
style: {
|
|
3762
|
+
...modalStyles.cancelButton,
|
|
3763
|
+
marginTop: "8px"
|
|
3764
|
+
},
|
|
3765
|
+
onClick: handleRetry,
|
|
3766
|
+
children: labels?.tryAgain ?? "Try again"
|
|
3767
|
+
}
|
|
3768
|
+
)
|
|
3769
|
+
] }),
|
|
3770
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3771
|
+
"button",
|
|
3772
|
+
{
|
|
3773
|
+
type: "button",
|
|
3774
|
+
style: modalStyles.cancelButton,
|
|
3775
|
+
onClick: onClose,
|
|
3776
|
+
disabled: isProcessing,
|
|
3777
|
+
children: step === "submitted" ? labels?.done ?? "Done" : labels?.cancel ?? "Cancel"
|
|
3778
|
+
}
|
|
3779
|
+
)
|
|
3780
|
+
]
|
|
3781
|
+
}
|
|
3782
|
+
) });
|
|
3430
3783
|
}
|
|
3431
3784
|
function PayButton({
|
|
3432
3785
|
planId,
|
|
@@ -3439,7 +3792,8 @@ function PayButton({
|
|
|
3439
3792
|
disabled,
|
|
3440
3793
|
onSuccess,
|
|
3441
3794
|
onError,
|
|
3442
|
-
onProviderSelect
|
|
3795
|
+
onProviderSelect,
|
|
3796
|
+
onProofSubmitted
|
|
3443
3797
|
}) {
|
|
3444
3798
|
const messages = useMessages();
|
|
3445
3799
|
const billing = messages?.billing;
|
|
@@ -3523,6 +3877,7 @@ function PayButton({
|
|
|
3523
3877
|
setShowTransferModal(false);
|
|
3524
3878
|
onSuccess?.(checkoutData);
|
|
3525
3879
|
},
|
|
3880
|
+
onProofSubmitted,
|
|
3526
3881
|
labels: billing
|
|
3527
3882
|
}
|
|
3528
3883
|
),
|
|
@@ -4017,32 +4372,6 @@ function usePasskeys(options) {
|
|
|
4017
4372
|
loginVerify
|
|
4018
4373
|
};
|
|
4019
4374
|
}
|
|
4020
|
-
function useSubmitTransferProof(options) {
|
|
4021
|
-
const client = useAccessClient();
|
|
4022
|
-
const queryClient = reactQuery.useQueryClient();
|
|
4023
|
-
const mutation = reactQuery.useMutation({
|
|
4024
|
-
mutationFn: (data) => client.post(client.paths.submitTransferProof, data),
|
|
4025
|
-
onSuccess: (data) => {
|
|
4026
|
-
void queryClient.invalidateQueries({ queryKey: ["transferProofs"] });
|
|
4027
|
-
options?.onSuccess?.(data);
|
|
4028
|
-
},
|
|
4029
|
-
onError: options?.onError
|
|
4030
|
-
});
|
|
4031
|
-
const submit = react.useCallback(
|
|
4032
|
-
(data) => {
|
|
4033
|
-
mutation.mutate(data);
|
|
4034
|
-
},
|
|
4035
|
-
[mutation]
|
|
4036
|
-
);
|
|
4037
|
-
return react.useMemo(() => ({ ...mutation, submit }), [mutation, submit]);
|
|
4038
|
-
}
|
|
4039
|
-
function useTransferProofs() {
|
|
4040
|
-
const client = useAccessClient();
|
|
4041
|
-
return reactQuery.useQuery({
|
|
4042
|
-
queryKey: ["transferProofs"],
|
|
4043
|
-
queryFn: () => client.get(client.paths.transferProofs)
|
|
4044
|
-
});
|
|
4045
|
-
}
|
|
4046
4375
|
var CONTAINER_ID = "pp-checkout-azirid";
|
|
4047
4376
|
function usePayphoneCheckout({
|
|
4048
4377
|
intentId,
|
|
@@ -4156,6 +4485,13 @@ function useTransferPayment({
|
|
|
4156
4485
|
cancelUrl: responseUrl
|
|
4157
4486
|
});
|
|
4158
4487
|
}, [checkout, intentId, responseUrl]);
|
|
4488
|
+
const { upload, isUploading } = useUploadTransferProof({
|
|
4489
|
+
onError: (err) => {
|
|
4490
|
+
setCurrentError(err);
|
|
4491
|
+
setStatus("error");
|
|
4492
|
+
onError?.(err);
|
|
4493
|
+
}
|
|
4494
|
+
});
|
|
4159
4495
|
const { submit, isPending: isSubmitting } = useSubmitTransferProof({
|
|
4160
4496
|
onSuccess: (proof) => {
|
|
4161
4497
|
setStatus("submitted");
|
|
@@ -4173,7 +4509,7 @@ function useTransferPayment({
|
|
|
4173
4509
|
setStatus("submitting");
|
|
4174
4510
|
setCurrentError(null);
|
|
4175
4511
|
submit({
|
|
4176
|
-
|
|
4512
|
+
intentId: checkoutData.intent.id,
|
|
4177
4513
|
fileUrl: data.fileUrl,
|
|
4178
4514
|
fileName: data.fileName,
|
|
4179
4515
|
fileType: data.fileType,
|
|
@@ -4184,6 +4520,29 @@ function useTransferPayment({
|
|
|
4184
4520
|
},
|
|
4185
4521
|
[submit, checkoutData]
|
|
4186
4522
|
);
|
|
4523
|
+
const uploadAndSubmitProof = react.useCallback(
|
|
4524
|
+
async (file, notes) => {
|
|
4525
|
+
if (!checkoutData?.intent) return;
|
|
4526
|
+
setCurrentError(null);
|
|
4527
|
+
try {
|
|
4528
|
+
setStatus("uploading");
|
|
4529
|
+
const result = await upload(file);
|
|
4530
|
+
setStatus("submitting");
|
|
4531
|
+
const intent = checkoutData.intent;
|
|
4532
|
+
submit({
|
|
4533
|
+
intentId: intent.id,
|
|
4534
|
+
fileUrl: result.publicUrl,
|
|
4535
|
+
fileName: file.name,
|
|
4536
|
+
fileType: file.type,
|
|
4537
|
+
amount: intent.amount ?? checkoutData.plan?.amount ?? 0,
|
|
4538
|
+
currency: intent.currency ?? checkoutData.plan?.currency ?? "USD",
|
|
4539
|
+
notes
|
|
4540
|
+
});
|
|
4541
|
+
} catch {
|
|
4542
|
+
}
|
|
4543
|
+
},
|
|
4544
|
+
[upload, submit, checkoutData]
|
|
4545
|
+
);
|
|
4187
4546
|
const TransferDetails = react.useMemo(() => {
|
|
4188
4547
|
return function TransferDetailsInner() {
|
|
4189
4548
|
if (!checkoutData) return null;
|
|
@@ -4259,10 +4618,12 @@ function useTransferPayment({
|
|
|
4259
4618
|
}, [checkoutData]);
|
|
4260
4619
|
return {
|
|
4261
4620
|
TransferDetails,
|
|
4621
|
+
uploadAndSubmitProof,
|
|
4262
4622
|
submitProof,
|
|
4263
4623
|
status,
|
|
4264
4624
|
checkoutData,
|
|
4265
4625
|
isSubmitting,
|
|
4626
|
+
isUploading,
|
|
4266
4627
|
error: currentError
|
|
4267
4628
|
};
|
|
4268
4629
|
}
|
|
@@ -4358,7 +4719,7 @@ function usePasswordToggle() {
|
|
|
4358
4719
|
}
|
|
4359
4720
|
|
|
4360
4721
|
// src/index.ts
|
|
4361
|
-
var SDK_VERSION = "0.
|
|
4722
|
+
var SDK_VERSION = "0.11.0";
|
|
4362
4723
|
|
|
4363
4724
|
exports.AuthForm = AuthForm;
|
|
4364
4725
|
exports.AziridProvider = AziridProvider;
|
|
@@ -4433,5 +4794,6 @@ exports.useTenantMembers = useTenantMembers;
|
|
|
4433
4794
|
exports.useTenants = useTenants;
|
|
4434
4795
|
exports.useTransferPayment = useTransferPayment;
|
|
4435
4796
|
exports.useTransferProofs = useTransferProofs;
|
|
4797
|
+
exports.useUploadTransferProof = useUploadTransferProof;
|
|
4436
4798
|
//# sourceMappingURL=index.cjs.map
|
|
4437
4799
|
//# sourceMappingURL=index.cjs.map
|