From 368e75c10ae53d19984d0640626dbf239a0681a8 Mon Sep 17 00:00:00 2001 From: enkhtuvshinD <87625210+enkhtuvshinD@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:17:57 +0800 Subject: [PATCH] fix(meetings): bug fixes after test cases (#364) --- .../src/models/Meetings.ts | 3 +- .../src/components/List.tsx | 76 +++++----------- .../src/components/myCalendar/SideBar.tsx | 2 +- .../components/myCalendar/meeting/Detail.tsx | 31 +++++++ .../components/myCalendar/meeting/Form.tsx | 14 +-- .../src/components/myMeetings/MyMeetings.tsx | 87 +++++++++++++++++++ .../src/components/myMeetings/Row.tsx | 6 +- .../src/containers/myMeetings/List.tsx | 4 +- .../plugin-meetings-ui/src/graphql/queries.ts | 2 + packages/plugin-meetings-ui/src/routes.tsx | 30 ++++++- 10 files changed, 186 insertions(+), 69 deletions(-) create mode 100644 packages/plugin-meetings-ui/src/components/myMeetings/MyMeetings.tsx diff --git a/packages/plugin-meetings-api/src/models/Meetings.ts b/packages/plugin-meetings-api/src/models/Meetings.ts index 56370e0147..b704db50e3 100644 --- a/packages/plugin-meetings-api/src/models/Meetings.ts +++ b/packages/plugin-meetings-api/src/models/Meetings.ts @@ -53,8 +53,7 @@ export const loadMeetingClass = (model: IModels) => { } const result = await model.Meetings.findOne({ _id: doc._id, - createdBy: user._id, - status: { $ne: 'completed' } + createdBy: user._id }); if (result) { await model.Meetings.updateOne( diff --git a/packages/plugin-meetings-ui/src/components/List.tsx b/packages/plugin-meetings-ui/src/components/List.tsx index 9fbf196f48..25bc522db2 100755 --- a/packages/plugin-meetings-ui/src/components/List.tsx +++ b/packages/plugin-meetings-ui/src/components/List.tsx @@ -2,7 +2,6 @@ import Button from '@erxes/ui/src/components/Button'; import { __, router } from '@erxes/ui/src/utils'; import React, { useEffect, useState } from 'react'; import MeetingFormContainer from '../containers/myCalendar/meeting/Form'; -import MyMeetingListContainer from '../containers/myMeetings/List'; import { Title } from '@erxes/ui-settings/src/styles'; import ModalTrigger from '@erxes/ui/src/components/ModalTrigger'; import Wrapper from '@erxes/ui/src/layout/components/Wrapper'; @@ -11,10 +10,9 @@ import DataWithLoader from '@erxes/ui/src/components/DataWithLoader'; import { menuMeeting } from '../contants'; import { MyCalendarList } from './myCalendar/MyCalendar'; import SideBar from '../containers/myCalendar/SideBar'; -import SideBarContainer from '../containers/myMeetings/SideBar'; import { IUser } from '@erxes/ui/src/auth/types'; -import { FormControl } from '@erxes/ui/src/components'; import { MeetingsQueryResponse } from '../types'; +import MyMeetings from './myMeetings/MyMeetings'; type Props = { meetings: any; @@ -36,28 +34,17 @@ function List(props: Props) { currentUser, meetingQuery } = props; - const { meetingId, searchValue } = queryParams; + const { meetingId } = queryParams; const [component, setComponent] = useState(
); const [leftSideBar, setLeftSideBar] = useState(
); - const [searchText, setSearchValue] = useState(searchValue); - const routePath = location.pathname.split('/').slice(-1)[0]; useEffect(() => { switch (routePath) { case 'myMeetings': - setComponent( - - ); - setLeftSideBar( - - ); + ; break; default: setComponent( @@ -102,48 +89,27 @@ function List(props: Props) { /> ); - const searchHandler = e => { - const searchValue = e.target.value; - - setSearchValue(searchValue); - - setTimeout(() => { - router.removeParams(history, 'page'); - router.setParams(history, { searchValue }); - }, 500); - }; const backToCalendar = () => { router.removeParams(history, 'meetingId'); }; - const actionBarRight = - routePath === 'myCalendar' ? ( - meetingId ? ( - - ) : ( - - ) - ) : ( - - ); + const actionBarRight = meetingId ? ( + + ) : ( + + ); const title = !meetingId && ( {__('My Calendar')} diff --git a/packages/plugin-meetings-ui/src/components/myCalendar/SideBar.tsx b/packages/plugin-meetings-ui/src/components/myCalendar/SideBar.tsx index e235f149ac..fbab2eaa12 100644 --- a/packages/plugin-meetings-ui/src/components/myCalendar/SideBar.tsx +++ b/packages/plugin-meetings-ui/src/components/myCalendar/SideBar.tsx @@ -226,7 +226,7 @@ export const SideBar = (props: Props) => { )} {tommorowMeetings(filteredMeeting)?.length > 0 && ( - + {tommorowMeetings(filteredMeeting)?.map(meeting => { return ListItem(meeting); diff --git a/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Detail.tsx b/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Detail.tsx index 0b96c0adb1..0515fe2315 100644 --- a/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Detail.tsx +++ b/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Detail.tsx @@ -15,9 +15,13 @@ import { import { IMeeting, ITopic } from '../../../types'; import { TopicFormContainer } from '../../../containers/myCalendar/topic/Form'; +import Form from '../../../containers/myCalendar/meeting/Form'; + import Button from '@erxes/ui/src/components/Button'; import { Link } from 'react-router-dom'; import { DrawerDetail } from '@erxes/ui-automations/src/styles'; +import queries from '../../../graphql/queries'; +import { gql } from '@apollo/client'; type Props = { meetingDetail: IMeeting; @@ -88,6 +92,25 @@ export const MeetingDetail = (props: Props) => { /> ); + const editTrigger = ( + + ); + + const editModalContent = props => ( +
+ ); + const renderTabContent = () => { return ( <> @@ -195,6 +218,14 @@ export const MeetingDetail = (props: Props) => { ? 'Start meeting' : 'End meeting'} + + )} diff --git a/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Form.tsx b/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Form.tsx index d068cfd1f8..d5b67c3d89 100644 --- a/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Form.tsx +++ b/packages/plugin-meetings-ui/src/components/myCalendar/meeting/Form.tsx @@ -5,7 +5,7 @@ import Button from '@erxes/ui/src/components/Button'; import { ModalFooter } from '@erxes/ui/src/styles/main'; import ControlLabel from '@erxes/ui/src/components/form/Label'; import { IButtonMutateProps, IFormProps, IOption } from '@erxes/ui/src/types'; -import { __ } from '@erxes/ui/src/utils'; +import { __, Alert } from '@erxes/ui/src/utils'; import React, { useEffect, useState } from 'react'; import { ICommonFormProps } from '@erxes/ui-settings/src/common/types'; import { IMeeting } from '../../../types'; @@ -44,7 +44,7 @@ export const MeetingForm = (props: Props) => { let dealInitialId = dealId ? [dealId] : ''; const [userIds, setUserIds] = useState([props.currentUser._id] || []); - const [companyId, setCompanyId] = useState(''); + const [companyId, setCompanyId] = useState(meeting?.companyId || ''); const [title, setTitle] = useState(''); const [selectedMethod, setSelectedMethod] = useState(''); const [dealIds, setDealIds] = useState(dealInitialId); @@ -53,7 +53,7 @@ export const MeetingForm = (props: Props) => { calendarDate?.startDate || new Date() ); const [endDate, setEndDate] = useState( - calendarDate?.endDate || new Date() + calendarDate?.endDate || '' ); useEffect(() => { @@ -112,7 +112,9 @@ export const MeetingForm = (props: Props) => { }; const onEndDateChange = dateVal => { - setEndDate(dateVal); + if (new Date() < dateVal) { + setEndDate(dateVal); + } else Alert.warning('Please choose the correct date'); }; const renderDatePicker = () => { @@ -160,7 +162,6 @@ export const MeetingForm = (props: Props) => { const { closeModal, renderButton } = props; const { values, isSubmitted } = formProps; const object = meeting || ({} as IMeeting); - let dealOptions = (deals && deals.map((deal: any) => ({ @@ -182,6 +183,7 @@ export const MeetingForm = (props: Props) => { name="companyId" onSelect={onCompanySelect} multi={false} + initialValue={companyId} /> @@ -263,7 +265,7 @@ export const MeetingForm = (props: Props) => { {renderButton({ - passedName: 'meetings', + passedName: 'meeting', values: generateDoc(values), isSubmitted, callback: closeModal, diff --git a/packages/plugin-meetings-ui/src/components/myMeetings/MyMeetings.tsx b/packages/plugin-meetings-ui/src/components/myMeetings/MyMeetings.tsx new file mode 100644 index 0000000000..7b4cb9c9ca --- /dev/null +++ b/packages/plugin-meetings-ui/src/components/myMeetings/MyMeetings.tsx @@ -0,0 +1,87 @@ +import { __, router } from '@erxes/ui/src/utils'; +import React, { useState } from 'react'; + +import Wrapper from '@erxes/ui/src/layout/components/Wrapper'; +import DataWithLoader from '@erxes/ui/src/components/DataWithLoader'; + +import SideBarContainer from '../myMeetings/SideBar'; +import { IUser } from '@erxes/ui/src/auth/types'; +import { FormControl } from '@erxes/ui/src/components'; +import { MeetingsQueryResponse } from '../../types'; +import MyMeetingListContainer from '../../containers/myMeetings/List'; +import { menuMeeting } from '../../contants'; + +type Props = { + meetings: any; + loading: boolean; + queryParams: any; + route?: string; + history: string; + refetchQueries?: any; + currentUser: IUser; + meetingQuery?: MeetingsQueryResponse; +}; + +function MyMeetings(props: Props) { + const { loading, queryParams, history, currentUser } = props; + const { searchValue } = queryParams; + const [searchText, setSearchValue] = useState(searchValue); + + const searchHandler = e => { + const searchValue = e.target.value; + + setSearchValue(searchValue); + + setTimeout(() => { + router.removeParams(history, 'page'); + router.setParams(history, { searchValue }); + }, 500); + }; + + const leftSideBar = ( + + ); + + const actionBarRight = ( + + ); + + const actionBar = ; + return ( + + } + actionBar={actionBar} + content={ + + } + loading={loading} + count={1} + emptyText={__('Theres no meetings')} + emptyImage="/images/actions/8.svg" + /> + } + leftSidebar={leftSideBar} + transparent={true} + hasBorder + /> + ); +} + +export default MyMeetings; diff --git a/packages/plugin-meetings-ui/src/components/myMeetings/Row.tsx b/packages/plugin-meetings-ui/src/components/myMeetings/Row.tsx index 66a263ac40..d4620e1d96 100644 --- a/packages/plugin-meetings-ui/src/components/myMeetings/Row.tsx +++ b/packages/plugin-meetings-ui/src/components/myMeetings/Row.tsx @@ -31,7 +31,9 @@ export const Row = (props: Props) => { ); }; - const content = props => ; + const content = props => ( + + ); const onTrClick = () => { history.push(`/meetings/myCalendar?meetingId=${meeting._id}`); @@ -58,7 +60,7 @@ export const Row = (props: Props) => { diff --git a/packages/plugin-meetings-ui/src/containers/myMeetings/List.tsx b/packages/plugin-meetings-ui/src/containers/myMeetings/List.tsx index 32460fc913..61024f406b 100644 --- a/packages/plugin-meetings-ui/src/containers/myMeetings/List.tsx +++ b/packages/plugin-meetings-ui/src/containers/myMeetings/List.tsx @@ -34,6 +34,7 @@ const MyMeetingListContainer = (props: FinalProps) => { companyId, searchValue } = queryParams; + const { data, loading } = useQuery(gql(queries.meetings), { variables: { perPage: parseInt(perPage?.toString()) || 10, @@ -44,8 +45,7 @@ const MyMeetingListContainer = (props: FinalProps) => { userId: ownerId, companyId, searchValue - }, - fetchPolicy: 'no-cache' + } }); const { data: countData, loading: countLoading } = useQuery( diff --git a/packages/plugin-meetings-ui/src/graphql/queries.ts b/packages/plugin-meetings-ui/src/graphql/queries.ts index ff0eee3e99..e319f12b82 100644 --- a/packages/plugin-meetings-ui/src/graphql/queries.ts +++ b/packages/plugin-meetings-ui/src/graphql/queries.ts @@ -80,6 +80,8 @@ query MeetingDetail($_id: String!) { createdAt status companyId + participantIds + dealIds deals{ _id boardId diff --git a/packages/plugin-meetings-ui/src/routes.tsx b/packages/plugin-meetings-ui/src/routes.tsx index 30ad8058cf..135180f8f9 100755 --- a/packages/plugin-meetings-ui/src/routes.tsx +++ b/packages/plugin-meetings-ui/src/routes.tsx @@ -7,6 +7,12 @@ const List = asyncComponent(() => import(/* webpackChunkName: "List - Meetings" */ './containers/List') ); +const MyMeetings = asyncComponent(() => + import( + /* webpackChunkName: "List - Meetings" */ './components/myMeetings/MyMeetings' + ) +); + const meetings = ({ location, history }) => { const queryParams = queryString.parse(location.search); const { meetingId } = queryParams; @@ -22,8 +28,30 @@ const meetings = ({ location, history }) => { ); }; +const myMeetings = ({ location, history }) => { + const queryParams = queryString.parse(location.search); + const routePath = location.pathname.split('/').slice(-1)[0]; + + return ( + + ); +}; + const routes = () => { - return meetings({ ...props })} />; + return ( + <> + meetings({ ...props })} + exact + /> + myMeetings({ ...props })} + exact + /> + + ); }; export default routes;