Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cards): comment #4458

Merged
merged 26 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6b9580d
add mutations
ariunzayarin Jun 9, 2023
beb5954
little fix
munkhsaikhan Jun 8, 2023
cae6959
Translation purchase (#4442)
uuganaa1007 Jun 8, 2023
001ae59
Add-webmessenger-in-opensource-customers (#4408)
soyombo-baterdene Jun 9, 2023
93ab85b
update(notifications): add index
munkhsaikhan Jun 10, 2023
284276a
update(cards): little
munkhsaikhan Jun 10, 2023
8be5227
remove branches departments for currentuser on ui
munkhsaikhan Jun 10, 2023
027e9f4
stop doing core to core RPC
dulguun0225 Jun 11, 2023
7f89e96
enable query deduplication
dulguun0225 Jun 11, 2023
b91e85c
fix(integration) fix required of channels field in creating integrations
Gerelsukh Jun 12, 2023
0992af7
fix loading everywhere bug
Jun 12, 2023
8685cea
perf(client portal) improve client portal comments logic
nandinboldn Jun 12, 2023
8c46ab5
add isEnabled (#4453)
ariunzayarin Jun 12, 2023
68d2e23
fix(nav): more button style (#4455)
ariunzayarin Jun 12, 2023
b40e3a6
fix email widget shrink (#4456)
ariunzayarin Jun 12, 2023
7fbf80a
add comment from team
ariunzayarin Jun 12, 2023
66d3c9b
see user details
nandinboldn Jun 12, 2023
533d424
fix commentor name and avatar
ariunzayarin Jun 13, 2023
d615c0e
Merge branch 'staging' into fix-comment
ariunzayarin Jun 13, 2023
e9928dc
little fix
ariunzayarin Jun 13, 2023
434d8c0
add refetch
ariunzayarin Jun 13, 2023
8c498c7
refactor
ariunzayarin Jun 13, 2023
de452b3
refactor
ariunzayarin Jun 16, 2023
dcdc97a
liitle fix
ariunzayarin Jun 16, 2023
f68abf2
add remove action
ariunzayarin Jun 18, 2023
861000b
merge with staging
Jun 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion client-portal/modules/card/components/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export default class CardDetail extends React.Component<
/>
<div>
<CommentContent>
<h5>{`${createdUser?.firstName} ${createdUser?.lastName}`}</h5>
<h5>
Anu-Ujin marked this conversation as resolved.
Show resolved Hide resolved
{renderUserFullName(createdUser)}
</h5>
<div
className="comment"
dangerouslySetInnerHTML={{ __html: comment.content }}
Expand Down
9 changes: 4 additions & 5 deletions client-portal/modules/card/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ const clientPortalComments = `
content
createdUser {
_id
avatar
firstName
fullName
lastName
email
username
details {
firstName
lastName
fullName
}
}
createdAt
userType
Expand Down
15 changes: 7 additions & 8 deletions client-portal/modules/main/containers/notifications/List.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IUser, NotificationsQueryResponse } from "../../../types";
import { gql, useMutation, useQuery } from "@apollo/client";

import { IUser, NotificationsQueryResponse } from '../../../types';
import { gql, useMutation, useQuery } from '@apollo/client';
import Alert from "../../../utils/Alert";
import NotificationList from "../../components/notifications/List";
import React from "react";
Expand Down Expand Up @@ -84,8 +83,8 @@ function NotificationsContainer(props: Props) {
const markAsRead = (ids: string[]) => {
markAsReadMutaion({
variables: {
ids,
},
ids
}
});
};

Expand All @@ -109,9 +108,9 @@ function NotificationsContainer(props: Props) {
skip: !props.currentUser,
variables: {
page: 1,
perPage: 10,
perPage: 10
},
fetchPolicy: "network-only",
fetchPolicy: 'network-only'
}
);

Expand All @@ -135,7 +134,7 @@ function NotificationsContainer(props: Props) {
markAsRead,
showNotifications,
markAllAsRead,
refetch,
refetch
};

return <NotificationList {...updatedProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default {
_id: user._id,
avatar: details.avatar,
firstName: details.firstName,
lastName: details.lastName
lastName: details.lastName,
fullName: details.fullName,
email: user.email
};
}

Expand All @@ -43,8 +45,10 @@ export default {
return {
_id: cpUser._id,
avatar: cpUser.avatar,
fullName: `${cpUser.firstName} ${cpUser.lastName}`,
firstName: cpUser.firstName,
lastName: cpUser.lastName
lastName: cpUser.lastName,
email: cpUser.email
};
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type VerificationRequest {
_id: String!
createdAt: Date
modifiedAt: Date
fullName: String
firstName: String
lastName: String
phone: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const types = `
userType: String,
content: String

createdUser: User
createdUser: ClientPortalUser
createdAt: Date
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TAG_TYPES } from '@erxes/ui-tags/src/constants';
import TaggerPopover from '@erxes/ui-tags/src/components/TaggerPopover';
import Tags from '@erxes/ui/src/components/Tags';
import Watch from '../../containers/editForm/Watch';
import Comment from '../../../comment/components/Comment';
import Comment from '../../../comment/containers/Comment';
import { loadDynamicComponent, __ } from '@erxes/ui/src/utils';
import { isEnabled } from '@erxes/ui/src/utils/core';
import PrintActionButton from './PrintDocumentBtn';
Expand Down
195 changes: 106 additions & 89 deletions packages/ui-cards/src/comment/components/Comment.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import React from 'react';
import Button from '@erxes/ui/src/components/Button';
import Icon from '@erxes/ui/src/components/Icon';
import Modal from 'react-bootstrap/Modal';
import { __, readFile } from 'coreui/utils';
import { __, readFile, renderFullName } from 'coreui/utils';
import {
SpaceFormsWrapper,
CommentWrapper,
Expand All @@ -11,101 +11,118 @@ import {
CommentContent
} from '@erxes/ui-settings/src/styles';
import { ColorButton } from '../../boards/styles/common';
import { gql, useQuery, useMutation } from '@apollo/client';
import dayjs from 'dayjs';
import { queries, mutations } from '../graphql/';
import { IUser } from '@erxes/ui/src/auth/types';
import { IClientPortalComment, ICommentCreatedUser } from '../types';

function Comment(item) {
const typeId = item.item._id;
const type = item.item.stage.type;
type Props = {
currentUser: IUser;
clientPortalComments: IClientPortalComment[];
remove: (_id: string) => void;
};

const { loading, data = {} as any } = useQuery(
gql(queries.clientPortalComments),
{
variables: { typeId: typeId, type: type },
fetchPolicy: 'network-only',
notifyOnNetworkStatusChange: true
}
);
const [clientPortalCommentsRemove] = useMutation(
gql(mutations.clientPortalCommentsRemove)
);
type State = {
show: boolean;
};

const clientPortalComments = data ? data.clientPortalComments || [] : [];
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
class Comment extends React.Component<Props, State> {
constructor(props) {
super(props);

return (
<>
<ColorButton onClick={handleShow}>
<Icon icon="comment-alt-message" />
{__('Comment')}
</ColorButton>
this.state = {
show: false
};
}

<Modal
centered
show={show}
onHide={handleClose}
backdrop="static"
keyboard={false}
>
<Modal.Header closeButton>
<Modal.Title>{__('Comments')}</Modal.Title>
</Modal.Header>
<Modal.Body>
<SpaceFormsWrapper>
<CommentWrapper>
{clientPortalComments.map(comment => {
const { createdUser = {} } = comment;
render() {
const { currentUser, clientPortalComments = [], remove } = this.props;

return (
<TicketComment key={comment._id}>
<CreatedUser>
<img
src={readFile(
createdUser && createdUser.avatar
? createdUser?.avatar
: '/static/avatar-colored.svg'
const handleClose = () => this.setState({ show: false });
const handleShow = () => this.setState({ show: true });

return (
<>
<ColorButton onClick={() => handleShow()}>
<Icon icon="comment-alt-message" />
{__('Comment')}
</ColorButton>

<Modal
centered={true}
show={this.state.show}
onHide={() => handleClose()}
backdrop="static"
keyboard={false}
>
<Modal.Header closeButton={true}>
<Modal.Title>{__('Comments')}</Modal.Title>
</Modal.Header>
<Modal.Body>
<SpaceFormsWrapper>
<CommentWrapper>
{clientPortalComments.map(comment => {
const { createdUser = {} as ICommentCreatedUser } = comment;

return (
<TicketComment key={comment._id}>
<CreatedUser>
<img
src={readFile(
createdUser && createdUser.avatar
? createdUser.avatar
: '/images/avatar-colored.svg'
)}
alt="profile"
/>
<div>
<CommentContent>
<h5>
{createdUser.fullName
? createdUser.fullName
: renderFullName(createdUser)}
</h5>
<div
className="comment"
dangerouslySetInnerHTML={{
__html: comment.content
}}
/>
</CommentContent>
<span>
Created at{' '}
{dayjs(comment.createdAt).format(
'YYYY-MM-DD HH:mm'
)}
</span>
</div>
{createdUser?._id === currentUser._id && (
<div className="actions">
<span onClick={() => remove(comment._id)}>
Delete
</span>
</div>
)}
alt="profile"
/>
<div>
<CommentContent>
<h5>{`${createdUser?.firstName} ${createdUser?.lastName}`}</h5>
<div
className="comment"
dangerouslySetInnerHTML={{
__html: comment.content
}}
/>
</CommentContent>
<span>
Reported{' '}
{dayjs(comment.createdAt).format('YYYY-MM-DD HH:mm')}
</span>
</div>
<div className="actions"></div>
</CreatedUser>
</TicketComment>
);
})}
</CommentWrapper>
</SpaceFormsWrapper>
<Modal.Footer>
<Button
btnStyle="simple"
size="small"
icon="times-circle"
onClick={handleClose}
>
{__('Cancel')}
</Button>
</Modal.Footer>
</Modal.Body>
</Modal>
</>
);
</CreatedUser>
</TicketComment>
);
})}
</CommentWrapper>
</SpaceFormsWrapper>
<Modal.Footer>
<Button
btnStyle="simple"
size="small"
icon="times-circle"
onClick={() => handleClose()}
>
{__('Cancel')}
</Button>
</Modal.Footer>
</Modal.Body>
</Modal>
</>
);
}
}

export default Comment;