diff --git a/src/pages/root/steps/data-step/components/cover-button/index.tsx b/src/pages/root/steps/data-step/components/cover-button/index.tsx index 2b3d339..e0b9aa1 100644 --- a/src/pages/root/steps/data-step/components/cover-button/index.tsx +++ b/src/pages/root/steps/data-step/components/cover-button/index.tsx @@ -1,4 +1,5 @@ import { useHapticFeedback } from "@vkruglikov/react-telegram-web-app"; +import { Replace } from "~/shared/ui/icons/replace"; import { XMark } from "~/shared/ui/icons/x-mark.tsx"; @@ -36,8 +37,8 @@ export const CoverButton = ({ src, onClick }: CoverButtonProps) => { } >
-
Удалить
- +
Изменить
+
); diff --git a/src/pages/root/steps/data-step/index.tsx b/src/pages/root/steps/data-step/index.tsx index 2878be1..c467205 100644 --- a/src/pages/root/steps/data-step/index.tsx +++ b/src/pages/root/steps/data-step/index.tsx @@ -14,6 +14,8 @@ import { useRootStore } from "~/shared/stores/root"; import { Checkbox } from "~/shared/ui/checkbox"; import { AudioPlayer } from "~/shared/ui/audio-player"; import { HashtagInput } from "~/shared/ui/hashtag-input"; +import { XMark } from "~/shared/ui/icons/x-mark"; +import { Replace } from "~/shared/ui/icons/replace"; type DataStepProps = { nextStep(): void; @@ -57,119 +59,140 @@ export const DataStep = ({ nextStep }: DataStepProps) => { })(); }; + const handleFileReset = () => { + rootStore.setFile(null); + rootStore.setFileSrc(''); + rootStore.setFileType(''); + } + return ( -
-
- /Заполните информацию о контенте -
- 1/5 -
+
+
+ /Заполните информацию о контенте +
+ 1/5
+
-
- - - +
+ + + - - - + + + - - - + + + - + + {!rootStore.fileSrc && <> { - rootStore.setFile(file); - rootStore.setFileSrc(URL.createObjectURL(file)); - rootStore.setFileType(file.type); // Save the file type for conditional rendering - }} + id={"file"} + shouldProcess={false} + accept={"video/mp4,video/x-m4v,video/*,audio/mp3,audio/*"} + onChange={(file) => { + rootStore.setFile(file); + rootStore.setFileSrc(URL.createObjectURL(file)); + rootStore.setFileType(file.type); // Save the file type for conditional rendering + }} /> - {!rootStore.fileSrc && } + + } - {rootStore.fileSrc && ( -
- {rootStore.fileType?.startsWith("audio") ? ( - - ) : ( - - )} -
- )} -
- -
- rootStore.setAllowCover(!rootStore.allowCover)} - checked={rootStore.allowCover} - /> + {rootStore.fileSrc && ( +
+ {rootStore.fileType?.startsWith("audio") ? ( + + ) : ( + + )} + +
+ )} +
- {rootStore.allowCover && ( - - { - rootStore.setCover(cover); - }} - /> - - {rootStore.cover ? ( - { - rootStore.setCover(null); - }} - /> - ) : ( - - )} - - )} -
-
- -
+ /> + + {rootStore.allowCover && ( + + + + {rootStore.cover ? ( + { + rootStore.setCover(null); + }} + /> + ) : ( + <> + { + rootStore.setCover(cover); + }} + /> + + + )} + + )} +
+ + +
); }; diff --git a/src/shared/services/file/index.ts b/src/shared/services/file/index.ts index 8a75ad9..03a830d 100644 --- a/src/shared/services/file/index.ts +++ b/src/shared/services/file/index.ts @@ -21,12 +21,12 @@ export const useUploadFile = () => { }>("/storage", formData, { headers: { "Content-Type": "multipart/form-data", - Authorization: localStorage.getItem('auth_v1_token') ?? "" + Authorization: localStorage.getItem('auth_v1_token') || "" }, onUploadProgress: (progressEvent) => { const percentCompleted = Math.round( - (progressEvent.loaded * 100) / (progressEvent?.total as number) ?? + (progressEvent.loaded * 100) / (progressEvent?.total as number) || 0, ); setUploadProgress(percentCompleted); diff --git a/src/shared/stores/root/index.ts b/src/shared/stores/root/index.ts index 376d717..94a9ab4 100644 --- a/src/shared/stores/root/index.ts +++ b/src/shared/stores/root/index.ts @@ -13,7 +13,7 @@ type RootStore = { setAuthor: (author: string) => void; file: File | null; - setFile: (file: File) => void; + setFile: (file: File | null) => void; fileType: string; setFileType: (type: string) => void; diff --git a/src/shared/ui/icons/replace.tsx b/src/shared/ui/icons/replace.tsx new file mode 100644 index 0000000..c256953 --- /dev/null +++ b/src/shared/ui/icons/replace.tsx @@ -0,0 +1,9 @@ +export const Replace = () => { + return ( + + + + + + ); +};