diff --git a/src/widgets/action-editor/ui/ActionEditor.tsx b/src/widgets/action-editor/ui/ActionEditor.tsx index 43e30d8..5e399ac 100644 --- a/src/widgets/action-editor/ui/ActionEditor.tsx +++ b/src/widgets/action-editor/ui/ActionEditor.tsx @@ -11,7 +11,8 @@ import CircularProgress from "@mui/material/CircularProgress"; import TextFieldsIcon from "@mui/icons-material/TextFields"; import ImageIcon from "@mui/icons-material/Image"; -// import RecordVoiceOverIcon from "@mui/icons-material/RecordVoiceOver"; +import RecordVoiceOverIcon from "@mui/icons-material/RecordVoiceOver"; +import MicNoneIcon from "@mui/icons-material/MicNone"; interface TabPanelProps { children?: React.ReactNode; @@ -59,6 +60,8 @@ export default function ActionEditor({ canExit = false, }: ActionEditorProps) { const imageRef = useRef(null); + const voiceRef = useRef(null); + const attachmentType = initialAction ? getActionAttachmentType(initialAction) : "empty"; @@ -75,6 +78,12 @@ export default function ActionEditor({ : null, ); + const [voiceUrl, setVoiceUrl] = useState( + initialAction && attachmentType === "voice" + ? initialAction.fileUrls[0]! + : null, + ); + const [action, setAction] = useState( initialAction ?? { actionType: "comment", @@ -106,6 +115,8 @@ export default function ActionEditor({ if (origin === "image") { setImageUrl(fileUrl); + } else if (origin === "voice") { + setVoiceUrl(fileUrl); } setLoading(false); @@ -137,8 +148,16 @@ export default function ActionEditor({ fileUrls: [imageUrl], }); } else if (value === 2) { - alert("Unsupported"); - return; + if (!voiceUrl) { + alert("Загрузите голосовое :3"); + return; + } + + onSave(actionIndex, { + actionType: action.actionType, + text: null, + fileUrls: [voiceUrl], + }); } } @@ -154,11 +173,11 @@ export default function ActionEditor({ > } {...a11yProps(0)} /> } {...a11yProps(1)} /> - {/* } {...a11yProps(2)} - /> */} + /> @@ -212,6 +231,7 @@ export default function ActionEditor({ await handleFileChange(e, "image")} @@ -233,9 +253,37 @@ export default function ActionEditor({ /> - {/* - In progress - */} + +
+ await handleFileChange(e, "voice")} + /> + + + {voiceUrl && ( +
+ +
+ )} +
+