mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
#34 made submitting comment form
This commit is contained in:
parent
051b199d5d
commit
dad416e6e2
6 changed files with 97 additions and 65 deletions
|
@ -15,20 +15,13 @@ import { EMPTY_COMMENT } from '~/redux/node/constants';
|
|||
interface IProps {
|
||||
comment?: IComment;
|
||||
nodeId: INode['id'];
|
||||
isBefore?: boolean;
|
||||
onCancelEdit?: () => void;
|
||||
}
|
||||
|
||||
const LocalCommentForm: FC<IProps> = ({ comment, nodeId, isBefore, onCancelEdit }) => {
|
||||
const LocalCommentForm: FC<IProps> = ({ comment, nodeId, onCancelEdit }) => {
|
||||
const [textarea, setTextarea] = useState<HTMLTextAreaElement>();
|
||||
const uploader = useFileUploader(UPLOAD_SUBJECTS.COMMENT, UPLOAD_TARGETS.COMMENTS);
|
||||
const formik = useCommentFormFormik(
|
||||
comment || EMPTY_COMMENT,
|
||||
nodeId,
|
||||
uploader,
|
||||
onCancelEdit,
|
||||
isBefore
|
||||
);
|
||||
const formik = useCommentFormFormik(comment || EMPTY_COMMENT, nodeId, uploader, onCancelEdit);
|
||||
const isLoading = formik.isSubmitting || uploader.isUploading;
|
||||
const isEditing = !!comment?.id;
|
||||
|
||||
|
@ -51,6 +44,7 @@ const LocalCommentForm: FC<IProps> = ({ comment, nodeId, isBefore, onCancelEdit
|
|||
)}
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
size="small"
|
||||
color="gray"
|
||||
iconRight={!isEditing ? 'enter' : 'check'}
|
||||
|
|
|
@ -19,7 +19,7 @@ const NodeCommentFormUnconnected: FC<IProps> = ({ user, isBefore, nodeId }) => {
|
|||
return (
|
||||
<CommentWrapper user={user}>
|
||||
<CommentForm id={0} is_before={isBefore} />
|
||||
<LocalCommentForm isBefore={isBefore} nodeId={nodeId} />
|
||||
<LocalCommentForm nodeId={nodeId} />
|
||||
</CommentWrapper>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue