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 21 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
10 changes: 8 additions & 2 deletions client-portal/modules/card/components/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,21 @@ export default class CardDetail extends React.Component<
<CreatedUser>
<img
src={readFile(
createdUser && createdUser.avatar
createdUser &&
createdUser.avatar &&
createdUser?.avatar !== "/images/avatar-colored.svg"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

? createdUser?.avatar
: "/static/avatar-colored.svg"
)}
alt="profile"
/>
<div>
<CommentContent>
<h5>{`${createdUser?.firstName} ${createdUser?.lastName}`}</h5>
<h5>
Anu-Ujin marked this conversation as resolved.
Show resolved Hide resolved
{createdUser
? createdUser.fullName || createdUser.username
: createdUser.email || "Undefined"}
</h5>
<div
className="comment"
dangerouslySetInnerHTML={{ __html: comment.content }}
Expand Down
10 changes: 9 additions & 1 deletion client-portal/modules/card/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ const clientPortalComments = `
clientPortalComments(typeId: $typeId, type: $type) {
_id
content
createdUser
createdUser {
_id
avatar
firstName
fullName
lastName
email
username
}
createdAt
userType
type
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
37 changes: 18 additions & 19 deletions packages/ui-cards/src/comment/components/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@ import {
CommentContent
} from '@erxes/ui-settings/src/styles';
import { ColorButton } from '../../boards/styles/common';
import { gql, useQuery, useMutation } from '@apollo/client';
import { gql, useQuery } from '@apollo/client';
import dayjs from 'dayjs';
import { queries, mutations } from '../graphql/';
import { queries } from '../graphql/';

function Comment(item) {
const typeId = item.item._id;
const type = item.item.stage.type;

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)
);
const { data = {} as any } = useQuery(gql(queries.clientPortalComments), {
variables: { typeId, type },
fetchPolicy: 'network-only',
notifyOnNetworkStatusChange: true
});

const clientPortalComments = data ? data.clientPortalComments || [] : [];
const [show, setShow] = useState(false);
Expand All @@ -44,13 +38,13 @@ function Comment(item) {
</ColorButton>

<Modal
centered
centered={true}
show={show}
onHide={handleClose}
backdrop="static"
keyboard={false}
>
<Modal.Header closeButton>
<Modal.Header closeButton={true}>
<Modal.Title>{__('Comments')}</Modal.Title>
</Modal.Header>
<Modal.Body>
Expand All @@ -65,14 +59,20 @@ function Comment(item) {
<img
src={readFile(
createdUser && createdUser.avatar
? createdUser?.avatar
: '/static/avatar-colored.svg'
? createdUser.avatar
: '/images/avatar-colored.svg'
)}
alt="profile"
/>
<div>
<CommentContent>
<h5>{`${createdUser?.firstName} ${createdUser?.lastName}`}</h5>
<h5>
{createdUser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create function util for these

? createdUser.fullName ||
createdUser.username ||
createdUser.email
: 'Undefined'}
</h5>
<div
className="comment"
dangerouslySetInnerHTML={{
Expand All @@ -85,7 +85,6 @@ function Comment(item) {
{dayjs(comment.createdAt).format('YYYY-MM-DD HH:mm')}
</span>
</div>
<div className="actions"></div>
</CreatedUser>
</TicketComment>
);
Expand Down
22 changes: 15 additions & 7 deletions packages/ui-cards/src/comment/graphql/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
const clientPortalCommentsRemove = `
mutation clientPortalCommentsRemove(
$_id: String!
const clientPortalCommentsAdd = `
mutation clientPortalCommentsAdd(
$typeId: String!
$type: String!
$content: String!
$userType: String!
) {
clientPortalCommentsRemove(
_id: $_id
)
clientPortalCommentsAdd(
typeId: $typeId
type: $type
content: $content
userType: $userType
) {
_id
}
}
`;

export default {
clientPortalCommentsRemove
clientPortalCommentsAdd
};
10 changes: 9 additions & 1 deletion packages/ui-cards/src/comment/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ const clientPortalComments = `
clientPortalComments(typeId: $typeId, type: $type) {
_id
content
createdUser
createdUser {
_id
avatar
firstName
fullName
lastName
email
username
}
createdAt
userType
type
Expand Down
80 changes: 66 additions & 14 deletions packages/ui-internalnotes/src/containers/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@ import React from 'react';
import { graphql } from '@apollo/client/react/hoc';
import Form from '../components/Form';
import { mutations } from '../graphql';
import {
mutations as commentMutations,
queries as commentQueries
} from '@erxes/ui-cards/src/comment/graphql';
import {
InternalNotesAddMutationResponse,
InternalNotesAddMutationVariables
InternalNotesAddMutationVariables,
CommentAddMutationResponse,
CommentAddMutationVariables,
ClientPortalCommentQueryResponse
} from '../types';

type Props = {
contentType: string;
contentTypeId: string;
inputType?: string;
};

type FinalProps = Props & InternalNotesAddMutationResponse;
type FinalProps = {
clientPortalCommentsQueries: ClientPortalCommentQueryResponse;
} & Props &
InternalNotesAddMutationResponse &
CommentAddMutationResponse;

class FormContainer extends React.Component<
FinalProps,
Expand All @@ -28,21 +40,44 @@ class FormContainer extends React.Component<

// create internalNote
create = (variables, callback: () => void) => {
const { contentType, contentTypeId, internalNotesAdd } = this.props;
const {
contentType,
contentTypeId,
internalNotesAdd,
commentAdd,
inputType,
clientPortalCommentsQueries
} = this.props;

this.setState({ isLoading: true });

internalNotesAdd({
variables: {
contentType,
contentTypeId,
...variables
}
}).then(() => {
callback();
if (inputType === 'comment') {
commentAdd({
variables: {
type: contentType.slice(6),
typeId: contentTypeId,
userType: 'team',
...variables
}
}).then(() => {
clientPortalCommentsQueries.refetch();
callback();

this.setState({ isLoading: false });
});
} else {
internalNotesAdd({
variables: {
contentType,
contentTypeId,
...variables
}
}).then(() => {
callback();

this.setState({ isLoading: false });
});
this.setState({ isLoading: false });
});
}
};

render() {
Expand Down Expand Up @@ -71,5 +106,22 @@ export default compose(
refetchQueries: ['activityLogs']
};
}
})
}),
graphql<Props>(gql(commentQueries.clientPortalComments), {
name: 'clientPortalCommentsQueries',
options: ({ contentType, contentTypeId }) => ({
variables: { type: contentType.slice(6), typeId: contentTypeId }
Copy link
Member

@Anu-Ujin Anu-Ujin Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove clientportal related code from internalnote

})
}),
graphql<Props, CommentAddMutationResponse, CommentAddMutationVariables>(
gql(commentMutations.clientPortalCommentsAdd),
{
name: 'commentAdd',
options: () => {
return {
refetchQueries: ['activityLogs']
};
}
}
)
)(FormContainer);