mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
comment undelete
This commit is contained in:
parent
45d6e9a052
commit
ba6b0bfe98
6 changed files with 50 additions and 6 deletions
25
src/components/node/CommendDeleted/index.tsx
Normal file
25
src/components/node/CommendDeleted/index.tsx
Normal file
|
@ -0,0 +1,25 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import styles from './styles.scss';
|
||||
import { Button } from '~/components/input/Button';
|
||||
import { nodeLockComment } from '~/redux/node/actions';
|
||||
import { IComment } from '~/redux/types';
|
||||
|
||||
interface IProps {
|
||||
id: IComment['id'];
|
||||
onDelete: typeof nodeLockComment;
|
||||
}
|
||||
|
||||
const CommendDeleted: FC<IProps> = ({ id, onDelete }) => {
|
||||
const onRestore = useCallback(() => onDelete(id, false), [onDelete]);
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<div>Комментарий удалён</div>
|
||||
<Button size="mini" onClick={onRestore} iconLeft="restore">
|
||||
Восстановить
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export { CommendDeleted };
|
13
src/components/node/CommendDeleted/styles.scss
Normal file
13
src/components/node/CommendDeleted/styles.scss
Normal file
|
@ -0,0 +1,13 @@
|
|||
.wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: row;
|
||||
padding: $gap;
|
||||
text-transform: uppercase;
|
||||
|
||||
div {
|
||||
flex: 1;
|
||||
font: $font_14_semibold;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import * as styles from './styles.scss';
|
|||
import { nodeLockComment, nodeEditComment } from '~/redux/node/actions';
|
||||
import { INodeState } from '~/redux/node/reducer';
|
||||
import { CommentForm } from '../CommentForm';
|
||||
import { CommendDeleted } from '../CommendDeleted';
|
||||
|
||||
type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||
is_empty?: boolean;
|
||||
|
@ -43,7 +44,7 @@ const Comment: FC<IProps> = memo(
|
|||
<div className={styles.wrap}>
|
||||
{comment_group.comments.map(comment => {
|
||||
if (comment.deleted_at) {
|
||||
return <div key={comment.id}>deleted</div>;
|
||||
return <CommendDeleted id={comment.id} onDelete={onDelete} key={comment.id} />;
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(comment_data, comment.id)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue