1
0
forked from YaBL/app

fix (web): refactor upload page

This commit is contained in:
Michael 2025-08-18 15:57:55 +03:00
parent f6de4891b1
commit 0c326e82a8
3 changed files with 12 additions and 13 deletions

View File

@ -38,6 +38,7 @@
.main_page_container { .main_page_container {
display: flex; display: flex;
gap: 50px; gap: 50px;
height: 100%;
} }
@media screen and (max-width: 470px) { /* кнопки в столбик */ @media screen and (max-width: 470px) { /* кнопки в столбик */

View File

@ -23,7 +23,7 @@ const AccountPage = () => {
icon: "shelves", icon: "shelves",
}, },
{ {
name: "Загрузить книгу", name: "Загрузить",
path: "/upload", path: "/upload",
icon: "upload", icon: "upload",
}, },

View File

@ -57,11 +57,10 @@ function UploadBook() {
setUploadStatuses((prev) => ({ ...prev, [i]: 1 })); setUploadStatuses((prev) => ({ ...prev, [i]: 1 }));
console.log(uploadStatuses); console.log(uploadStatuses);
} else { } else {
toast("Ошибка на сервере, go дебажить."); toast.error("Ошибка при загрузке книги");
} }
} catch (err) { } catch (err) {
console.error("Ошибка:", err); toast.error("Ошибка при загрузке книги");
toast("Шатался интернет или сервер умер.");
} }
} }
@ -72,11 +71,9 @@ function UploadBook() {
return <span>Недоступно оффлайн</span>; return <span>Недоступно оффлайн</span>;
} }
return ( return (
<div className="flex flex-col items-center justify-center h-screen"> <div className="flex flex-col items-center justify-center h-full w-full">
<h1 className="text-2xl font-bold mb-4">Загрузка литературы</h1>
<div <div
className={`flex items-center justify-around w-full max-w-lg h-50 mb-4 rounded-xl flex-col gap-1 px-4 border-2 border-dashed transition-colors duration-200 cursor-pointer border-(--md-sys-color-outline) ${ className={`flex items-center justify-around w-[calc(100%-32px)] max-w-lg h-50 mb-4 px-4 rounded-xl flex-col gap-1 transition-colors duration-200 ${uploading ? 'cursor-wait' : 'cursor-pointer'} ${
isDragging isDragging
? "bg-(--md-sys-color-surface-variant)" ? "bg-(--md-sys-color-surface-variant)"
: "bg-(--md-sys-color-inverse-on-surface)" : "bg-(--md-sys-color-inverse-on-surface)"
@ -87,8 +84,8 @@ function UploadBook() {
onDragLeave={handleDragLeave} onDragLeave={handleDragLeave}
> >
<> <>
<span className="font-bold">Перетащи файл сюда или кликни</span> <span className="font-bold text-center">Перетащите файл или нажмите для выбора</span>
<IconButton className="w-24 h-24"> <IconButton className="w-24 h-24" disabled={uploading}>
<Icon className="text-6xl w-24 h-24">upload_file</Icon> <Icon className="text-6xl w-24 h-24">upload_file</Icon>
</IconButton> </IconButton>
<span className="text-sm">Поддерживается .fb2 и .pdf</span> <span className="text-sm">Поддерживается .fb2 и .pdf</span>
@ -99,13 +96,14 @@ function UploadBook() {
accept=".fb2,.pdf" accept=".fb2,.pdf"
ref={fileSelectorRef} ref={fileSelectorRef}
className="hidden" className="hidden"
disabled={uploading}
onChange={handleFileChange} onChange={handleFileChange}
/> />
</div> </div>
<div className="w-full max-w-lg bg-(--md-sys-color-surface-variant) flex p-[18px] rounded-2xl flex-col max-h-60 overflow-scroll gap-3 mb-4"> <div className={`w-[calc(100%-32px)] max-w-lg bg-(--md-sys-color-inverse-on-surface) flex p-4 rounded-2xl flex-col max-h-60 overflow-scroll gap-3 mb-4 ${uploadedFiles.length === 0 ? 'hidden' : ''}`}>
{uploadedFiles.length === 0 ? <span>Нечего загружать</span> : <></>} {uploadedFiles.length === 0 ? <span>Нечего загружать</span> : <></>}
{uploadedFiles.map((file, i) => ( {uploadedFiles.map((file, i) => (
<div className="flex justify-between" key={i}> <div className="flex justify-between items-center" key={i}>
<span className="truncate w-[calc(100%-42px)] inline-block"> <span className="truncate w-[calc(100%-42px)] inline-block">
{file.name} {file.name}
</span> </span>
@ -130,7 +128,7 @@ function UploadBook() {
))} ))}
</div> </div>
<FilledButton onClick={handleUpload} disabled={uploading}> <FilledButton onClick={handleUpload} disabled={uploading || uploadedFiles.length===0}>
Загрузить Загрузить
</FilledButton> </FilledButton>
</div> </div>