From 1d22ac21730e1ade597fb404c828b7850db5a871 Mon Sep 17 00:00:00 2001 From: Saidakrom Rakhmedov Date: Sat, 1 Feb 2025 20:21:56 +0500 Subject: [PATCH] add reset attachment --- src/pages/root/steps/data-step/index.tsx | 221 ++++++++++++----------- src/shared/stores/root/index.ts | 2 +- 2 files changed, 119 insertions(+), 104 deletions(-) diff --git a/src/pages/root/steps/data-step/index.tsx b/src/pages/root/steps/data-step/index.tsx index 2878be1..a601b98 100644 --- a/src/pages/root/steps/data-step/index.tsx +++ b/src/pages/root/steps/data-step/index.tsx @@ -14,6 +14,7 @@ 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"; type DataStepProps = { nextStep(): void; @@ -57,119 +58,133 @@ export const DataStep = ({ nextStep }: DataStepProps) => { })(); }; + const handleFileReset = () => { + rootStore.setFile(null); + rootStore.setFileSrc(''); + rootStore.setFileType(''); + } + return ( -
-
- /Заполните информацию о контенте -
- 1/5 -
+
+
+ /Заполните информацию о контенте +
+ 1/5
+
-
- - - +
+ + + - - - + + + - - - + + + - - { - rootStore.setFile(file); - rootStore.setFileSrc(URL.createObjectURL(file)); - rootStore.setFileType(file.type); // Save the file type for conditional rendering - }} - /> + + { + rootStore.setFile(file); + rootStore.setFileSrc(URL.createObjectURL(file)); + rootStore.setFileType(file.type); // Save the file type for conditional rendering + }} + /> - {!rootStore.fileSrc && } + {!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.setCover(cover); + }} + /> + + {rootStore.cover ? ( + { + rootStore.setCover(null); + }} + /> + ) : ( + + )} + + )} +
+ + +
); }; diff --git a/src/shared/stores/root/index.ts b/src/shared/stores/root/index.ts index 2a0d84a..f9decdd 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;