Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:erxes/erxes into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkhtuvshin Narmandakh authored and Enkhtuvshin Narmandakh committed Mar 29, 2023
2 parents 6c32c16 + f4cce7f commit 9dfe3ce
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 38 deletions.
12 changes: 11 additions & 1 deletion packages/core/src/data/resolvers/queries/structures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,17 @@ const structureQueries = {
type: 'department',
params
});
return models.Departments.find(filter).sort({ order: 1 });
const pipeline: any[] = [{ $match: filter }, { $sort: { order: 1 } }];

if (!!params?.ids?.length) {
pipeline.push({
$addFields: {
__order: { $indexOfArray: [params.ids, '$_id'] }
}
});
pipeline.push({ $sort: { __order: 1 } });
}
return models.Departments.aggregate(pipeline);
},

async departmentsMain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ const clientPortalUserMutations = {
args: ILoginParams,
{ models, requestInfo, res }: IContext
) => {
console.log('clientPortalLogin');

const { token } = await models.ClientPortalUsers.login(args);

const cookieOptions: any = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ export const loadClientPortalUserClass = (models: IModels) => {
throw new Error('Invalid login');
}

console.log({ login, password, clientPortalId });

const user = await models.ClientPortalUsers.findOne({
$or: [
{ email: { $regex: new RegExp(`^${login}$`, 'i') } },
Expand All @@ -733,6 +735,8 @@ export const loadClientPortalUserClass = (models: IModels) => {
clientPortalId
});

console.log('user passed');

if (!user || !user.password) {
throw new Error('Invalid login');
}
Expand All @@ -741,8 +745,12 @@ export const loadClientPortalUserClass = (models: IModels) => {
throw new Error('User is not verified');
}

console.log('config started');

const cp = await models.ClientPortals.getConfig(clientPortalId);

console.log('config passed');

if (
cp.manualVerificationConfig &&
user.type === 'customer' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class CustomerDetails extends React.Component<Props> {
<MailForm
fromEmail={customer.primaryEmail}
refetchQueries={['activityLogsCustomer']}
source={isEnabled('imap') ? 'inbox' : undefined}
closeModal={props.closeModal}
/>
</MailBox>
Expand Down Expand Up @@ -121,7 +122,7 @@ class CustomerDetails extends React.Component<Props> {
contentType="contacts:customer"
extraTabs={[
{ name: 'inbox:conversation', label: 'Conversation' },
{ name: 'email', label: 'Email' },
{ name: 'imap:email', label: 'Email' },
{ name: 'cards:task', label: 'Task' },
// { name: 'sms', label: 'SMS' },
{ name: 'engages:campaign', label: 'Campaign' }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alert, __, confirm } from '@erxes/ui/src/utils';
import { Box, MailBox, States } from '../../styles';
import { Box, States } from '../../styles';

import { Actions } from '@erxes/ui/src/styles/main';
import Button from '@erxes/ui/src/components/Button';
Expand All @@ -13,7 +13,6 @@ import DropdownToggle from '@erxes/ui/src/components/DropdownToggle';
import { ICompany } from '@erxes/ui-contacts/src/companies/types';
import { ICustomer } from '../../types';
import Icon from '@erxes/ui/src/components/Icon';
import MailForm from '@erxes/ui-inbox/src/settings/integrations/containers/mail/MailForm';
import ModalTrigger from '@erxes/ui/src/components/ModalTrigger';
import React from 'react';
import SmsForm from '@erxes/ui-inbox/src/settings/integrations/containers/telnyx/SmsForm';
Expand Down Expand Up @@ -42,44 +41,10 @@ class ActionSection extends React.Component<Props, { customerState: string }> {
const { coc, cocType } = this.props;
const { primaryPhone, primaryEmail } = coc;

const content = props => (
<MailBox>
<MailForm
fromEmail={primaryEmail}
customerId={cocType === 'customer' ? coc._id : undefined}
refetchQueries={
cocType === 'customer'
? ['activityLogsCustomer']
: ['activityLogsCompany']
}
closeModal={props.closeModal}
/>
</MailBox>
);

const smsForm = props => <SmsForm {...props} primaryPhone={primaryPhone} />;

return (
<>
<ModalTrigger
dialogClassName="middle"
title="Email"
trigger={
<Button
disabled={primaryEmail ? false : true}
size="small"
btnStyle={primaryEmail ? 'primary' : 'simple'}
>
<Tip text="Send e-mail" placement="top-end">
<Icon icon="envelope" />
</Tip>
</Button>
}
size="lg"
content={content}
paddingContent="less-padding"
enforceFocus={false}
/>
<ModalTrigger
dialogClassName="middle"
title={`Send SMS to (${primaryPhone})`}
Expand Down

0 comments on commit 9dfe3ce

Please sign in to comment.