continue: user verification

This commit is contained in:
smanylov
2026-04-02 16:46:50 +07:00
parent 9b83ba3176
commit d6dee3361e
3 changed files with 130 additions and 84 deletions
+51 -1
View File
@@ -220,8 +220,58 @@
} }
} }
.verefication-section { &.verefication-section {
height: 100%;
display: flex;
flex-direction: column;
.verefication-block {
flex-grow: 1;
display: flex;
flex-direction: column;
.drag-drop-zone {
border: 2px dashed #6366f1;
border-radius: .75rem;
padding: 10px;
}
.selected-file-action-panel {
display: flex;
justify-content: center;
gap: 10px;
}
.selected-file-actions {
display: flex;
justify-content: center;
gap: 10px;
}
.description {
font-size: 12px;
color: v.$text-s;
}
.btn {
padding: 5px 12px;
}
.btn-confirm {
background: v.$p-color;
color: v.$white;
background: linear-gradient(135deg, v.$p-color, v.$s-color);
color: v.$white;
border: 2px solid transparent;
padding: 2px 10px;
}
.btn-cancel {
border: 2px solid v.$p-color;
padding: 2px 10px;
}
}
} }
} }
@@ -115,6 +115,11 @@ export default function VerificationUploadSection({
const currentFileNames = new Set<string>(); const currentFileNames = new Set<string>();
const duplicateNames: string[] = []; const duplicateNames: string[] = [];
if (selectedFiles.length + files.length > 4) {
setError('max-lenght');
return
}
for (const file of files) { for (const file of files) {
if (selectedFileNames.has(file.name)) { if (selectedFileNames.has(file.name)) {
duplicateNames.push(file.name); duplicateNames.push(file.name);
@@ -398,7 +403,7 @@ export default function VerificationUploadSection({
}); });
return ( return (
<div className="" > <div className="verefication-block" >
<h3> <h3>
Загрузка изображений удостоверения личности Загрузка изображений удостоверения личности
</h3> </h3>
@@ -409,9 +414,9 @@ export default function VerificationUploadSection({
onDragLeave={handleDragLeave} onDragLeave={handleDragLeave}
onDrop={handleDrop} onDrop={handleDrop}
> >
<h4> {/* <h4>
{t('drag-the-file-here')} {t('drag-the-file-here')}
</h4> </h4> */}
{ {
fileType === "image" && ( fileType === "image" && (
@@ -423,9 +428,9 @@ export default function VerificationUploadSection({
<p className="description" > <p className="description" >
{t('file-format')}: {acceptString} {t('file-format')}: {acceptString}
</p> </p>
< p className="description" > {/* < p className="description" >
{t('file-size')}: {t('to')} {(maxFileSize / 1024 / 1024)} {t('mb')} {t('file-size')}: {t('to')} {(maxFileSize / 1024 / 1024)} {t('mb')}
</p> </p> */}
< input < input
ref={fileInputRef} ref={fileInputRef}
@@ -437,15 +442,6 @@ export default function VerificationUploadSection({
multiple // Добавляем multiple для выбора нескольких файлов multiple // Добавляем multiple для выбора нескольких файлов
/> />
<button
className="btn btn-primary"
onClick={() => fileInputRef.current?.click()}
type="button"
disabled={uploadingCount > maxParallelUploads}
>
выберете документ для загрузки
</button>
{ {
error && ( error && (
<div className="error-message"> <div className="error-message">
@@ -456,9 +452,9 @@ export default function VerificationUploadSection({
{ {
selectedFiles.length > 0 && ( selectedFiles.length > 0 && (
<div className="mt-6" > <div className="mt-4" >
<div className="selected-file-action-panel" > <div className="selected-file-action-panel" >
<div> {/* <div>
<p className="selected-file-action-info" > <p className="selected-file-action-info" >
<span>{t('total-files')}: {selectedFiles.length}</span> <span>{t('total-files')}: {selectedFiles.length}</span>
<span>{t('uploading')}: {uploadingCount}</span> <span>{t('uploading')}: {uploadingCount}</span>
@@ -472,25 +468,23 @@ export default function VerificationUploadSection({
> >
</div> </div>
</div> </div>
</div> </div> */}
<div className="flex gap-2"> <button
<button className={`btn btn-primary`}
className={`btn btn-primary`} onClick={handleStartAllUploads}
onClick={handleStartAllUploads} type="button"
type="button" disabled={uploadingCount > 0 || selectedFiles.every(f => f.status !== 'pending')}
disabled={uploadingCount > 0 || selectedFiles.every(f => f.status !== 'pending')} >
> {t('upload-all')}
{t('upload-all')} </button>
</button> < button
< button className="btn btn-primary"
className="btn btn-primary" onClick={() => handleClearFile()}
onClick={() => handleClearFile()} type="button"
type="button" >
> {t('clear-all')}
{t('clear-all')} </button>
</button>
</div>
</div> </div>
<div className="selected-file-wrapper"> <div className="selected-file-wrapper">
@@ -505,10 +499,12 @@ export default function VerificationUploadSection({
<p className="text-gray-700" > <p className="text-gray-700" >
<span className="font-medium" > {t('file')}: </span> {file.name} <span className="font-medium" > {t('file')}: </span> {file.name}
</p> </p>
< p className="text-gray-700" >
{/* < p className="text-gray-700" >
<span className="font-medium" > {t('size')}: </span> {file.size} <span className="font-medium" > {t('size')}: </span> {file.size}
</p> </p> */}
< p className="text-gray-700" >
{/* < p className="text-gray-700" >
<span className="font-medium" > {t('status')}: </span> <span className="font-medium" > {t('status')}: </span>
<span className={`ml-2 ${file.status === 'completed' ? 'text-green-600' : <span className={`ml-2 ${file.status === 'completed' ? 'text-green-600' :
file.status === 'uploading' ? 'text-blue-600' : file.status === 'uploading' ? 'text-blue-600' :
@@ -522,23 +518,49 @@ export default function VerificationUploadSection({
t('pending') t('pending')
} }
</span> </span>
</p> </p> */}
{ {
file.error && ( file.error && (
<p className="text-red-600 text-sm mt-1" > {file.error} </p> <p className="text-red-600 text-sm mt-1" > {file.error} </p>
) )
} }
</div> </div>
<div className="selected-file-right-block"> <div className="selected-file">
<div> <div className="w-full bg-gray-200 rounded-full h-2.5 mt-2 mb-2">
<span className={ <div
className="bg-blue-600 h-2.5 rounded-full transition-all duration-300"
style={{ width: `${file.progress}%` }
}
>
</div>
</div>
{/* <span className={
`upload-progress ${file.status === 'completed' ? 'text-green-600' : `upload-progress ${file.status === 'completed' ? 'text-green-600' :
file.status === 'uploading' ? 'text-blue-600' : file.status === 'uploading' ? 'text-blue-600' :
'text-gray-600' 'text-gray-600'
}` }`
}> }>
{file.progress} % {file.progress} %
</span> </span> */}
<div
className="selected-file-actions"
>
{
file.status === 'pending' && (
<button
className="btn btn-confirm"
onClick={() => uploadSingleFile(file, 'single')
}
type="button"
disabled={uploadingCount >= maxParallelUploads}
>
{t('start-upload')}
</button>
)
}
< button < button
className="btn btn-cancel" className="btn btn-cancel"
onClick={() => handleClearFile(file.uploadId || file.name)} onClick={() => handleClearFile(file.uploadId || file.name)}
@@ -549,44 +571,20 @@ export default function VerificationUploadSection({
</div> </div>
</div> </div>
</div> </div>
{/* {
(fileType === 'image' && file.preview) && (
<div
className="image-preview-wrapper"
>
<img
src={file.preview}
alt="Предпросмотр загруженного документа"
className="uploaded-image"
onError={() => setError('Не удалось загрузить превью документа')
}
/>
</div>
)
} */}
{
file.status === 'pending' && (
<div className="mt-2 text-center" >
<button
className="btn btn-confirm"
onClick={() => uploadSingleFile(file, 'single')
}
type="button"
disabled={uploadingCount >= maxParallelUploads}
>
{t('start-upload')}
</button>
</div>
)}
</div> </div>
))} ))}
</div> </div>
</div> </div>
)} )}
</div> </div>
<button
className="btn btn-primary mt-auto"
onClick={() => fileInputRef.current?.click()}
type="button"
disabled={uploadingCount > maxParallelUploads}
>
выберете документ(ы) для загрузки
</button>
</div> </div>
); );
} }
@@ -15,16 +15,14 @@ export default function SettingUserVerification() {
<h3 className="form-section-title"> <h3 className="form-section-title">
Верификация юзера Верификация юзера
</h3> </h3>
<form> <VerificationUploadSection
{/* <VerificationUploadSection fileType="image"
fileType="image" allowedExtensions={allFilesExtensions.images}
allowedExtensions={allFilesExtensions.images} maxFileSize={allFilesExtensions.maxFileSize}
maxFileSize={allFilesExtensions.maxFileSize} />
/> */} {/* <button type="submit" className="btn btn-primary">
{/* <button type="submit" className="btn btn-primary">
загрузить загрузить
</button> */} </button> */}
</form>
</div> </div>
</div> </div>
) )