From dd30941fd4e79cc46367432d8b600f2bce5bfedf Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 9 Mar 2024 00:13:45 +0700 Subject: [PATCH] action editor --- src/widgets/action-editor/index.ts | 1 + src/widgets/action-editor/ui/ActionEditor.tsx | 133 ++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/widgets/action-editor/index.ts create mode 100644 src/widgets/action-editor/ui/ActionEditor.tsx diff --git a/src/widgets/action-editor/index.ts b/src/widgets/action-editor/index.ts new file mode 100644 index 0000000..7d79c9c --- /dev/null +++ b/src/widgets/action-editor/index.ts @@ -0,0 +1 @@ +export { default as ActionEditor } from "./ui/ActionEditor"; diff --git a/src/widgets/action-editor/ui/ActionEditor.tsx b/src/widgets/action-editor/ui/ActionEditor.tsx new file mode 100644 index 0000000..c378f3c --- /dev/null +++ b/src/widgets/action-editor/ui/ActionEditor.tsx @@ -0,0 +1,133 @@ +import { useState } from "react"; +import type { CommentAction } from "@/entities/action/schema"; + +import Tabs from "@mui/material/Tabs"; +import Tab from "@mui/material/Tab"; +import Box from "@mui/material/Box"; +import { Button, TextField } from "@mui/material"; + +import TextFieldsIcon from "@mui/icons-material/TextFields"; +import ImageIcon from "@mui/icons-material/Image"; +import RecordVoiceOverIcon from "@mui/icons-material/RecordVoiceOver"; +import VideocamIcon from "@mui/icons-material/Videocam"; + +interface TabPanelProps { + children?: React.ReactNode; + index: number; + value: number; +} + +function TabPanel(props: TabPanelProps) { + const { children, value, index, ...other } = props; + + return ( + + ); +} + +function a11yProps(index: number) { + return { + id: `simple-tab-${index}`, + "aria-controls": `simple-tabpanel-${index}`, + }; +} + +interface ActionEditorProps { + actionIndex?: number; + initialAction?: CommentAction; + onSave?: (actionIndex: number, action: CommentAction) => Promise | void; +} + +export default function ActionEditor({ + actionIndex = 0, + initialAction, + onSave, +}: ActionEditorProps) { + const [value, setValue] = useState(0); + + const [action, setAction] = useState( + initialAction ?? { + actionType: "comment", + text: "", + fileUrls: [], + }, + ); + + const handleChange = (_: React.SyntheticEvent, newValue: number) => { + setValue(newValue); + }; + + return ( + <> +
+ + + + } {...a11yProps(0)} /> + } {...a11yProps(1)} /> + } + {...a11yProps(2)} + /> + } {...a11yProps(2)} /> + + + + + + setAction((currentAction) => ({ + ...currentAction, + text: event.target.value, + })) + } + /> + + + + In progress + + + + In progress + + + + In progress + + +
+ +
+ +
+ + ); +}