1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

removed almost all node sagas

This commit is contained in:
Fedor Katurov 2022-01-02 20:44:41 +07:00
parent f76a5a4798
commit 168ba8cc04
30 changed files with 268 additions and 448 deletions

View file

@ -14,6 +14,7 @@ type IProps = HTMLAttributes<HTMLDivElement> & {
group: ICommentGroup;
isSame?: boolean;
canEdit?: boolean;
saveComment: (data: IComment) => Promise<unknown>;
onDelete: (id: IComment['id'], isLocked: boolean) => void;
onShowImageModal: (images: IFile[], index: number) => void;
};
@ -29,6 +30,7 @@ const Comment: FC<IProps> = memo(
canEdit,
onDelete,
onShowImageModal,
saveComment,
...props
}) => {
return (
@ -50,6 +52,7 @@ const Comment: FC<IProps> = memo(
return (
<CommentContent
saveComment={saveComment}
nodeId={nodeId}
comment={comment}
key={comment.id}

View file

@ -18,12 +18,13 @@ interface IProps {
nodeId: number;
comment: IComment;
canEdit: boolean;
saveComment: (data: IComment) => Promise<unknown>;
onDelete: (id: IComment['id'], isLocked: boolean) => void;
onShowImageModal: (images: IFile[], index: number) => void;
}
const CommentContent: FC<IProps> = memo(
({ comment, canEdit, nodeId, onDelete, onShowImageModal }) => {
({ comment, canEdit, nodeId, saveComment, onDelete, onShowImageModal }) => {
const [isEditing, setIsEditing] = useState(false);
const startEditing = useCallback(() => setIsEditing(true), [setIsEditing]);
@ -58,7 +59,14 @@ const CommentContent: FC<IProps> = memo(
);
if (isEditing) {
return <CommentForm nodeId={nodeId} comment={comment} onCancelEdit={stopEditing} />;
return (
<CommentForm
saveComment={saveComment}
nodeId={nodeId}
comment={comment}
onCancelEdit={stopEditing}
/>
);
}
return (

View file

@ -20,17 +20,24 @@ import { Filler } from '~/components/containers/Filler';
interface IProps {
comment?: IComment;
nodeId: INode['id'];
saveComment: (data: IComment) => Promise<unknown>;
onCancelEdit?: () => void;
}
const CommentForm: FC<IProps> = ({ comment, nodeId, onCancelEdit }) => {
const CommentForm: FC<IProps> = ({ comment, nodeId, saveComment, onCancelEdit }) => {
const [textarea, setTextarea] = useState<HTMLTextAreaElement>();
const uploader = useFileUploader(
UPLOAD_SUBJECTS.COMMENT,
UPLOAD_TARGETS.COMMENTS,
comment?.files
);
const formik = useCommentFormFormik(comment || EMPTY_COMMENT, nodeId, uploader, onCancelEdit);
const formik = useCommentFormFormik(
comment || EMPTY_COMMENT,
nodeId,
uploader,
saveComment,
onCancelEdit
);
const isLoading = formik.isSubmitting || uploader.isUploading;
const isEditing = !!comment?.id;