@opexa/portal-components 0.0.244 → 0.0.246
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/dist/client/hooks/useInfiniteQueryHelper.js +1 -1
- package/dist/components/Account/Account.lazy.js +6 -3
- package/dist/components/AccountInfo/AccountInfo.js +1 -1
- package/dist/components/AccountVerification/AccountVerification.js +5 -2
- package/dist/components/Banner/Banner.js +2 -1
- package/dist/components/BetRecords/BetRecords.client.d.ts +4 -0
- package/dist/components/BetRecords/BetRecords.client.js +2 -2
- package/dist/components/Bonuses/Bonuses.client.js +13 -8
- package/dist/components/GameLaunch/GameLaunchTrigger.js +7 -0
- package/dist/components/GameProviders/GameProvidersCarousel.js +2 -2
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
- package/dist/components/KYC/utils.js +18 -18
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
- package/dist/components/TransactionRecords/WithdrawalRecordsTable.js +1 -1
- package/dist/components/shared/IdDocumentField.client.d.ts +25 -0
- package/dist/components/shared/IdDocumentField.client.js +204 -0
- package/dist/components/shared/IdDocumentField.d.ts +1 -24
- package/dist/components/shared/IdDocumentField.js +7 -201
- package/dist/components/shared/SelfieField.client.d.ts +20 -0
- package/dist/components/shared/SelfieField.client.js +327 -0
- package/dist/components/shared/SelfieField.d.ts +1 -20
- package/dist/components/shared/SelfieField.js +7 -314
- package/dist/services/queries.d.ts +1 -1
- package/dist/services/queries.js +2528 -2527
- package/dist/styles/theme.css +694 -694
- package/dist/types/index.d.ts +6 -0
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/utils/gamesAvailable3pmTo3am.d.ts +1 -0
- package/dist/utils/gamesAvailable3pmTo3am.js +1 -0
- package/dist/utils/getGameImageUrl.js +3 -5
- package/dist/utils/isBetween3amAnd3pm.d.ts +1 -0
- package/dist/utils/isBetween3amAnd3pm.js +5 -0
- package/package.json +165 -165
- package/dist/components/FeatureFlag/FeatureFlag.d.ts +0 -1
- package/dist/components/FeatureFlag/FeatureFlag.js +0 -29
- package/dist/components/FeatureFlag/index.d.ts +0 -1
- package/dist/components/FeatureFlag/index.js +0 -1
- package/dist/components/KYC/AutoOpen.d.ts +0 -1
- package/dist/components/KYC/AutoOpen.js +0 -45
- package/dist/components/SignUp/SignUp.lazy.d.ts +0 -12
- package/dist/components/SignUp/SignUp.lazy.js +0 -18
- package/dist/components/SignUp/SignUpContext.d.ts +0 -6
- package/dist/components/SignUp/SignUpContext.js +0 -2
- package/dist/components/SignUp/SignUpForm.d.ts +0 -1
- package/dist/components/SignUp/SignUpForm.js +0 -283
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +0 -198
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +0 -251
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +0 -10
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +0 -41
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +0 -1
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +0 -429
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +0 -13
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +0 -26
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +0 -7
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +0 -2
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +0 -11
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +0 -20
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as faceapi from 'face-api.js';
|
|
4
|
-
import { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
|
-
import { ArrowLeftIcon } from '../../../icons/ArrowLeftIcon.js';
|
|
7
|
-
import { Camera01Icon } from '../../../icons/Camera01Icon.js';
|
|
8
|
-
import { XIcon } from '../../../icons/XIcon.js';
|
|
9
|
-
import { Button } from '../../../ui/Button/index.js';
|
|
10
|
-
import { Dialog } from '../../../ui/Dialog/index.js';
|
|
11
|
-
import { Portal } from '../../../ui/Portal/index.js';
|
|
12
|
-
import { onMobileDevice } from '../../../utils/onMobileDevice.js';
|
|
13
|
-
import PersonOverlayDesktop from '../../KYC/PersonOverlayDesktop.js';
|
|
14
|
-
import { dataURLtoBlob, loadFaceApiModels, resizeFile } from '../../KYC/utils.js';
|
|
15
|
-
import { useSignUpPagcorPropsContext } from './SignUpPagcorContext.js';
|
|
16
|
-
export function CaptureSelfie() {
|
|
17
|
-
const props = useSignUpPagcorPropsContext();
|
|
18
|
-
const mobileDevice = onMobileDevice();
|
|
19
|
-
const [modelsLoaded, setModelsLoaded] = useState(false);
|
|
20
|
-
const [videoStream, setVideoStream] = useState(null);
|
|
21
|
-
const [cameraError, setCameraError] = useState(null);
|
|
22
|
-
const [captureInProgress, setCaptureInProgress] = useState(false);
|
|
23
|
-
const [selectedImage, setSelectedImage] = useState(null);
|
|
24
|
-
const [isFaceCentered, setIsFaceCentered] = useState(false);
|
|
25
|
-
const [isCapturing, setIsCapturing] = useState(false);
|
|
26
|
-
const [countdown, setCountdown] = useState(3);
|
|
27
|
-
const videoRef = useRef(null);
|
|
28
|
-
const faceCanvasRef = useRef(null);
|
|
29
|
-
const detectionIntervalRef = useRef(null);
|
|
30
|
-
const countdownTimerRef = useRef(null);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
loadFaceApiModels()
|
|
33
|
-
.then(() => setModelsLoaded(true))
|
|
34
|
-
.catch(() => setModelsLoaded(false));
|
|
35
|
-
}, []);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (captureInProgress) {
|
|
38
|
-
startFaceDetection();
|
|
39
|
-
}
|
|
40
|
-
}, [captureInProgress]);
|
|
41
|
-
async function startCamera() {
|
|
42
|
-
setCaptureInProgress(true);
|
|
43
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
44
|
-
video: {
|
|
45
|
-
facingMode: mobileDevice ? 'user' : 'environment',
|
|
46
|
-
aspectRatio: mobileDevice ? 9 / 16 : 16 / 9,
|
|
47
|
-
width: { ideal: 1920 },
|
|
48
|
-
height: { ideal: 1080 },
|
|
49
|
-
},
|
|
50
|
-
audio: false,
|
|
51
|
-
});
|
|
52
|
-
setVideoStream(stream);
|
|
53
|
-
if (videoRef.current) {
|
|
54
|
-
videoRef.current.srcObject = stream;
|
|
55
|
-
videoRef.current.onloadedmetadata = () => {
|
|
56
|
-
videoRef.current
|
|
57
|
-
?.play()
|
|
58
|
-
.then(() => {
|
|
59
|
-
if (modelsLoaded) {
|
|
60
|
-
startFaceDetection();
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.catch((error) => {
|
|
64
|
-
console.error('Error playing video:', error);
|
|
65
|
-
setCameraError('Failed to play video stream. Please check your camera settings.');
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function startFaceDetection() {
|
|
71
|
-
if (!modelsLoaded) {
|
|
72
|
-
console.error('Cannot start face detection: video element not ready or models not loaded');
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (!faceCanvasRef.current) {
|
|
76
|
-
faceCanvasRef.current = faceapi.createCanvasFromMedia(videoRef.current);
|
|
77
|
-
const parentDiv = document.getElementById('parent');
|
|
78
|
-
faceCanvasRef.current.className = `absolute inset-0 m-auto h-${parentDiv?.clientHeight} w-${parentDiv?.clientWidth} md:aspect-video object-cover md:object-contain`;
|
|
79
|
-
faceCanvasRef.current.style.width = `${videoRef.current?.clientWidth}px`;
|
|
80
|
-
faceCanvasRef.current.style.height = `${videoRef.current?.clientHeight}px`;
|
|
81
|
-
}
|
|
82
|
-
const displaySize = {
|
|
83
|
-
width: videoRef.current?.clientWidth || 643,
|
|
84
|
-
height: videoRef.current?.clientHeight || 333,
|
|
85
|
-
};
|
|
86
|
-
// Clear any existing interval
|
|
87
|
-
if (detectionIntervalRef.current) {
|
|
88
|
-
clearInterval(detectionIntervalRef.current);
|
|
89
|
-
}
|
|
90
|
-
faceapi.matchDimensions(faceCanvasRef.current, displaySize);
|
|
91
|
-
let countdownInterval = null;
|
|
92
|
-
detectionIntervalRef.current = window.setInterval(async () => {
|
|
93
|
-
if (!videoRef.current || !faceCanvasRef.current) {
|
|
94
|
-
console.error('Video or canvas element is not ready');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
try {
|
|
98
|
-
const detection = await faceapi
|
|
99
|
-
.detectSingleFace(videoRef.current, new faceapi.TinyFaceDetectorOptions())
|
|
100
|
-
.withFaceLandmarks();
|
|
101
|
-
if (detection) {
|
|
102
|
-
const resizedDetection = faceapi.resizeResults(detection, displaySize);
|
|
103
|
-
const frame_height = resizedDetection.detection.box.height;
|
|
104
|
-
const frame_width = resizedDetection.detection.box.width;
|
|
105
|
-
const frame_x = resizedDetection.detection.box.x;
|
|
106
|
-
const frame_y = resizedDetection.detection.box.y;
|
|
107
|
-
const faceCenterX = frame_x + frame_width / 2;
|
|
108
|
-
const faceCenterY = frame_y + frame_height / 2;
|
|
109
|
-
const screenCenterX = displaySize.width / 2;
|
|
110
|
-
const screenCenterY = displaySize.height / 2;
|
|
111
|
-
const centerThresholdX = displaySize.width * 0.15;
|
|
112
|
-
const centerThresholdY = displaySize.height * 0.15;
|
|
113
|
-
const isFaceCentered = Math.abs(faceCenterX - screenCenterX) <= centerThresholdX &&
|
|
114
|
-
Math.abs(faceCenterY - screenCenterY) <= centerThresholdY;
|
|
115
|
-
setIsFaceCentered(isFaceCentered);
|
|
116
|
-
const faceDetectionConfidence = detection.detection.score * 100;
|
|
117
|
-
// const context = faceCanvasRef.current.getContext('2d');
|
|
118
|
-
// if (context) {
|
|
119
|
-
// context.clearRect(
|
|
120
|
-
// 0,
|
|
121
|
-
// 0,
|
|
122
|
-
// faceCanvasRef.current.width,
|
|
123
|
-
// faceCanvasRef.current.height,
|
|
124
|
-
// );
|
|
125
|
-
// faceapi.draw.drawDetections(
|
|
126
|
-
// faceCanvasRef.current,
|
|
127
|
-
// resizedDetection,
|
|
128
|
-
// );
|
|
129
|
-
// faceapi.draw.drawFaceLandmarks(
|
|
130
|
-
// faceCanvasRef.current,
|
|
131
|
-
// resizedDetection,
|
|
132
|
-
// );
|
|
133
|
-
// }
|
|
134
|
-
//adjust the faceDetectionConfidence if need
|
|
135
|
-
if (isFaceCentered && faceDetectionConfidence >= 65) {
|
|
136
|
-
if (!countdownInterval) {
|
|
137
|
-
setIsCapturing(true);
|
|
138
|
-
countdownInterval = setInterval(() => {
|
|
139
|
-
setCountdown((prev) => {
|
|
140
|
-
if (prev === 1) {
|
|
141
|
-
clearInterval(countdownInterval);
|
|
142
|
-
countdownInterval = null;
|
|
143
|
-
captureImage();
|
|
144
|
-
return 3;
|
|
145
|
-
}
|
|
146
|
-
return prev - 1;
|
|
147
|
-
});
|
|
148
|
-
}, 1000);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
if (countdownInterval) {
|
|
153
|
-
clearInterval(countdownInterval);
|
|
154
|
-
countdownInterval = null;
|
|
155
|
-
setCountdown(3);
|
|
156
|
-
setIsCapturing(false);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
console.error('Error during face detection:', error);
|
|
163
|
-
setCameraError('An error occurred while detecting your face. Please try again.');
|
|
164
|
-
}
|
|
165
|
-
}, 100);
|
|
166
|
-
}
|
|
167
|
-
function stopCamera() {
|
|
168
|
-
setCaptureInProgress(false);
|
|
169
|
-
if (detectionIntervalRef.current) {
|
|
170
|
-
clearInterval(detectionIntervalRef.current);
|
|
171
|
-
detectionIntervalRef.current = null;
|
|
172
|
-
}
|
|
173
|
-
if (countdownTimerRef.current) {
|
|
174
|
-
clearInterval(countdownTimerRef.current);
|
|
175
|
-
countdownTimerRef.current = null;
|
|
176
|
-
}
|
|
177
|
-
if (videoStream) {
|
|
178
|
-
videoStream.getTracks().forEach((track) => track.stop());
|
|
179
|
-
setVideoStream(null);
|
|
180
|
-
}
|
|
181
|
-
if (videoRef.current && videoRef.current.srcObject) {
|
|
182
|
-
const stream = videoRef.current.srcObject;
|
|
183
|
-
stream.getTracks().forEach((track) => {
|
|
184
|
-
track.stop();
|
|
185
|
-
});
|
|
186
|
-
videoRef.current.srcObject = null;
|
|
187
|
-
videoRef.current.pause();
|
|
188
|
-
videoRef.current.currentTime = 0;
|
|
189
|
-
videoRef.current.load();
|
|
190
|
-
}
|
|
191
|
-
setCountdown(3);
|
|
192
|
-
}
|
|
193
|
-
function captureImage() {
|
|
194
|
-
if (videoRef.current && faceCanvasRef.current) {
|
|
195
|
-
const canvas = document.createElement('canvas');
|
|
196
|
-
canvas.width = videoRef.current.videoWidth;
|
|
197
|
-
canvas.height = videoRef.current.videoHeight;
|
|
198
|
-
const context = canvas.getContext('2d');
|
|
199
|
-
if (context) {
|
|
200
|
-
context.drawImage(videoRef.current, 0, 0, canvas.width, canvas.height);
|
|
201
|
-
const imageData = canvas.toDataURL('image/png');
|
|
202
|
-
setSelectedImage(imageData);
|
|
203
|
-
stopCamera();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function retakePhoto() {
|
|
208
|
-
setSelectedImage(null);
|
|
209
|
-
setCaptureInProgress(true);
|
|
210
|
-
setCameraError(null);
|
|
211
|
-
if (faceCanvasRef.current) {
|
|
212
|
-
const canvas = faceCanvasRef.current.querySelector('canvas');
|
|
213
|
-
if (canvas) {
|
|
214
|
-
canvas.width = canvas.width;
|
|
215
|
-
}
|
|
216
|
-
faceCanvasRef.current.innerHTML = '';
|
|
217
|
-
}
|
|
218
|
-
if (videoRef.current) {
|
|
219
|
-
videoRef.current.play();
|
|
220
|
-
}
|
|
221
|
-
startCamera();
|
|
222
|
-
}
|
|
223
|
-
async function usePhoto() {
|
|
224
|
-
if (!selectedImage) {
|
|
225
|
-
console.error('No photo selected to use');
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
const blob = dataURLtoBlob(selectedImage);
|
|
229
|
-
const img = new File([blob], 'image', { type: blob.type });
|
|
230
|
-
const resizedImage = (await resizeFile(img));
|
|
231
|
-
if (resizedImage) {
|
|
232
|
-
props.setSelfieImage(resizedImage);
|
|
233
|
-
props.setCapturing(null);
|
|
234
|
-
stopCamera();
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
useEffect(() => {
|
|
238
|
-
return () => {
|
|
239
|
-
if (detectionIntervalRef.current) {
|
|
240
|
-
clearInterval(detectionIntervalRef.current);
|
|
241
|
-
}
|
|
242
|
-
if (countdownTimerRef.current) {
|
|
243
|
-
clearInterval(countdownTimerRef.current);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}, []);
|
|
247
|
-
return (_jsx(Dialog.Root, { open: props.capturing === 'SELFIE', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl', props.className), children: _jsxs("div", { className: "w-full p-4 lg:w-[640px] lg:px-12 lg:py-4xl", children: [_jsxs("button", { type: "button", className: "flex items-center gap-lg lg:absolute lg:right-5 lg:top-5 lg:p-md", onClick: () => {
|
|
248
|
-
stopCamera();
|
|
249
|
-
props.setCapturing(null);
|
|
250
|
-
}, children: [_jsx(XIcon, { className: "text-text-senary-300 hidden size-5 lg:block" }), _jsx(ArrowLeftIcon, { className: "text-text-senary-300 size-5 lg:hidden" }), _jsx("span", { className: "text-lg font-semibold lg:hidden", children: "Back" })] }), _jsx(Dialog.Title, { className: "mt-6 text-center text-lg font-semibold lg:mt-0", children: "Take a Selfie Holding Your ID" }), _jsx(Dialog.Description, { className: "text-text-tertiary-600 mx-auto mt-sm max-w-[19rem] text-center text-sm lg:max-w-full", children: "Make sure your face and ID are clearly visible, with no glare or blur." }), _jsx("div", { id: "parent", className: "border-border-disabled mt-6 aspect-video rounded-xl border bg-black lg:mt-8", children: captureInProgress ? (_jsxs("div", { className: "relative flex h-fit w-full flex-col items-center justify-center", children: [_jsx("video", { ref: videoRef, autoPlay: true, muted: true, className: "h-[60vh] w-full rounded-lg object-cover md:aspect-video md:h-[333px]", width: "100%", height: "100%" }), _jsx("canvas", { ref: faceCanvasRef, className: "absolute inset-0 h-[60vh] w-full object-cover md:aspect-video md:h-[333px] md:object-contain", width: "100%", height: "100%" }), isCapturing && (_jsx("span", { className: "absolute inset-x-0 bottom-8 flex items-center justify-center text-5xl font-bold text-[#713B12CC] md:bottom-4", children: countdown })), !isFaceCentered && (_jsx("span", { className: "absolute inset-x-0 bottom-12 mx-auto w-1/2 text-center text-xs text-white md:bottom-3", children: "Please center your face in the camera view. Make sure your ID is clearly visible next to your face." })), _jsx(PersonOverlayDesktop, { isFaceCentered: isFaceCentered, width: videoRef.current?.clientWidth || 543, height: videoRef.current?.clientHeight || 333 })] })) : (selectedImage && (_jsx("img", { src: selectedImage, alt: "Captured Photo", className: "h-full w-full rounded-lg object-cover md:aspect-video md:h-[333px]" }))) }), selectedImage && (_jsxs("div", { className: "flex flex-col items-center justify-center gap-2 md:flex-row", children: [_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-4 px-xl disabled:opacity-100", size: "sm", onClick: retakePhoto, type: "button", children: ["Retake Photo", _jsx(Camera01Icon, { className: "size-5" })] }), _jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-4 px-xl disabled:opacity-100", size: "sm", onClick: usePhoto, type: "button", children: ["Use Photo", _jsx(Camera01Icon, { className: "size-5" })] })] })), !captureInProgress && (_jsxs(Button, { className: twMerge('mx-auto mt-6 px-xl lg:mt-8', selectedImage && 'hidden'), onClick: startCamera, disabled: !modelsLoaded, type: "button", children: ["Start Camera", _jsx(Camera01Icon, { className: "size-5" })] }))] }) }) })] }) }));
|
|
251
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CaptureSubject } from '../../KYC/useKYC';
|
|
2
|
-
interface FileUploadProps {
|
|
3
|
-
name: string;
|
|
4
|
-
value: File | null;
|
|
5
|
-
hasDescription?: boolean;
|
|
6
|
-
onChange?: (id: File) => void;
|
|
7
|
-
captureObject: CaptureSubject;
|
|
8
|
-
}
|
|
9
|
-
declare function ImageUploader({ value, name, hasDescription, onChange, captureObject, }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export default ImageUploader;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import Image from 'next/image';
|
|
4
|
-
import { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { UploadCloud02Icon } from '../../../icons/UploadCloud02Icon.js';
|
|
6
|
-
import { Button } from '../../../ui/Button/index.js';
|
|
7
|
-
import { validateFile } from '../../KYC/utils.js';
|
|
8
|
-
import { useSignUpPagcorPropsContext } from './SignUpPagcorContext.js';
|
|
9
|
-
function ImageUploader({ value, name, hasDescription = true, onChange, captureObject, }) {
|
|
10
|
-
const props = useSignUpPagcorPropsContext();
|
|
11
|
-
const [previewUrl, setPreviewUrl] = useState(null);
|
|
12
|
-
const [error, setError] = useState(null);
|
|
13
|
-
const fileInputRef = useRef(null);
|
|
14
|
-
const handleFileChange = (event) => {
|
|
15
|
-
const file = event.target.files?.[0];
|
|
16
|
-
if (!file) {
|
|
17
|
-
setError('No file selected');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const validationError = validateFile(file);
|
|
21
|
-
if (validationError) {
|
|
22
|
-
setError(validationError);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
setError(null);
|
|
26
|
-
const url = URL.createObjectURL(file);
|
|
27
|
-
setPreviewUrl(url);
|
|
28
|
-
onChange?.(file);
|
|
29
|
-
return () => URL.revokeObjectURL(url);
|
|
30
|
-
};
|
|
31
|
-
const handleUploadClick = () => {
|
|
32
|
-
fileInputRef.current?.click();
|
|
33
|
-
};
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (value) {
|
|
36
|
-
setPreviewUrl(URL.createObjectURL(value));
|
|
37
|
-
}
|
|
38
|
-
}, [value]);
|
|
39
|
-
return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col items-center justify-center gap-lg rounded-xl border px-3xl py-xl", children: [error && (_jsx("p", { className: "text-text-error-600 mb-2 text-center text-sm", children: error })), previewUrl ? (_jsxs("div", { className: "flex w-full flex-col items-center", children: [_jsx("div", { className: "relative h-[9.25rem] w-full overflow-hidden rounded-md", children: _jsx(Image, { src: previewUrl, alt: "Uploaded image preview", fill: true, className: "object-contain", draggable: false, priority: true }) }), _jsx(Button, { size: "xs", variant: "outline", className: "mt-4 w-fit", type: "button", onClick: handleUploadClick, children: "Reupload" })] })) : (hasDescription && (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-border-primary shadow-xs flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsxs("p", { className: "text-text-tertiary-600 text-center text-sm", children: [_jsx("span", { className: "text-button-secondary-fg cursor-pointer font-semibold hover:underline", onClick: handleUploadClick, children: "Click to upload" }), ' ', "or drag and drop", _jsx("br", {}), "PNG, JPG, or JPEG (max. 10MB)"] })] }))), _jsx("input", { type: "file", id: `file-upload-${name}`, name: name, ref: fileInputRef, onChange: handleFileChange, accept: "image/png,image/jpg,image/jpeg", className: "hidden", "aria-label": "Upload image file" }), _jsx(Button, { size: "xs", variant: "outline", className: "mt-4 w-fit", onClick: () => props.setCapturing(captureObject), type: "button", children: value ? 'Retake Photo' : 'Take a Photo' })] }));
|
|
40
|
-
}
|
|
41
|
-
export default ImageUploader;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function SignUpFormPagcor(): import("react/jsx-runtime").JSX.Element;
|