From d21d781aa40816a7fca566e5b7d7a6bb782de5bd Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:40:59 +0500 Subject: [PATCH 01/44] del memo (already a separate component) --- apps/schools/domains/common/components/bubbleFilter/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/common/components/bubbleFilter/index.tsx b/apps/schools/domains/common/components/bubbleFilter/index.tsx index 840641e1..45a3e1ac 100644 --- a/apps/schools/domains/common/components/bubbleFilter/index.tsx +++ b/apps/schools/domains/common/components/bubbleFilter/index.tsx @@ -4,7 +4,7 @@ import styles from './styles/styles.module.scss' import { BubbleFilterProps, BubbleFilterListItem } from '@domains/common/components/bubbleFilter/interface' import { CloseOutlined } from '@ant-design/icons' -export const BubbleFilter: React.FC = React.memo(({ text, items }) => { +export const BubbleFilter: React.FC = ({ text, items }) => { const listItems = items.map((item: BubbleFilterListItem) => item.count && item.count > 0 ? ( = React.memo(({ text, ite {listItems} ) -}) +} From 69427c9668b4b6d30ec3325af4c3225bcbef6570 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:51:01 +0500 Subject: [PATCH 02/44] change logic in bubbleFilter for memo --- .../common/components/bubbleFilter/index.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/schools/domains/common/components/bubbleFilter/index.tsx b/apps/schools/domains/common/components/bubbleFilter/index.tsx index 45a3e1ac..4a4cd70c 100644 --- a/apps/schools/domains/common/components/bubbleFilter/index.tsx +++ b/apps/schools/domains/common/components/bubbleFilter/index.tsx @@ -1,10 +1,23 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import { Row, Typography } from 'antd' import styles from './styles/styles.module.scss' import { BubbleFilterProps, BubbleFilterListItem } from '@domains/common/components/bubbleFilter/interface' import { CloseOutlined } from '@ant-design/icons' -export const BubbleFilter: React.FC = ({ text, items }) => { +export const BubbleFilter: React.FC = React.memo(({ text, items }) => { + const [selectedStatuses, setSelectedStatuses] = useState([]) + + useEffect(() => { + const storedStatuses = localStorage.getItem('selectedStatuses') + if (storedStatuses) { + setSelectedStatuses(JSON.parse(storedStatuses)) + } + }, []) + + useEffect(() => { + localStorage.setItem('selectedStatuses', JSON.stringify(selectedStatuses)) + }, [selectedStatuses]) + const listItems = items.map((item: BubbleFilterListItem) => item.count && item.count > 0 ? ( = ({ text, items }) => { {listItems} ) -} +}) From 4b60ecd56ccdc68d028bf7864d8fc01cc5d5f2cf Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Mon, 1 Jul 2024 11:55:59 +0500 Subject: [PATCH 03/44] del memo --- .../common/components/bubbleFilter/index.tsx | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/apps/schools/domains/common/components/bubbleFilter/index.tsx b/apps/schools/domains/common/components/bubbleFilter/index.tsx index 4a4cd70c..3a3b89af 100644 --- a/apps/schools/domains/common/components/bubbleFilter/index.tsx +++ b/apps/schools/domains/common/components/bubbleFilter/index.tsx @@ -4,20 +4,7 @@ import styles from './styles/styles.module.scss' import { BubbleFilterProps, BubbleFilterListItem } from '@domains/common/components/bubbleFilter/interface' import { CloseOutlined } from '@ant-design/icons' -export const BubbleFilter: React.FC = React.memo(({ text, items }) => { - const [selectedStatuses, setSelectedStatuses] = useState([]) - - useEffect(() => { - const storedStatuses = localStorage.getItem('selectedStatuses') - if (storedStatuses) { - setSelectedStatuses(JSON.parse(storedStatuses)) - } - }, []) - - useEffect(() => { - localStorage.setItem('selectedStatuses', JSON.stringify(selectedStatuses)) - }, [selectedStatuses]) - +export const BubbleFilter: React.FC = ({ text, items }) => { const listItems = items.map((item: BubbleFilterListItem) => item.count && item.count > 0 ? ( = React.memo(({ text, ite {listItems} ) -}) +} From 8b76201bdaab91e03e742527df326479576fb3f4 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:06:36 +0500 Subject: [PATCH 04/44] way to save memo and don't use useEffect --- .../common/components/bubbleFilter/index.tsx | 17 +++++++++-------- .../common/components/bubbleFilter/interface.ts | 1 + .../query/components/queryList/index.tsx | 6 +++++- .../ticket/components/ticketList/index.tsx | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/apps/schools/domains/common/components/bubbleFilter/index.tsx b/apps/schools/domains/common/components/bubbleFilter/index.tsx index 3a3b89af..b4d6f2d5 100644 --- a/apps/schools/domains/common/components/bubbleFilter/index.tsx +++ b/apps/schools/domains/common/components/bubbleFilter/index.tsx @@ -4,12 +4,13 @@ import styles from './styles/styles.module.scss' import { BubbleFilterProps, BubbleFilterListItem } from '@domains/common/components/bubbleFilter/interface' import { CloseOutlined } from '@ant-design/icons' -export const BubbleFilter: React.FC = ({ text, items }) => { - const listItems = items.map((item: BubbleFilterListItem) => - item.count && item.count > 0 ? ( +export const BubbleFilter: React.FC = React.memo(({ text, items, statuses }) => { + const listItems = items.map((item: BubbleFilterListItem) => { + const isSelected = statuses?.includes(item.key) ?? false + return item.count && item.count > 0 ? ( {} : item.onClick} + className={isSelected ? styles.bubbleContainerSelected : styles.bubbleContainer} + onClick={isSelected ? () => {} : item.onClick} style={{ backgroundColor: item.isSelected ? item.color : '' }} key={item.key} > @@ -21,8 +22,8 @@ export const BubbleFilter: React.FC = ({ text, items }) => {
{item.text}
{item.isSelected && }
- ) : null, - ) + ) : null + }) return ( @@ -30,4 +31,4 @@ export const BubbleFilter: React.FC = ({ text, items }) => { {listItems} ) -} +}) diff --git a/apps/schools/domains/common/components/bubbleFilter/interface.ts b/apps/schools/domains/common/components/bubbleFilter/interface.ts index 8f348b3c..c6f83405 100644 --- a/apps/schools/domains/common/components/bubbleFilter/interface.ts +++ b/apps/schools/domains/common/components/bubbleFilter/interface.ts @@ -11,4 +11,5 @@ export interface BubbleFilterListItem { export interface BubbleFilterProps { items: BubbleFilterListItem[] text?: string + statuses?: string[] | null } diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index e140c8b8..e8153aff 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -113,7 +113,11 @@ export function QueryList() { Заявки - + loading={isTableLoading} customType={'tableWithoutSearch'} diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 7245b37a..c8fbfc49 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -128,7 +128,7 @@ export function TicketList() { Обращения - +
loading={isTableLoading} From 88c17471465cf48f701782e63ae0de9c85d219d6 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:07:53 +0500 Subject: [PATCH 05/44] del --- apps/schools/domains/common/components/bubbleFilter/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/common/components/bubbleFilter/index.tsx b/apps/schools/domains/common/components/bubbleFilter/index.tsx index b4d6f2d5..a25c9beb 100644 --- a/apps/schools/domains/common/components/bubbleFilter/index.tsx +++ b/apps/schools/domains/common/components/bubbleFilter/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react' +import React from 'react' import { Row, Typography } from 'antd' import styles from './styles/styles.module.scss' import { BubbleFilterProps, BubbleFilterListItem } from '@domains/common/components/bubbleFilter/interface' From 0e30f8610359212d22bb541f2ca1938a61bc5ec4 Mon Sep 17 00:00:00 2001 From: nenichv Date: Mon, 1 Jul 2024 14:33:20 +0500 Subject: [PATCH 06/44] delete tooltips, add width tooltips, fix margin btn, add cursor pointer in row table --- .../components/changeCircleForm/index.tsx | 28 ++- .../styles/styles.module.scss | 1 + .../circle/components/circleList/index.tsx | 2 +- .../circleList/styles/styles.module.scss | 6 +- .../components/createCircleForm/index.tsx | 38 +--- .../styles/styles.module.scss | 4 +- .../components/createEmployeeForm/index.tsx | 80 ++++---- .../styles/styles.module.scss | 1 + .../components/createStudentForm/index.tsx | 194 ++++++++---------- .../styles/styles.module.scss | 2 +- 10 files changed, 147 insertions(+), 209 deletions(-) diff --git a/apps/schools/domains/circle/components/changeCircleForm/index.tsx b/apps/schools/domains/circle/components/changeCircleForm/index.tsx index f67c7333..8ad76a1a 100644 --- a/apps/schools/domains/circle/components/changeCircleForm/index.tsx +++ b/apps/schools/domains/circle/components/changeCircleForm/index.tsx @@ -6,8 +6,6 @@ import { Button } from '@domains/common/components/button' import { useChangeCircleFormValidators } from './hooks' import { useGetAllCirclesQuery } from '@domains/organization/redux/organizationApi' import { useOrganization } from '@domains/organization/providers/organizationProvider' -import { WithTooltip } from '@domains/common/components/tooltip/withTooltip' -import { TOOLTIP_MARGIN } from './styles/styles' import { isValidFormCheck } from '@domains/common/utils/form' import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from './constants' import classnames from 'classnames' @@ -80,22 +78,20 @@ export const ChangeCircleForm = () => { layout='vertical' > Редактирование кружка - - + * Название - } - name={CIRCLE_NAME} - className={styles.label} - rules={validators.name} - initialValue={initialValues[CIRCLE_NAME]} - > - - - + } + name={CIRCLE_NAME} + className={styles.label} + rules={validators.name} + initialValue={initialValues[CIRCLE_NAME]} + > + + {!circlesData.isLoading ? ( diff --git a/apps/schools/domains/circle/components/changeCircleForm/styles/styles.module.scss b/apps/schools/domains/circle/components/changeCircleForm/styles/styles.module.scss index 197ea315..42252514 100644 --- a/apps/schools/domains/circle/components/changeCircleForm/styles/styles.module.scss +++ b/apps/schools/domains/circle/components/changeCircleForm/styles/styles.module.scss @@ -20,6 +20,7 @@ font-style: normal; font-weight: 400; line-height: 22px; + width: 95%; :global { .ant-select-selector { diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index d9a1c062..9c23ba0d 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -10,7 +10,6 @@ import { RowType, TableType } from './interfaces' import { searchStudentsColumns } from './constants' import { useGetAllCirclesQuery } from '@domains/organization/redux/organizationApi' import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' -import { mapReturnedData } from '@domains/common/redux/utils' import { HighlightText } from '@domains/common/components/table/forming' import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' @@ -97,6 +96,7 @@ export function CircleList() { customWidths={[60, 25, 15]} searchRequestText={searchRequestText} setSearchRequestText={setSearchRequestText} + rowClassName={styles.tableRowPointer} /> ) diff --git a/apps/schools/domains/circle/components/circleList/styles/styles.module.scss b/apps/schools/domains/circle/components/circleList/styles/styles.module.scss index 20a5f9b5..c0d78172 100644 --- a/apps/schools/domains/circle/components/circleList/styles/styles.module.scss +++ b/apps/schools/domains/circle/components/circleList/styles/styles.module.scss @@ -59,4 +59,8 @@ font-style: normal; font-weight: 400; line-height: 22px; -} \ No newline at end of file +} + +.tableRowPointer:hover { + cursor: pointer; +} diff --git a/apps/schools/domains/circle/components/createCircleForm/index.tsx b/apps/schools/domains/circle/components/createCircleForm/index.tsx index 3d5636a6..a06e375d 100644 --- a/apps/schools/domains/circle/components/createCircleForm/index.tsx +++ b/apps/schools/domains/circle/components/createCircleForm/index.tsx @@ -1,4 +1,4 @@ -import { Form, Typography, Input as AntdInput, Row, Spin, Tooltip } from 'antd' +import { Form, Typography, Input as AntdInput, Row, Spin } from 'antd' import React, { useEffect, useState } from 'react' import { Input } from '@domains/common/components/input' import styles from './styles/styles.module.scss' @@ -6,12 +6,10 @@ import { Button } from '@domains/common/components/button' import { useCreateCircleFormValidators } from './hooks' import { useGetAllCirclesQuery } from '@domains/organization/redux/organizationApi' import { useOrganization } from '@domains/organization/providers/organizationProvider' -import { WithTooltip } from '@domains/common/components/tooltip/withTooltip' -import { TOOLTIP_MARGIN } from './styles/styles' import { isValidFormCheck } from '@domains/common/utils/form' import { CIRCLE_NAME, CIRCLE_ADDRESS, ADDRESS_ROOM } from './constants' import classnames from 'classnames' -import { AimOutlined, QuestionCircleFilled } from '@ant-design/icons' +import { AimOutlined } from '@ant-design/icons' import { Select } from '@domains/common/components/select' import { useCreateCircleMutation } from '../../redux/circleApi' import { getVarsForAddressColumn } from '@domains/common/utils/geo' @@ -21,14 +19,6 @@ import { mapSteps } from '@domains/circle/interfaces/mapStepsType' import { FormMapSteps } from '@domains/circle/constants/Enums' import Image from 'next/image' import android from '@public/image/Android 11.png' -import { - DEFAULT_ICON_SIZE, - DEFAULT_MARGIN, - DEFAULT_OVERLAY_INNER_COLOR, - DEFAULT_OVERLAY_INNER_STYLE, - ICON_SIZES, -} from '@domains/common/components/tooltip/styles/styles' -import { BackPage } from '@domains/common/components/backPage' export const CreateCircleForm = () => { const validators = useCreateCircleFormValidators() @@ -93,28 +83,10 @@ export const CreateCircleForm = () => { > -
- - - -
- + />
diff --git a/apps/schools/domains/circle/components/createCircleForm/styles/styles.module.scss b/apps/schools/domains/circle/components/createCircleForm/styles/styles.module.scss index 4ff4c485..c79c9600 100644 --- a/apps/schools/domains/circle/components/createCircleForm/styles/styles.module.scss +++ b/apps/schools/domains/circle/components/createCircleForm/styles/styles.module.scss @@ -30,13 +30,13 @@ width: 3%; } - .inputWithTooltipContainer { + .inputContainer { display: flex; flex-direction: row; justify-content: unset; } - .inputWithTooltip { + .input { width: 70%; margin-right: 5px; display: flex; diff --git a/apps/schools/domains/employee/components/createEmployeeForm/index.tsx b/apps/schools/domains/employee/components/createEmployeeForm/index.tsx index 01834f6a..1660b138 100644 --- a/apps/schools/domains/employee/components/createEmployeeForm/index.tsx +++ b/apps/schools/domains/employee/components/createEmployeeForm/index.tsx @@ -7,9 +7,7 @@ import { useCreateEmployeeFormValidators } from './hooks' import { useInviteEmployeeMutation } from '@domains/organization/redux/organizationApi' import { useOrganization } from '@domains/organization/providers/organizationProvider' import { handleSubmitForm } from '@domains/employee/handlers/employeeCreate' -import router, { useRouter } from 'next/router' -import { WithTooltip } from '@domains/common/components/tooltip/withTooltip' -import { TOOLTIP_MARGIN } from '@domains/employee/components/createEmployeeForm/styles/styles' +import { useRouter } from 'next/router' import { isValidFormCheck } from '@domains/common/utils/form' import { EMPLOYEE_EMAIL, @@ -45,55 +43,47 @@ export const CreateEmployeeForm = () => { }} layout='vertical' > - Добавление Сотрудника - - + Добавление сотрудника + * Телефон сотрудника - } - name={EMPLOYEE_PHONE} - className={styles.label} - rules={validators.phone} - > - - - + } + name={EMPLOYEE_PHONE} + className={styles.label} + rules={validators.phone} + > + + - - + * Ф. И. О. сотрудника - } - name={EMPLOYEE_NAME} - className={styles.label} - rules={validators.name} - > - - - + } + name={EMPLOYEE_NAME} + className={styles.label} + rules={validators.name} + > + + - - - - - + + + - - - - - + + + + + )} + options={circlesData?.data?.results.map((x) => { + return { + value: x.id, + label: x.name, + } + })} + /> + + diff --git a/apps/schools/domains/user/components/profile/profileInfo/styles/styles.module.scss b/apps/schools/domains/user/components/profile/profileInfo/styles/styles.module.scss index 4aa3a70c..972ae767 100644 --- a/apps/schools/domains/user/components/profile/profileInfo/styles/styles.module.scss +++ b/apps/schools/domains/user/components/profile/profileInfo/styles/styles.module.scss @@ -17,3 +17,11 @@ } } } + +.editButton { + margin-top: 30px; +} + +.organizationContainer { + margin-top: 60px; +} From 9c07a19a633dd0814dd1fe2a6391259b092143af Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 4 Jul 2024 12:40:39 +0500 Subject: [PATCH 10/44] add * in fields --- .../components/profile/profileEdit/index.tsx | 16 ++++++++++++---- .../profileEdit/styles/styles.module.scss | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/schools/domains/user/components/profile/profileEdit/index.tsx b/apps/schools/domains/user/components/profile/profileEdit/index.tsx index cb43fee5..bfb1756e 100644 --- a/apps/schools/domains/user/components/profile/profileEdit/index.tsx +++ b/apps/schools/domains/user/components/profile/profileEdit/index.tsx @@ -61,9 +61,13 @@ export function ProfileEdit() { > + * Ф.И.О. + + } name={USER_NAME} - rules={[...validators[USER_NAME], { required: true, message: '' }]} + rules={validators[USER_NAME]} className={styles.label} initialValue={initialValues[USER_NAME]} > @@ -72,9 +76,13 @@ export function ProfileEdit() { + * Email сотрудника + + } name={USER_EMAIL} - rules={[...validators[USER_EMAIL], { required: true, message: '' }]} + rules={validators[USER_EMAIL]} className={styles.label} initialValue={initialValues[USER_EMAIL]} > diff --git a/apps/schools/domains/user/components/profile/profileEdit/styles/styles.module.scss b/apps/schools/domains/user/components/profile/profileEdit/styles/styles.module.scss index a87ccef5..1a78fbe0 100644 --- a/apps/schools/domains/user/components/profile/profileEdit/styles/styles.module.scss +++ b/apps/schools/domains/user/components/profile/profileEdit/styles/styles.module.scss @@ -1,3 +1,5 @@ +@import '../../../../../common/components/styles/abstracts/colors'; + .baseRowContainer { padding-bottom: 50px; @@ -19,3 +21,7 @@ } } } + +.requiredMark{ + color: $color-required-mark; +} From 6451235b247aa3d8a446f5c999841ff3bcd990a6 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:15:44 +0500 Subject: [PATCH 11/44] merge students and invites --- .../student/components/studentList/index.tsx | 127 +++++++++++++----- 1 file changed, 92 insertions(+), 35 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 48c023ec..37819c80 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -16,14 +16,15 @@ import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@dom import { scrollToTop } from '@domains/common/utils/scrollInDirection' export function StudentList() { - const [invitesPaginationParams, setInvitesPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }) - - const [studentsPaginationParams, setStudentsPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, + const [queryPaginationParams, setQueryPaginationParams] = useState({ + invites: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, + students: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, }) const [searchRequestText, setSearchRequestText] = useState('') @@ -33,23 +34,25 @@ export function StudentList() { circle__organization__id: organizationId, status: StatusesEnum.SENT, or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), - page: invitesPaginationParams.page, - page_size: invitesPaginationParams.pageSize, + page: queryPaginationParams.invites.page, + page_size: queryPaginationParams.invites.pageSize, }) const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: studentsPaginationParams.page, - page_size: studentsPaginationParams.pageSize, + page: queryPaginationParams.students.page, + page_size: queryPaginationParams.students.pageSize, }) - const data = { - count: (invites?.count ?? 0) + (students?.count ?? 0), - next: invites?.next ?? '', - previous: invites?.previous ?? '', - results: [...(invites?.results ?? []), ...(students?.results ?? [])].map((x) => { - if ('body' in x) { + const [paginationParams, setPaginationParams] = useState({ + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }) + + const resultsCalc = (): RowType[] => { + if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + return (invites?.results ?? []).map((x) => { return { id: x.body.id, student_name: x.body.name, @@ -57,7 +60,32 @@ export function StudentList() { parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), circle_name: x.sender.name, } as RowType - } else { + }) + } else if (paginationParams.page === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + return [...(invites?.results ?? []), ...(students?.results ?? [])] + .slice(0, paginationParams.pageSize) + .map((x) => { + if ('body' in x) { + return { + id: x.body.id, + student_name: x.body.name, + student_phone: x.additional.phone, + parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), + circle_name: x.sender.name, + } as RowType + } else { + return { + id: x.id, + student_name: x.name, + student_phone: x.student_profile.phone, + parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), + circle_name: x.circle.name, + } as RowType + } + }) + } else { + const temp = paginationParams.pageSize - ((invites?.count ?? 0) % paginationParams.pageSize) + return (students?.results ?? []).slice(temp).map((x) => { return { id: x.id, student_name: x.name, @@ -65,25 +93,54 @@ export function StudentList() { parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), circle_name: x.circle.name, } as RowType - } - }), + }) + } } - const [currentPage, setCurrentPage] = useState(defaultPaginationTablePage) - const [currentPageSize, setCurrentPageSize] = useState(defaultPaginationTablePageSize) + const data = { + count: (invites?.count ?? 0) + (students?.count ?? 0), + next: invites?.next ?? '', + previous: invites?.previous ?? '', + results: resultsCalc(), + } const handlePageChange = (newPage: number, newPageSize: number) => { - setCurrentPage(newPage) - setCurrentPageSize(newPageSize) + setPaginationParams({ + page: newPage, + pageSize: newPageSize, + }) - if (newPage <= Math.ceil(invites?.count ?? 0 / defaultPaginationTablePageSize)) { - setInvitesPaginationParams({ page: newPage, pageSize: newPageSize }) + if (newPage < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + setQueryPaginationParams((prevParams) => ({ + ...prevParams, + invites: { + page: newPage, + pageSize: newPageSize, + }, + })) + } else if (newPage === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + setQueryPaginationParams(() => ({ + invites: { + page: newPage, + pageSize: newPageSize, + }, + students: { + page: 1, + pageSize: paginationParams.pageSize - ((invites?.count ?? 0) % newPageSize), + }, + })) } else { - const invitesCount = invites?.count ?? 0 - const studentsPage = - Math.ceil((newPage * defaultPaginationTablePageSize - invitesCount) / defaultPaginationTablePageSize) + - 1 - setStudentsPaginationParams({ page: studentsPage, pageSize: newPageSize }) + const nextPage = Math.abs(newPage - Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) + setQueryPaginationParams(() => ({ + invites: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, + students: { + page: nextPage, + pageSize: paginationParams.pageSize, + }, + })) } scrollToTop() } @@ -119,9 +176,9 @@ export function StudentList() { ['Телефон родителя', 'parent_phone'], ]} pagination={{ - current: currentPage, - pageSize: currentPageSize, - total: data.count, + current: paginationParams.page, + pageSize: paginationParams.pageSize, + total: (invites?.count ?? 0) + (students?.count ?? 0), onChange: (page, pageSize) => { handlePageChange(page, pageSize) }, From 0cd1021a4fe45c4ee1f1343a88b418298b371ca5 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:18:06 +0500 Subject: [PATCH 12/44] change 1 to defaultPaginationTablePage --- apps/schools/domains/student/components/studentList/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 37819c80..7b7917b0 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -125,7 +125,7 @@ export function StudentList() { pageSize: newPageSize, }, students: { - page: 1, + page: defaultPaginationTablePage, pageSize: paginationParams.pageSize - ((invites?.count ?? 0) % newPageSize), }, })) From ee72274b3d558917420745af341c5013b70312cf Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:09:28 +0500 Subject: [PATCH 13/44] change nextPage logic --- .../domains/student/components/studentList/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 7b7917b0..38f2fb22 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' @@ -50,7 +50,7 @@ export function StudentList() { pageSize: defaultPaginationTablePageSize, }) - const resultsCalc = (): RowType[] => { + const resultsCalc = useCallback((): RowType[] => { if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { return (invites?.results ?? []).map((x) => { return { @@ -95,7 +95,7 @@ export function StudentList() { } as RowType }) } - } + }, [queryPaginationParams, paginationParams, invites, students]) const data = { count: (invites?.count ?? 0) + (students?.count ?? 0), @@ -138,7 +138,7 @@ export function StudentList() { }, students: { page: nextPage, - pageSize: paginationParams.pageSize, + pageSize: 2 * paginationParams.pageSize - ((invites?.count ?? 0) % newPageSize), }, })) } From f427a3b32268ff26ff86e8dff47bf0a2ca4dd08a Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:15:28 +0500 Subject: [PATCH 14/44] small fix --- .../domains/student/components/studentList/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 38f2fb22..3f8d60ab 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -110,7 +110,7 @@ export function StudentList() { pageSize: newPageSize, }) - if (newPage < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + if (newPage < Math.ceil((invites?.count ?? 0) / newPageSize)) { setQueryPaginationParams((prevParams) => ({ ...prevParams, invites: { @@ -118,7 +118,7 @@ export function StudentList() { pageSize: newPageSize, }, })) - } else if (newPage === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + } else if (newPage === Math.ceil((invites?.count ?? 0) / newPageSize)) { setQueryPaginationParams(() => ({ invites: { page: newPage, @@ -130,7 +130,7 @@ export function StudentList() { }, })) } else { - const nextPage = Math.abs(newPage - Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) + const nextPage = Math.abs(newPage - Math.ceil((invites?.count ?? 0) / newPageSize)) setQueryPaginationParams(() => ({ invites: { page: defaultPaginationTablePage, From 38ebc9a9a019eefb90156b62e23b22f0ec8e11e0 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:56:03 +0500 Subject: [PATCH 15/44] fix --- apps/schools/domains/student/components/studentList/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 3f8d60ab..c16244fa 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -126,7 +126,7 @@ export function StudentList() { }, students: { page: defaultPaginationTablePage, - pageSize: paginationParams.pageSize - ((invites?.count ?? 0) % newPageSize), + pageSize: newPageSize - ((invites?.count ?? 0) % newPageSize), }, })) } else { @@ -138,7 +138,7 @@ export function StudentList() { }, students: { page: nextPage, - pageSize: 2 * paginationParams.pageSize - ((invites?.count ?? 0) % newPageSize), + pageSize: 2 * newPageSize - ((invites?.count ?? 0) % newPageSize), }, })) } From 185e9d2ce13f9515a4306188308946e80eba4a34 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:09:49 +0500 Subject: [PATCH 16/44] refactor --- .../common/handlers/paginationChange.ts | 59 +++++++++++++++++++ .../student/components/studentList/index.tsx | 53 ++++------------- 2 files changed, 72 insertions(+), 40 deletions(-) create mode 100644 apps/schools/domains/common/handlers/paginationChange.ts diff --git a/apps/schools/domains/common/handlers/paginationChange.ts b/apps/schools/domains/common/handlers/paginationChange.ts new file mode 100644 index 00000000..5c3ba72c --- /dev/null +++ b/apps/schools/domains/common/handlers/paginationChange.ts @@ -0,0 +1,59 @@ +export const handlePaginationChange = ( + setPaginationParams: (params: { page: number; pageSize: number }) => void, + setQueryPaginationParams: (params: { + invites: { page: number; pageSize: number } + students: { page: number; pageSize: number } + }) => void, + invitesCount: number | undefined, + newPage: number, + newPageSize: number, + defaultPaginationTablePage: number, + defaultPaginationTablePageSize: number, + scrollToTop: () => void, +) => { + setPaginationParams({ + page: newPage, + pageSize: newPageSize, + }) + + let newQueryParams: { invites: { page: number; pageSize: number }; students: { page: number; pageSize: number } } + + if (newPage < Math.ceil((invitesCount ?? 0) / newPageSize)) { + newQueryParams = { + invites: { + page: newPage, + pageSize: newPageSize, + }, + students: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, + } + } else if (newPage === Math.ceil((invitesCount ?? 0) / newPageSize)) { + newQueryParams = { + invites: { + page: newPage, + pageSize: newPageSize, + }, + students: { + page: defaultPaginationTablePage, + pageSize: newPageSize - ((invitesCount ?? 0) % newPageSize), + }, + } + } else { + const nextPage = Math.abs(newPage - Math.ceil((invitesCount ?? 0) / newPageSize)) + newQueryParams = { + invites: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, + students: { + page: nextPage, + pageSize: 2 * newPageSize - ((invitesCount ?? 0) % newPageSize), + }, + } + } + + setQueryPaginationParams(newQueryParams) + scrollToTop() +} diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index c16244fa..ce2aa659 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -14,6 +14,7 @@ import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' import { scrollToTop } from '@domains/common/utils/scrollInDirection' +import { handlePaginationChange } from '@domains/common/handlers/paginationChange' export function StudentList() { const [queryPaginationParams, setQueryPaginationParams] = useState({ @@ -50,7 +51,7 @@ export function StudentList() { pageSize: defaultPaginationTablePageSize, }) - const resultsCalc = useCallback((): RowType[] => { + const resultsCalculate = useCallback((): RowType[] => { if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { return (invites?.results ?? []).map((x) => { return { @@ -101,48 +102,20 @@ export function StudentList() { count: (invites?.count ?? 0) + (students?.count ?? 0), next: invites?.next ?? '', previous: invites?.previous ?? '', - results: resultsCalc(), + results: resultsCalculate(), } const handlePageChange = (newPage: number, newPageSize: number) => { - setPaginationParams({ - page: newPage, - pageSize: newPageSize, - }) - - if (newPage < Math.ceil((invites?.count ?? 0) / newPageSize)) { - setQueryPaginationParams((prevParams) => ({ - ...prevParams, - invites: { - page: newPage, - pageSize: newPageSize, - }, - })) - } else if (newPage === Math.ceil((invites?.count ?? 0) / newPageSize)) { - setQueryPaginationParams(() => ({ - invites: { - page: newPage, - pageSize: newPageSize, - }, - students: { - page: defaultPaginationTablePage, - pageSize: newPageSize - ((invites?.count ?? 0) % newPageSize), - }, - })) - } else { - const nextPage = Math.abs(newPage - Math.ceil((invites?.count ?? 0) / newPageSize)) - setQueryPaginationParams(() => ({ - invites: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - students: { - page: nextPage, - pageSize: 2 * newPageSize - ((invites?.count ?? 0) % newPageSize), - }, - })) - } - scrollToTop() + handlePaginationChange( + setPaginationParams, + setQueryPaginationParams, + invites?.count, + newPage, + newPageSize, + defaultPaginationTablePage, + defaultPaginationTablePageSize, + scrollToTop, + ) } return ( From ed49e2c0fffbe3ba95191ed2953e074b9b9dc816 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:39:25 +0500 Subject: [PATCH 17/44] resultsCalculate took it out --- .../student/components/studentList/index.tsx | 53 +++---------------- .../student/handlers/resultsCalculate.ts | 52 ++++++++++++++++++ 2 files changed, 59 insertions(+), 46 deletions(-) create mode 100644 apps/schools/domains/student/handlers/resultsCalculate.ts diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index ce2aa659..5d9d4737 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -15,6 +15,7 @@ import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' import { scrollToTop } from '@domains/common/utils/scrollInDirection' import { handlePaginationChange } from '@domains/common/handlers/paginationChange' +import { calculateResults } from '@domains/student/handlers/resultsCalculate' export function StudentList() { const [queryPaginationParams, setQueryPaginationParams] = useState({ @@ -51,52 +52,12 @@ export function StudentList() { pageSize: defaultPaginationTablePageSize, }) - const resultsCalculate = useCallback((): RowType[] => { - if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { - return (invites?.results ?? []).map((x) => { - return { - id: x.body.id, - student_name: x.body.name, - student_phone: x.additional.phone, - parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), - circle_name: x.sender.name, - } as RowType - }) - } else if (paginationParams.page === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { - return [...(invites?.results ?? []), ...(students?.results ?? [])] - .slice(0, paginationParams.pageSize) - .map((x) => { - if ('body' in x) { - return { - id: x.body.id, - student_name: x.body.name, - student_phone: x.additional.phone, - parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), - circle_name: x.sender.name, - } as RowType - } else { - return { - id: x.id, - student_name: x.name, - student_phone: x.student_profile.phone, - parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), - circle_name: x.circle.name, - } as RowType - } - }) - } else { - const temp = paginationParams.pageSize - ((invites?.count ?? 0) % paginationParams.pageSize) - return (students?.results ?? []).slice(temp).map((x) => { - return { - id: x.id, - student_name: x.name, - student_phone: x.student_profile.phone, - parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), - circle_name: x.circle.name, - } as RowType - }) - } - }, [queryPaginationParams, paginationParams, invites, students]) + const resultsCalculate = useCallback( + () => calculateResults(paginationParams, invites, students), + [paginationParams, invites, students], + ) + + console.log(resultsCalculate()) const data = { count: (invites?.count ?? 0) + (students?.count ?? 0), diff --git a/apps/schools/domains/student/handlers/resultsCalculate.ts b/apps/schools/domains/student/handlers/resultsCalculate.ts new file mode 100644 index 00000000..143e5afe --- /dev/null +++ b/apps/schools/domains/student/handlers/resultsCalculate.ts @@ -0,0 +1,52 @@ +import { RowType } from '@domains/student/components/studentList/interfaces' + +export const calculateResults = ( + paginationParams: { page: number; pageSize: number }, + invites: { count: number | undefined; results: any[] } | undefined, + students: { count: number | undefined; results: any[] } | undefined, +): RowType[] => { + if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + return (invites?.results ?? []).map((x) => { + return { + id: x.body.id, + student_name: x.body.name, + student_phone: x.additional.phone, + parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), + circle_name: x.sender.name, + } as RowType + }) + } else if (paginationParams.page === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + return [...(invites?.results ?? []), ...(students?.results ?? [])] + .slice(0, paginationParams.pageSize) + .map((x) => { + if ('body' in x) { + return { + id: x.body.id, + student_name: x.body.name, + student_phone: x.additional.phone, + parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), + circle_name: x.sender.name, + } as RowType + } else { + return { + id: x.id, + student_name: x.name, + student_phone: x.student_profile.phone, + parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), + circle_name: x.circle.name, + } as RowType + } + }) + } else { + const temp = paginationParams.pageSize - ((invites?.count ?? 0) % paginationParams.pageSize) + return (students?.results ?? []).slice(temp).map((x) => { + return { + id: x.id, + student_name: x.name, + student_phone: x.student_profile.phone, + parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), + circle_name: x.circle.name, + } as RowType + }) + } +} From d5fb712733b226b50aca34cfa340f4fbbe70a15d Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:44:48 +0500 Subject: [PATCH 18/44] fix --- .../domains/student/handlers/resultsCalculate.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/schools/domains/student/handlers/resultsCalculate.ts b/apps/schools/domains/student/handlers/resultsCalculate.ts index 143e5afe..735ea4c8 100644 --- a/apps/schools/domains/student/handlers/resultsCalculate.ts +++ b/apps/schools/domains/student/handlers/resultsCalculate.ts @@ -39,14 +39,17 @@ export const calculateResults = ( }) } else { const temp = paginationParams.pageSize - ((invites?.count ?? 0) % paginationParams.pageSize) - return (students?.results ?? []).slice(temp).map((x) => { - return { + const mapper = (x: any) => + ({ id: x.id, student_name: x.name, student_phone: x.student_profile.phone, parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), circle_name: x.circle.name, - } as RowType - }) + }) as RowType + + return students?.results.length === 1 + ? [mapper(students?.results[0])] + : (students?.results ?? []).slice(temp).map(mapper) } } From 3e77fdc3aca4b0ea4c778332cfe7ebb3da50834a Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 5 Jul 2024 03:01:58 +0500 Subject: [PATCH 19/44] del console.log --- apps/schools/domains/student/components/studentList/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 5d9d4737..d6c4fe5f 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -57,8 +57,6 @@ export function StudentList() { [paginationParams, invites, students], ) - console.log(resultsCalculate()) - const data = { count: (invites?.count ?? 0) + (students?.count ?? 0), next: invites?.next ?? '', From c629aa0f0a99a7b9d640ad748b7e62e2397f8b4b Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:34:20 +0500 Subject: [PATCH 20/44] calculateResults mappers took in transformResponse organizationApi --- .../domains/common/redux/serializers.ts | 4 +- .../organization/redux/organizationApi.ts | 23 ++++++++++ .../student/handlers/resultsCalculate.ts | 45 ++----------------- 3 files changed, 28 insertions(+), 44 deletions(-) diff --git a/apps/schools/domains/common/redux/serializers.ts b/apps/schools/domains/common/redux/serializers.ts index 6165fb90..b16df007 100644 --- a/apps/schools/domains/common/redux/serializers.ts +++ b/apps/schools/domains/common/redux/serializers.ts @@ -125,10 +125,10 @@ interface GetStudentProfile { id?: string name: string age?: number - phone?: string + phone: string photo: GetPhoto parent_names?: string - parent_phones?: string + parent_phones: string } export interface GetAnalytics { diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index 6dcafe3d..2307d8a5 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -37,6 +37,7 @@ import { mapReturnedData } from '@domains/common/redux/utils' import { TableType as TableTypeCircle } from '@domains/circle/components/circleList/interfaces' import { TableType as TableTypeTickets } from '@domains/ticket/components/ticketList/interfaces' import { TableType as TableTypeQuery } from '@domains/query/components/queryList/interfaces' +import { TableType as TableTypeStudent } from '@domains/student/components/studentList/interfaces' const organizationApi = commonApi.injectEndpoints({ endpoints: (build) => ({ @@ -70,6 +71,17 @@ const organizationApi = commonApi.injectEndpoints({ method: 'GET', params: params, }), + transformResponse: (response: ReturnedData) => { + return mapReturnedData(response, (query) => { + const transformedQuery = structuredClone(query) as unknown as TableTypeStudent + transformedQuery.id = query.id + transformedQuery.student_name = query.name + transformedQuery.student_phone = query.student_profile.phone + transformedQuery.parent_phone = query.student_profile.parent_phones?.replaceAll(',', '\n') + transformedQuery.circle_name = query.circle.name + return transformedQuery + })! + }, providesTags: (result) => providesList(result?.results, 'Student'), }), getAllCircles: build.query, GetOrganizationCircleListData>({ @@ -168,6 +180,17 @@ const organizationApi = commonApi.injectEndpoints({ method: 'GET', params: params, }), + transformResponse: (response: ReturnedData) => { + return mapReturnedData(response, (query) => { + const transformedQuery = structuredClone(query) as unknown as TableTypeStudent + transformedQuery.id = query.body.id + transformedQuery.student_name = query.body.name + transformedQuery.student_phone = query.additional.phone + transformedQuery.parent_phone = query.recipient.parent_phones.replaceAll(',', '\n') + transformedQuery.circle_name = query.sender.name + return transformedQuery + })! + }, providesTags: (result) => providesList(result?.results, 'Student'), }), getAllJoinCircleQueries: build.query, AllStudentJoinCircleQueriesData>({ diff --git a/apps/schools/domains/student/handlers/resultsCalculate.ts b/apps/schools/domains/student/handlers/resultsCalculate.ts index 735ea4c8..abd92688 100644 --- a/apps/schools/domains/student/handlers/resultsCalculate.ts +++ b/apps/schools/domains/student/handlers/resultsCalculate.ts @@ -6,50 +6,11 @@ export const calculateResults = ( students: { count: number | undefined; results: any[] } | undefined, ): RowType[] => { if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { - return (invites?.results ?? []).map((x) => { - return { - id: x.body.id, - student_name: x.body.name, - student_phone: x.additional.phone, - parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), - circle_name: x.sender.name, - } as RowType - }) + return invites?.results ?? [] } else if (paginationParams.page === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { - return [...(invites?.results ?? []), ...(students?.results ?? [])] - .slice(0, paginationParams.pageSize) - .map((x) => { - if ('body' in x) { - return { - id: x.body.id, - student_name: x.body.name, - student_phone: x.additional.phone, - parent_phone: x.recipient.parent_phones.replaceAll(',', '\n'), - circle_name: x.sender.name, - } as RowType - } else { - return { - id: x.id, - student_name: x.name, - student_phone: x.student_profile.phone, - parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), - circle_name: x.circle.name, - } as RowType - } - }) + return [...(invites?.results ?? []), ...(students?.results ?? [])].slice(0, paginationParams.pageSize) } else { const temp = paginationParams.pageSize - ((invites?.count ?? 0) % paginationParams.pageSize) - const mapper = (x: any) => - ({ - id: x.id, - student_name: x.name, - student_phone: x.student_profile.phone, - parent_phone: x.student_profile.parent_phones?.replaceAll(',', '\n'), - circle_name: x.circle.name, - }) as RowType - - return students?.results.length === 1 - ? [mapper(students?.results[0])] - : (students?.results ?? []).slice(temp).map(mapper) + return students?.results.length === 1 ? [students?.results[0]] : (students?.results ?? []).slice(temp) } } From 66e785673fab42c03d9592e06a83fb8d0721726c Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 11 Jul 2024 19:42:07 +0500 Subject: [PATCH 21/44] add search parameter in query/ticket/employee tables --- .../components/employeeList/index.tsx | 23 ++++++++++++------- .../query/components/queryList/index.tsx | 18 ++++++++++----- .../ticket/components/ticketList/index.tsx | 22 +++++++++++------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 7247578b..91c9b6be 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, {useEffect, useState} from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' @@ -13,10 +13,15 @@ import { searchColumns } from '@domains/employee/components/employeeList/constan import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' import { scrollToTop } from '@domains/common/utils/scrollInDirection' +import { useQueryState } from 'next-usequerystate' export function EmployeeList() { - const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() + const [searchRequest, setSearchRequest] = useQueryState('search') + + useEffect(() => { + localStorage.setItem('search', searchRequest) + }, [searchRequest]); const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, @@ -25,11 +30,13 @@ export function EmployeeList() { const { data, isFetching } = useGetAllEmployeesQuery({ organization: organizationId, - or_search: createSearchTextForRequest(searchRequestText, searchColumns), + or_search: createSearchTextForRequest(searchRequest || '', searchColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) + const searchRequestText = localStorage.getItem('search') ? localStorage.getItem('search') : searchRequest; + return ( <>
@@ -58,17 +65,17 @@ export function EmployeeList() { setPaginationParams({ page, pageSize, - }) - scrollToTop() + }); + scrollToTop(); }, }} data={data} isLoading={isFetching} mainRoute={RoutePath[AppRoutes.EMPLOYEE_LIST]} searchFields={searchColumns} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequest(text)} /> ) -} +} \ No newline at end of file diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index e8153aff..743526b4 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -25,9 +25,15 @@ import { scrollToTop } from '@domains/common/utils/scrollInDirection' export function QueryList() { const { organizationId } = useOrganization() - const [searchRequestText, setSearchRequestText] = useState('') + const [searchRequest, setSearchRequest] = useQueryState('search') const [isTableLoading, setIsTableLoading] = useState(false) + useEffect(() => { + localStorage.setItem('search', searchRequest) + }, [searchRequest]); + + const searchRequestText = localStorage.getItem('search') ? localStorage.getItem('search') : searchRequest; + const [statuses, setStatuses] = useQueryState( 'statuses', parseAsArrayOf(parseAsString).withOptions({ @@ -77,7 +83,7 @@ export function QueryList() { const { data: queries, isFetching: isQueriesFetching } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, - or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) @@ -96,7 +102,7 @@ export function QueryList() { const handleSearchChange = useCallback((value: string) => { setIsTableLoading(true) setTimeout(() => { - setSearchRequestText(value) + setSearchRequest(value) }, 1000) }, []) @@ -107,7 +113,7 @@ export function QueryList() { pageTitle={'Заявки'} data={queries} isLoading={isQueriesFetching} - searchTrigger={searchRequestText} + searchTrigger={searchRequestText || ''} >
Заявки @@ -202,8 +208,8 @@ export function QueryList() { }, }} sortFields={['created_at']} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequest(text)} onChange={(pagination, filters, sorter) => { const localStatuses = [...(filters['status'] ?? [])] as string[] setStatuses(localStatuses.length === 0 ? null : localStatuses) diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index c8fbfc49..6fb47ec6 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -32,9 +32,15 @@ type HandleChange = ( export function TicketList() { const [inputText, setInputText] = useState('') - const [searchRequestText, setSearchRequestText] = useState('') const [isTableLoading, setIsTableLoading] = useState(false) const { organizationId } = useOrganization() + const [searchRequest, setSearchRequest] = useQueryState('search') + + useEffect(() => { + localStorage.setItem('search', searchRequest) + }, [searchRequest]); + + const searchRequestText = localStorage.getItem('search') ? localStorage.getItem('search') : searchRequest; const [statuses, setStatuses] = useQueryState( 'statuses', @@ -77,7 +83,7 @@ export function TicketList() { const { data: tickets, isFetching: isTicketsFetching } = useGetAllTicketsQuery({ organization_id: organizationId, - or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchTicketsColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) @@ -94,17 +100,17 @@ export function TicketList() { setIsTableLoading(true) setInputText(text) setTimeout(() => { - setSearchRequestText(text) + setSearchRequest(text) }, 1000) } else { setIsTableLoading(true) setInputText(text.target.value) setTimeout(() => { - setSearchRequestText(text.target.value) + setSearchRequest(text.target.value) }, 1000) } }, - [setIsTableLoading, setInputText, setSearchRequestText], + [setIsTableLoading, setInputText, setSearchRequest], ) const handleChange: HandleChange = useCallback( @@ -122,7 +128,7 @@ export function TicketList() { pageTitle={'Обращения'} data={tickets} isLoading={isTicketsFetching} - searchTrigger={searchRequestText} + searchTrigger={searchRequestText || ''} >
Обращения @@ -209,8 +215,8 @@ export function TicketList() { }, }} sortFields={['created_at']} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequest(text)} onChange={handleChange} />
From 3b0165c382fbc0f6e78e5bde81628482f52bdac1 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:06:00 +0500 Subject: [PATCH 22/44] calculateResults for 2 arrays --- .../domains/common/handlers/paginationChange.ts | 15 ++------------- .../student/components/studentList/index.tsx | 4 +++- .../domains/student/handlers/resultsCalculate.ts | 7 ++----- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/apps/schools/domains/common/handlers/paginationChange.ts b/apps/schools/domains/common/handlers/paginationChange.ts index 5c3ba72c..946f6cbf 100644 --- a/apps/schools/domains/common/handlers/paginationChange.ts +++ b/apps/schools/domains/common/handlers/paginationChange.ts @@ -18,7 +18,7 @@ export const handlePaginationChange = ( let newQueryParams: { invites: { page: number; pageSize: number }; students: { page: number; pageSize: number } } - if (newPage < Math.ceil((invitesCount ?? 0) / newPageSize)) { + if (newPage <= Math.ceil((invitesCount ?? 0) / newPageSize)) { newQueryParams = { invites: { page: newPage, @@ -29,17 +29,6 @@ export const handlePaginationChange = ( pageSize: defaultPaginationTablePageSize, }, } - } else if (newPage === Math.ceil((invitesCount ?? 0) / newPageSize)) { - newQueryParams = { - invites: { - page: newPage, - pageSize: newPageSize, - }, - students: { - page: defaultPaginationTablePage, - pageSize: newPageSize - ((invitesCount ?? 0) % newPageSize), - }, - } } else { const nextPage = Math.abs(newPage - Math.ceil((invitesCount ?? 0) / newPageSize)) newQueryParams = { @@ -49,7 +38,7 @@ export const handlePaginationChange = ( }, students: { page: nextPage, - pageSize: 2 * newPageSize - ((invitesCount ?? 0) % newPageSize), + pageSize: newPageSize, }, } } diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index d6c4fe5f..fb1b3c60 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -110,7 +110,9 @@ export function StudentList() { pagination={{ current: paginationParams.page, pageSize: paginationParams.pageSize, - total: (invites?.count ?? 0) + (students?.count ?? 0), + total: + Math.ceil((invites?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize + + Math.ceil((students?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize, onChange: (page, pageSize) => { handlePageChange(page, pageSize) }, diff --git a/apps/schools/domains/student/handlers/resultsCalculate.ts b/apps/schools/domains/student/handlers/resultsCalculate.ts index abd92688..a43e7000 100644 --- a/apps/schools/domains/student/handlers/resultsCalculate.ts +++ b/apps/schools/domains/student/handlers/resultsCalculate.ts @@ -5,12 +5,9 @@ export const calculateResults = ( invites: { count: number | undefined; results: any[] } | undefined, students: { count: number | undefined; results: any[] } | undefined, ): RowType[] => { - if (paginationParams.page < Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { + if (paginationParams.page <= Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { return invites?.results ?? [] - } else if (paginationParams.page === Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { - return [...(invites?.results ?? []), ...(students?.results ?? [])].slice(0, paginationParams.pageSize) } else { - const temp = paginationParams.pageSize - ((invites?.count ?? 0) % paginationParams.pageSize) - return students?.results.length === 1 ? [students?.results[0]] : (students?.results ?? []).slice(temp) + return students?.results ?? [] } } From 5791c7c16d9231a5e02fdfdff5a2c9c14300addf Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:20:07 +0500 Subject: [PATCH 23/44] calculateResults for 3 arrays --- .../common/handlers/paginationChange.ts | 34 +++++++++++++++++-- .../student/components/studentList/index.tsx | 4 ++- .../student/handlers/resultsCalculate.ts | 5 +++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/apps/schools/domains/common/handlers/paginationChange.ts b/apps/schools/domains/common/handlers/paginationChange.ts index 946f6cbf..d0c80b0d 100644 --- a/apps/schools/domains/common/handlers/paginationChange.ts +++ b/apps/schools/domains/common/handlers/paginationChange.ts @@ -2,9 +2,11 @@ export const handlePaginationChange = ( setPaginationParams: (params: { page: number; pageSize: number }) => void, setQueryPaginationParams: (params: { invites: { page: number; pageSize: number } + teachers: { page: number; pageSize: number } students: { page: number; pageSize: number } }) => void, invitesCount: number | undefined, + teachersCount: number | undefined, newPage: number, newPageSize: number, defaultPaginationTablePage: number, @@ -16,7 +18,11 @@ export const handlePaginationChange = ( pageSize: newPageSize, }) - let newQueryParams: { invites: { page: number; pageSize: number }; students: { page: number; pageSize: number } } + let newQueryParams: { + invites: { page: number; pageSize: number } + teachers: { page: number; pageSize: number } + students: { page: number; pageSize: number } + } if (newPage <= Math.ceil((invitesCount ?? 0) / newPageSize)) { newQueryParams = { @@ -24,18 +30,42 @@ export const handlePaginationChange = ( page: newPage, pageSize: newPageSize, }, + teachers: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, students: { page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }, } - } else { + } else if (newPage <= Math.ceil(((teachersCount ?? 0) + (invitesCount ?? 0)) / newPageSize)) { const nextPage = Math.abs(newPage - Math.ceil((invitesCount ?? 0) / newPageSize)) newQueryParams = { invites: { page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }, + teachers: { + page: nextPage, + pageSize: newPageSize, + }, + students: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, + } + } else { + const nextPage = Math.abs(newPage - Math.ceil(((teachersCount ?? 0) + (invitesCount ?? 0)) / newPageSize)) + newQueryParams = { + invites: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, + teachers: { + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, + }, students: { page: nextPage, pageSize: newPageSize, diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index fb1b3c60..394bab52 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -53,7 +53,7 @@ export function StudentList() { }) const resultsCalculate = useCallback( - () => calculateResults(paginationParams, invites, students), + () => calculateResults(paginationParams, invites, invites, students), [paginationParams, invites, students], ) @@ -69,6 +69,7 @@ export function StudentList() { setPaginationParams, setQueryPaginationParams, invites?.count, + invites?.count, newPage, newPageSize, defaultPaginationTablePage, @@ -111,6 +112,7 @@ export function StudentList() { current: paginationParams.page, pageSize: paginationParams.pageSize, total: + Math.ceil((invites?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize + Math.ceil((invites?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize + Math.ceil((students?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize, onChange: (page, pageSize) => { diff --git a/apps/schools/domains/student/handlers/resultsCalculate.ts b/apps/schools/domains/student/handlers/resultsCalculate.ts index a43e7000..b7f96821 100644 --- a/apps/schools/domains/student/handlers/resultsCalculate.ts +++ b/apps/schools/domains/student/handlers/resultsCalculate.ts @@ -3,10 +3,15 @@ import { RowType } from '@domains/student/components/studentList/interfaces' export const calculateResults = ( paginationParams: { page: number; pageSize: number }, invites: { count: number | undefined; results: any[] } | undefined, + teachers: { count: number | undefined; results: any[] } | undefined, students: { count: number | undefined; results: any[] } | undefined, ): RowType[] => { if (paginationParams.page <= Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { return invites?.results ?? [] + } else if ( + paginationParams.page <= Math.ceil(((teachers?.count ?? 0) + (invites?.count ?? 0)) / paginationParams.pageSize) + ) { + return teachers?.results ?? [] } else { return students?.results ?? [] } From a770209b2913d66c3311a6ee844a6a75fb3abbd1 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:46:05 +0500 Subject: [PATCH 24/44] resultsCalculate work for n element data --- .../student/components/studentList/index.tsx | 2 +- .../student/handlers/resultsCalculate.ts | 27 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 394bab52..923106d0 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -53,7 +53,7 @@ export function StudentList() { }) const resultsCalculate = useCallback( - () => calculateResults(paginationParams, invites, invites, students), + () => calculateResults(paginationParams, { invites, teachers: invites, students }), [paginationParams, invites, students], ) diff --git a/apps/schools/domains/student/handlers/resultsCalculate.ts b/apps/schools/domains/student/handlers/resultsCalculate.ts index b7f96821..b1fcde23 100644 --- a/apps/schools/domains/student/handlers/resultsCalculate.ts +++ b/apps/schools/domains/student/handlers/resultsCalculate.ts @@ -2,17 +2,22 @@ import { RowType } from '@domains/student/components/studentList/interfaces' export const calculateResults = ( paginationParams: { page: number; pageSize: number }, - invites: { count: number | undefined; results: any[] } | undefined, - teachers: { count: number | undefined; results: any[] } | undefined, - students: { count: number | undefined; results: any[] } | undefined, + data: { + [key: string]: { count: number | undefined; results: any[] } | undefined + }, ): RowType[] => { - if (paginationParams.page <= Math.ceil((invites?.count ?? 0) / paginationParams.pageSize)) { - return invites?.results ?? [] - } else if ( - paginationParams.page <= Math.ceil(((teachers?.count ?? 0) + (invites?.count ?? 0)) / paginationParams.pageSize) - ) { - return teachers?.results ?? [] - } else { - return students?.results ?? [] + const dataArray = Object.values(data) + const pageIndex = paginationParams.page - 1 + let offset = 0 + + for (const item of dataArray) { + const count = item?.count ?? 0 + const pageCount = Math.ceil(count / paginationParams.pageSize) + if (pageIndex < offset + pageCount) { + return item?.results ?? [] + } + offset += pageCount } + + return [] } From 3570697daf08fc5f4eacc8a301c50897be226bd9 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:43:54 +0500 Subject: [PATCH 25/44] handlePaginationChange work for n element data --- .../common/handlers/paginationChange.ts | 77 +++++-------------- .../student/components/studentList/index.tsx | 9 ++- 2 files changed, 27 insertions(+), 59 deletions(-) diff --git a/apps/schools/domains/common/handlers/paginationChange.ts b/apps/schools/domains/common/handlers/paginationChange.ts index d0c80b0d..bbd0217c 100644 --- a/apps/schools/domains/common/handlers/paginationChange.ts +++ b/apps/schools/domains/common/handlers/paginationChange.ts @@ -1,12 +1,7 @@ export const handlePaginationChange = ( setPaginationParams: (params: { page: number; pageSize: number }) => void, - setQueryPaginationParams: (params: { - invites: { page: number; pageSize: number } - teachers: { page: number; pageSize: number } - students: { page: number; pageSize: number } - }) => void, - invitesCount: number | undefined, - teachersCount: number | undefined, + setQueryPaginationParams: (params: { [key: string]: { page: number; pageSize: number } }) => void, + counts: { [key: string]: number | undefined }, newPage: number, newPageSize: number, defaultPaginationTablePage: number, @@ -18,60 +13,30 @@ export const handlePaginationChange = ( pageSize: newPageSize, }) - let newQueryParams: { - invites: { page: number; pageSize: number } - teachers: { page: number; pageSize: number } - students: { page: number; pageSize: number } - } + const newQueryParams: { [key: string]: { page: number; pageSize: number } } = {} - if (newPage <= Math.ceil((invitesCount ?? 0) / newPageSize)) { - newQueryParams = { - invites: { - page: newPage, - pageSize: newPageSize, - }, - teachers: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - students: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - } - } else if (newPage <= Math.ceil(((teachersCount ?? 0) + (invitesCount ?? 0)) / newPageSize)) { - const nextPage = Math.abs(newPage - Math.ceil((invitesCount ?? 0) / newPageSize)) - newQueryParams = { - invites: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - teachers: { - page: nextPage, + let currentPage = newPage + let currentOffset = 0 + + Object.keys(counts).forEach((key, index) => { + const count = counts[key] ?? 0 + const maxPages = Math.ceil(count / newPageSize) + + if (currentPage <= maxPages) { + newQueryParams[key] = { + page: currentPage, pageSize: newPageSize, - }, - students: { + } + } else { + currentPage -= maxPages + newQueryParams[key] = { page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, - }, + } } - } else { - const nextPage = Math.abs(newPage - Math.ceil(((teachersCount ?? 0) + (invitesCount ?? 0)) / newPageSize)) - newQueryParams = { - invites: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - teachers: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - students: { - page: nextPage, - pageSize: newPageSize, - }, - } - } + + currentOffset += count + }) setQueryPaginationParams(newQueryParams) scrollToTop() diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 923106d0..81d28345 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -67,9 +67,12 @@ export function StudentList() { const handlePageChange = (newPage: number, newPageSize: number) => { handlePaginationChange( setPaginationParams, - setQueryPaginationParams, - invites?.count, - invites?.count, + setQueryPaginationParams as any, + { + invites: invites?.count, + teachers: invites?.count, + students: students?.count, + }, newPage, newPageSize, defaultPaginationTablePage, From d097eff6a0f57f2496f534acd57f5d31fc0c0804 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:45:09 +0500 Subject: [PATCH 26/44] del teachers --- apps/schools/domains/student/components/studentList/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 81d28345..aa6fdfa5 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -53,7 +53,7 @@ export function StudentList() { }) const resultsCalculate = useCallback( - () => calculateResults(paginationParams, { invites, teachers: invites, students }), + () => calculateResults(paginationParams, { invites, students }), [paginationParams, invites, students], ) @@ -70,7 +70,6 @@ export function StudentList() { setQueryPaginationParams as any, { invites: invites?.count, - teachers: invites?.count, students: students?.count, }, newPage, @@ -115,7 +114,6 @@ export function StudentList() { current: paginationParams.page, pageSize: paginationParams.pageSize, total: - Math.ceil((invites?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize + Math.ceil((invites?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize + Math.ceil((students?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize, onChange: (page, pageSize) => { From f1a0198e93b72a4e0d28b34f36c6523203be8909 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:50:57 +0500 Subject: [PATCH 27/44] add getTotalPages util function --- apps/schools/domains/common/utils/getTotalPages.ts | 5 +++++ .../domains/student/components/studentList/index.tsx | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 apps/schools/domains/common/utils/getTotalPages.ts diff --git a/apps/schools/domains/common/utils/getTotalPages.ts b/apps/schools/domains/common/utils/getTotalPages.ts new file mode 100644 index 00000000..7ebaea31 --- /dev/null +++ b/apps/schools/domains/common/utils/getTotalPages.ts @@ -0,0 +1,5 @@ +export const getTotalPages = (counts: { [key: string]: { count: number | undefined } }, pageSize: number) => { + return Object.keys(counts).reduce((total, key) => { + return total + Math.ceil((counts[key].count ?? 0) / pageSize) * pageSize + }, 0) +} diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index aa6fdfa5..f035c9a2 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -16,6 +16,7 @@ import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@dom import { scrollToTop } from '@domains/common/utils/scrollInDirection' import { handlePaginationChange } from '@domains/common/handlers/paginationChange' import { calculateResults } from '@domains/student/handlers/resultsCalculate' +import { getTotalPages } from '@domains/common/utils/getTotalPages' export function StudentList() { const [queryPaginationParams, setQueryPaginationParams] = useState({ @@ -113,9 +114,10 @@ export function StudentList() { pagination={{ current: paginationParams.page, pageSize: paginationParams.pageSize, - total: - Math.ceil((invites?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize + - Math.ceil((students?.count ?? 0) / paginationParams.pageSize) * paginationParams.pageSize, + total: getTotalPages( + { invites: { count: invites?.count }, students: { count: students?.count } }, + paginationParams.pageSize, + ), onChange: (page, pageSize) => { handlePageChange(page, pageSize) }, From ea2d023e2ee967db2f4c818d79b27388f3af7ea6 Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 12 Jul 2024 18:14:37 +0500 Subject: [PATCH 28/44] delete localstorage, add query state in input search --- .../domains/common/components/table/index.tsx | 5 +++-- .../employee/components/employeeList/index.tsx | 10 ++-------- .../domains/query/components/queryList/index.tsx | 12 +++--------- .../domains/ticket/components/ticketList/index.tsx | 12 +++--------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/apps/schools/domains/common/components/table/index.tsx b/apps/schools/domains/common/components/table/index.tsx index 1e7d1ffb..108f962e 100644 --- a/apps/schools/domains/common/components/table/index.tsx +++ b/apps/schools/domains/common/components/table/index.tsx @@ -9,6 +9,7 @@ import { typeTable } from '@domains/common/constants/Table' import { CustomTableProps } from '@domains/common/components/table/interfaces' import { calculateAverageWidth } from '@domains/common/utils/calculateAverageWidth' import { ColumnType } from 'antd/lib/table/interface' +import { useQueryState } from "next-usequerystate"; export const Table = (props: CustomTableProps) => { const { @@ -64,7 +65,7 @@ export const Table = (props: CustomTableProps([]) const router = useRouter() @@ -134,7 +135,7 @@ export const Table = (props: CustomTableProps diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 91c9b6be..1621d49e 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react' +import React, { useState } from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' @@ -19,10 +19,6 @@ export function EmployeeList() { const { organizationId } = useOrganization() const [searchRequest, setSearchRequest] = useQueryState('search') - useEffect(() => { - localStorage.setItem('search', searchRequest) - }, [searchRequest]); - const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, @@ -35,8 +31,6 @@ export function EmployeeList() { page_size: paginationParams.pageSize, }) - const searchRequestText = localStorage.getItem('search') ? localStorage.getItem('search') : searchRequest; - return ( <>
@@ -73,7 +67,7 @@ export function EmployeeList() { isLoading={isFetching} mainRoute={RoutePath[AppRoutes.EMPLOYEE_LIST]} searchFields={searchColumns} - searchRequestText={searchRequestText || ''} + searchRequestText={searchRequest || ''} setSearchRequestText={(text) => setSearchRequest(text)} /> diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index 743526b4..3e1176fa 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -28,12 +28,6 @@ export function QueryList() { const [searchRequest, setSearchRequest] = useQueryState('search') const [isTableLoading, setIsTableLoading] = useState(false) - useEffect(() => { - localStorage.setItem('search', searchRequest) - }, [searchRequest]); - - const searchRequestText = localStorage.getItem('search') ? localStorage.getItem('search') : searchRequest; - const [statuses, setStatuses] = useQueryState( 'statuses', parseAsArrayOf(parseAsString).withOptions({ @@ -83,7 +77,7 @@ export function QueryList() { const { data: queries, isFetching: isQueriesFetching } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, - or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), + or_search: createSearchTextForRequest(searchRequest || '', searchStudentsColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) @@ -113,7 +107,7 @@ export function QueryList() { pageTitle={'Заявки'} data={queries} isLoading={isQueriesFetching} - searchTrigger={searchRequestText || ''} + searchTrigger={searchRequest || ''} >
Заявки @@ -208,7 +202,7 @@ export function QueryList() { }, }} sortFields={['created_at']} - searchRequestText={searchRequestText || ''} + searchRequestText={searchRequest || ''} setSearchRequestText={(text) => setSearchRequest(text)} onChange={(pagination, filters, sorter) => { const localStatuses = [...(filters['status'] ?? [])] as string[] diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 6fb47ec6..9f1e85c2 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -36,12 +36,6 @@ export function TicketList() { const { organizationId } = useOrganization() const [searchRequest, setSearchRequest] = useQueryState('search') - useEffect(() => { - localStorage.setItem('search', searchRequest) - }, [searchRequest]); - - const searchRequestText = localStorage.getItem('search') ? localStorage.getItem('search') : searchRequest; - const [statuses, setStatuses] = useQueryState( 'statuses', parseAsArrayOf(parseAsString).withOptions({ @@ -83,7 +77,7 @@ export function TicketList() { const { data: tickets, isFetching: isTicketsFetching } = useGetAllTicketsQuery({ organization_id: organizationId, - or_search: createSearchTextForRequest(searchRequestText || '', searchTicketsColumns), + or_search: createSearchTextForRequest(searchRequest || '', searchTicketsColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) @@ -128,7 +122,7 @@ export function TicketList() { pageTitle={'Обращения'} data={tickets} isLoading={isTicketsFetching} - searchTrigger={searchRequestText || ''} + searchTrigger={searchRequest || ''} >
Обращения @@ -215,7 +209,7 @@ export function TicketList() { }, }} sortFields={['created_at']} - searchRequestText={searchRequestText || ''} + searchRequestText={searchRequest || ''} setSearchRequestText={(text) => setSearchRequest(text)} onChange={handleChange} /> From 99a54f79d9f11627ddb048c12f94e2c92d25582c Mon Sep 17 00:00:00 2001 From: nenichv Date: Mon, 15 Jul 2024 14:41:24 +0500 Subject: [PATCH 29/44] fix --- .../domains/circle/components/circleList/index.tsx | 11 ++++++----- .../circle/components/currentCircle/index.tsx | 9 +++++---- .../domains/common/components/searchInput/index.tsx | 7 ++++--- .../domains/common/components/table/interfaces.ts | 6 +++++- .../domains/query/components/queryList/index.tsx | 4 +--- .../student/components/studentList/index.tsx | 13 +++++++------ .../domains/ticket/components/ticketList/index.tsx | 8 ++------ 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 9c23ba0d..9cfadbf3 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -15,9 +15,10 @@ import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' import { scrollToTop } from '@domains/common/utils/scrollInDirection' +import {useQueryState} from "next-usequerystate"; export function CircleList() { - const [searchRequestText, setSearchRequestText] = useState('') + const [searchRequestText, setSearchRequestText] = useQueryState('search') const { organizationId } = useOrganization() const [paginationParams, setPaginationParams] = useState({ @@ -27,7 +28,7 @@ export function CircleList() { const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ organization_id: organizationId, - or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) @@ -41,7 +42,7 @@ export function CircleList() { data={circles} isLoading={isFetching} handleRunTask={() => router.push(RoutePath[AppRoutes.CIRCLE_CREATE])} - searchTrigger={searchRequestText} + searchTrigger={searchRequestText || ''} >
Кружки @@ -94,8 +95,8 @@ export function CircleList() { }, }} customWidths={[60, 25, 15]} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequestText(text)} rowClassName={styles.tableRowPointer} /> diff --git a/apps/schools/domains/circle/components/currentCircle/index.tsx b/apps/schools/domains/circle/components/currentCircle/index.tsx index 48cbcb25..bb89ebfd 100644 --- a/apps/schools/domains/circle/components/currentCircle/index.tsx +++ b/apps/schools/domains/circle/components/currentCircle/index.tsx @@ -25,10 +25,11 @@ import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { StatusesEnum } from '@domains/common/constants/Enums' import { ErrorType } from '@store/commonApi' import { AppRoutes, DynamicAppRoutes, DynamicRoutePath, RoutePath } from '@domains/common/constants/routerEnums' +import {useQueryState} from "next-usequerystate"; const CurrentCircle = () => { const [isModalVisible, setIsModalVisible] = useState(false) - const [searchRequestText, setSearchRequestText] = useState('') + const [searchRequestText, setSearchRequestText] = useQueryState('search') const [mutation, isDeleteFinished] = useDeleteCircleMutation() const uuid = getUuidFromUrl() const router = useRouter() @@ -40,7 +41,7 @@ const CurrentCircle = () => { const { data: circle, error: circleError } = useGetCircleQuery({ circle_id: uuid[0] }) const { data: students, isLoading } = useGetCircleStudentsQuery({ circle_id: uuid[0], - or_search: createSearchTextForRequest(searchRequestText, searchColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchColumns), }) const { data: queryData } = useGetCurrentCircleQuery({ circle_id: uuid[0], organization_id: organizationId }) @@ -135,8 +136,8 @@ const CurrentCircle = () => { isLoading={isLoading} needNumbering={true} searchFields={['student_name', 'student_phone', 'parent_names', 'parent_phones']} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequestText(text)} />
diff --git a/apps/schools/domains/common/components/searchInput/index.tsx b/apps/schools/domains/common/components/searchInput/index.tsx index 93986b3c..054a158b 100644 --- a/apps/schools/domains/common/components/searchInput/index.tsx +++ b/apps/schools/domains/common/components/searchInput/index.tsx @@ -1,14 +1,15 @@ -import React, { useState, ChangeEvent } from 'react' +import React, { ChangeEvent } from 'react' import { Input } from '@domains/common/components/input' import { CloseCircleOutlined, SearchOutlined } from '@ant-design/icons' import styles from './styles/styles.module.scss' +import { useQueryState } from 'next-usequerystate' interface SearchInputProps { onSearchChange: (value: string) => void } const SearchInput: React.FC = ({ onSearchChange }) => { - const [inputText, setInputText] = useState('') + const [inputText, setInputText] = useQueryState('search') const handleInputChange = (event: ChangeEvent) => { const value = event.target.value @@ -21,7 +22,7 @@ const SearchInput: React.FC = ({ onSearchChange }) => { onChange={handleInputChange} customType={'inputSearch'} placeholder={'Поиск'} - value={inputText} + value={inputText || ''} children={ <> diff --git a/apps/schools/domains/common/components/table/interfaces.ts b/apps/schools/domains/common/components/table/interfaces.ts index 268282eb..332235ab 100644 --- a/apps/schools/domains/common/components/table/interfaces.ts +++ b/apps/schools/domains/common/components/table/interfaces.ts @@ -3,6 +3,7 @@ import { ReturnedData } from '@domains/common/redux/interfaces' import { TableProps } from 'antd' import { ColumnFilterItem } from 'antd/lib/table/interface' import { Key } from 'antd/es/table/interface' +import {Options} from "next-usequerystate"; export interface CustomFieldsProps { [key: string]: React.FC<{ @@ -30,7 +31,10 @@ export interface CustomTableProps extends TableProps customFields?: CustomFieldsProps searchRequestText: string needNumbering?: boolean - setSearchRequestText: React.Dispatch> + setSearchRequestText: ( + value: string | ((old: string | null) => string | null) | null, + options?: Options | undefined, + ) => Promise mainRoute: string sortFields?: string[] customFilterFields?: CustomFilterFieldsProps diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index 3e1176fa..b554fe46 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -95,9 +95,7 @@ export function QueryList() { const handleSearchChange = useCallback((value: string) => { setIsTableLoading(true) - setTimeout(() => { - setSearchRequest(value) - }, 1000) + setSearchRequest(value) }, []) return ( diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index f5af871a..633da4d0 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -14,15 +14,16 @@ import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' import { scrollToTop } from '@domains/common/utils/scrollInDirection' +import {useQueryState} from "next-usequerystate"; export function StudentList() { - const [searchRequestText, setSearchRequestText] = useState('') + const [searchRequestText, setSearchRequestText] = useQueryState('search') const { organizationId } = useOrganization() const { data: invites, isLoading: isLoadingInvites } = useGetAllStudentInvitationsQuery({ circle__organization__id: organizationId, status: StatusesEnum.SENT, - or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchInvitesColumns), }) const [paginationParams, setPaginationParams] = useState({ @@ -32,7 +33,7 @@ export function StudentList() { const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, - or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), page: paginationParams.page, page_size: paginationParams.pageSize, }) @@ -75,7 +76,7 @@ export function StudentList() { data={data} isLoading={isFetchingStudents || isLoadingInvites} handleRunTask={() => router.push(RoutePath[AppRoutes.STUDENT_CREATE])} - searchTrigger={searchRequestText} + searchTrigger={searchRequestText || ''} >
Обучающиеся @@ -113,8 +114,8 @@ export function StudentList() { isLoading={isLoadingInvites || isFetchingStudents} mainRoute={RoutePath[AppRoutes.STUDENT_LIST]} searchFields={['student_name', 'student_phone', 'parent_phone', 'circle_name']} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequestText(text)} /> ) diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 9f1e85c2..f74acbc3 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -93,15 +93,11 @@ export function TicketList() { if (typeof text === 'string') { setIsTableLoading(true) setInputText(text) - setTimeout(() => { - setSearchRequest(text) - }, 1000) + setSearchRequest(text) } else { setIsTableLoading(true) setInputText(text.target.value) - setTimeout(() => { - setSearchRequest(text.target.value) - }, 1000) + setSearchRequest(text.target.value) } }, [setIsTableLoading, setInputText, setSearchRequest], From 77cdc8be5555d2af2e6e8d18740d13e5f403be79 Mon Sep 17 00:00:00 2001 From: nenichv Date: Wed, 17 Jul 2024 11:12:48 +0500 Subject: [PATCH 30/44] fix conflict --- .../student/components/studentList/index.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index f035c9a2..619998ab 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react' +import React, { useCallback, useState } from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' @@ -17,6 +17,7 @@ import { scrollToTop } from '@domains/common/utils/scrollInDirection' import { handlePaginationChange } from '@domains/common/handlers/paginationChange' import { calculateResults } from '@domains/student/handlers/resultsCalculate' import { getTotalPages } from '@domains/common/utils/getTotalPages' +import { useQueryState } from "next-usequerystate" export function StudentList() { const [queryPaginationParams, setQueryPaginationParams] = useState({ @@ -30,20 +31,20 @@ export function StudentList() { }, }) - const [searchRequestText, setSearchRequestText] = useState('') + const [searchRequestText, setSearchRequestText] = useQueryState('search') const { organizationId } = useOrganization() const { data: invites, isLoading: isLoadingInvites } = useGetAllStudentInvitationsQuery({ circle__organization__id: organizationId, status: StatusesEnum.SENT, - or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchInvitesColumns), page: queryPaginationParams.invites.page, page_size: queryPaginationParams.invites.pageSize, }) const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, - or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), page: queryPaginationParams.students.page, page_size: queryPaginationParams.students.pageSize, }) @@ -90,7 +91,7 @@ export function StudentList() { data={data} isLoading={isFetchingStudents || isLoadingInvites} handleRunTask={() => router.push(RoutePath[AppRoutes.STUDENT_CREATE])} - searchTrigger={searchRequestText} + searchTrigger={searchRequestText || ''} >
Обучающиеся @@ -127,9 +128,9 @@ export function StudentList() { isLoading={isLoadingInvites || isFetchingStudents} mainRoute={RoutePath[AppRoutes.STUDENT_LIST]} searchFields={['student_name', 'student_phone', 'parent_phone', 'circle_name']} - searchRequestText={searchRequestText} - setSearchRequestText={setSearchRequestText} + searchRequestText={searchRequestText || ''} + setSearchRequestText={(text) => setSearchRequestText(text)} /> ) -} +} \ No newline at end of file From 3b4a6b578a430eb9c6bc1164920ecd4fea254e30 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:30:52 +0500 Subject: [PATCH 31/44] remove pagination --- .../circle/components/circleList/index.tsx | 19 ------- .../components/employeeList/index.tsx | 21 ------- .../organization/redux/organizationApi.ts | 8 +-- .../query/components/queryList/index.tsx | 19 ------- .../components/currentStudent/index.tsx | 3 +- .../student/components/studentList/index.tsx | 55 +------------------ .../components/studentList/interfaces.ts | 2 +- .../ticket/components/ticketList/index.tsx | 19 ------- 8 files changed, 9 insertions(+), 137 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 9c23ba0d..1daad16b 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -20,16 +20,9 @@ export function CircleList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() - const [paginationParams, setPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }) - const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: paginationParams.page, - page_size: paginationParams.pageSize, }) return ( @@ -60,18 +53,6 @@ export function CircleList() { ['Адрес', 'address'], ['Кол-во принятых заявок', 'accepted_count'], ]} - pagination={{ - current: paginationParams.page, - pageSize: paginationParams.pageSize, - total: circles?.count, - onChange: (page, pageSize) => { - setPaginationParams({ - page, - pageSize, - }) - scrollToTop() - }, - }} data={circles} isLoading={isFetching} mainRoute={RoutePath[AppRoutes.CIRCLE_LIST]} diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 7247578b..f804b134 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -11,23 +11,14 @@ import { GetListEmployee } from '@domains/employee/redux/interfaces' import { RowType } from '@domains/employee/components/employeeList/interfaces' import { searchColumns } from '@domains/employee/components/employeeList/constants' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' -import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' -import { scrollToTop } from '@domains/common/utils/scrollInDirection' export function EmployeeList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() - const [paginationParams, setPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }) - const { data, isFetching } = useGetAllEmployeesQuery({ organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchColumns), - page: paginationParams.page, - page_size: paginationParams.pageSize, }) return ( @@ -50,18 +41,6 @@ export function EmployeeList() { ['Должность', 'position'], ['Телефон', 'phone'], ]} - pagination={{ - current: paginationParams.page, - pageSize: paginationParams.pageSize, - total: data?.count, - onChange: (page, pageSize) => { - setPaginationParams({ - page, - pageSize, - }) - scrollToTop() - }, - }} data={data} isLoading={isFetching} mainRoute={RoutePath[AppRoutes.EMPLOYEE_LIST]} diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index 2307d8a5..bd63a421 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -65,7 +65,7 @@ const organizationApi = commonApi.injectEndpoints({ body: data, }), }), - getAllStudents: build.query, AllStudentsData>({ + getAllStudents: build.query, AllStudentsData>({ query: (params) => ({ url: '/organization-management/organizations/students', method: 'GET', @@ -73,7 +73,7 @@ const organizationApi = commonApi.injectEndpoints({ }), transformResponse: (response: ReturnedData) => { return mapReturnedData(response, (query) => { - const transformedQuery = structuredClone(query) as unknown as TableTypeStudent + const transformedQuery = structuredClone(query) transformedQuery.id = query.id transformedQuery.student_name = query.name transformedQuery.student_phone = query.student_profile.phone @@ -182,8 +182,8 @@ const organizationApi = commonApi.injectEndpoints({ }), transformResponse: (response: ReturnedData) => { return mapReturnedData(response, (query) => { - const transformedQuery = structuredClone(query) as unknown as TableTypeStudent - transformedQuery.id = query.body.id + const transformedQuery = structuredClone(query) + transformedQuery.id = query.body.id || '' transformedQuery.student_name = query.body.name transformedQuery.student_phone = query.additional.phone transformedQuery.parent_phone = query.recipient.parent_phones.replaceAll(',', '\n') diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index e8153aff..cb0a8ad6 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -70,16 +70,9 @@ export function QueryList() { return items }, [analytics, statuses]) - const [paginationParams, setPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }) - const { data: queries, isFetching: isQueriesFetching } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: paginationParams.page, - page_size: paginationParams.pageSize, }) const countAllQueries = useMemo( @@ -129,18 +122,6 @@ export function QueryList() { ['Телефон родителя', 'parent_phone'], ['Кружок', 'circle_name'], ]} - pagination={{ - current: paginationParams.page, - pageSize: paginationParams.pageSize, - total: queries?.count, - onChange: (page, pageSize) => { - setPaginationParams({ - page, - pageSize, - }) - scrollToTop() - }, - }} data={queries} isLoading={isQueriesFetching} mainRoute={RoutePath[AppRoutes.QUERY_LIST]} diff --git a/apps/schools/domains/student/components/currentStudent/index.tsx b/apps/schools/domains/student/components/currentStudent/index.tsx index 63640f14..adb5121c 100644 --- a/apps/schools/domains/student/components/currentStudent/index.tsx +++ b/apps/schools/domains/student/components/currentStudent/index.tsx @@ -15,11 +15,12 @@ import { Field } from '@domains/common/components/field' import { useDeleteStudentMutation } from '@domains/student/redux/studentApi' import { ActionBar } from '@domains/common/components/stickyBlock/actionBar' import DeleteModal from '@domains/common/components/deleteModal' -import { GetStudent } from '@domains/common/redux/serializers' +import { GetCircleInviteStudent, GetStudent } from '@domains/common/redux/serializers' import { useOrganization } from '@domains/organization/providers/organizationProvider' import parentAcceptedPhone from '@public/icons/parentAcceptedMobile.svg' import parentDeclinedPhone from '@public/icons/parentDeclinedMobile.svg' import { AppRoutes, DynamicAppRoutes, DynamicRoutePath, RoutePath } from '@domains/common/constants/routerEnums' +import { ReturnedData } from '@domains/common/redux/interfaces' const CurrentStudent = () => { const [isModalVisible, setIsModalVisible] = useState(false) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index f035c9a2..32d1e10d 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -17,19 +17,9 @@ import { scrollToTop } from '@domains/common/utils/scrollInDirection' import { handlePaginationChange } from '@domains/common/handlers/paginationChange' import { calculateResults } from '@domains/student/handlers/resultsCalculate' import { getTotalPages } from '@domains/common/utils/getTotalPages' +import { ReturnedData } from '@domains/common/redux/interfaces' export function StudentList() { - const [queryPaginationParams, setQueryPaginationParams] = useState({ - invites: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - students: { - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }, - }) - const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() @@ -37,48 +27,18 @@ export function StudentList() { circle__organization__id: organizationId, status: StatusesEnum.SENT, or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), - page: queryPaginationParams.invites.page, - page_size: queryPaginationParams.invites.pageSize, }) const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: queryPaginationParams.students.page, - page_size: queryPaginationParams.students.pageSize, - }) - - const [paginationParams, setPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, }) - const resultsCalculate = useCallback( - () => calculateResults(paginationParams, { invites, students }), - [paginationParams, invites, students], - ) - const data = { count: (invites?.count ?? 0) + (students?.count ?? 0), next: invites?.next ?? '', previous: invites?.previous ?? '', - results: resultsCalculate(), - } - - const handlePageChange = (newPage: number, newPageSize: number) => { - handlePaginationChange( - setPaginationParams, - setQueryPaginationParams as any, - { - invites: invites?.count, - students: students?.count, - }, - newPage, - newPageSize, - defaultPaginationTablePage, - defaultPaginationTablePageSize, - scrollToTop, - ) + results: [...((invites?.results ?? []) as unknown as TableType[]), ...(students?.results ?? [])], } return ( @@ -111,17 +71,6 @@ export function StudentList() { ['Телефон обучающегося', 'student_phone'], ['Телефон родителя', 'parent_phone'], ]} - pagination={{ - current: paginationParams.page, - pageSize: paginationParams.pageSize, - total: getTotalPages( - { invites: { count: invites?.count }, students: { count: students?.count } }, - paginationParams.pageSize, - ), - onChange: (page, pageSize) => { - handlePageChange(page, pageSize) - }, - }} filterFields={['circle_name']} data={data} isLoading={isLoadingInvites || isFetchingStudents} diff --git a/apps/schools/domains/student/components/studentList/interfaces.ts b/apps/schools/domains/student/components/studentList/interfaces.ts index 36c22cb9..0ba393b7 100644 --- a/apps/schools/domains/student/components/studentList/interfaces.ts +++ b/apps/schools/domains/student/components/studentList/interfaces.ts @@ -7,7 +7,7 @@ export interface RowType { } export interface TableType { - id?: string + id: string student_name: string student_phone: string parent_phone: string diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index c8fbfc49..319a9099 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -70,16 +70,9 @@ export function TicketList() { } as BubbleFilterListItem } - const [paginationParams, setPaginationParams] = useState({ - page: defaultPaginationTablePage, - pageSize: defaultPaginationTablePageSize, - }) - const { data: tickets, isFetching: isTicketsFetching } = useGetAllTicketsQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), - page: paginationParams.page, - page_size: paginationParams.pageSize, }) useEffect(() => { @@ -132,18 +125,6 @@ export function TicketList() {
loading={isTableLoading} - pagination={{ - current: paginationParams.page, - pageSize: paginationParams.pageSize, - total: tickets?.count, - onChange: (page, pageSize) => { - setPaginationParams({ - page, - pageSize, - }) - scrollToTop() - }, - }} customType={'tableWithoutSearch'} columnsTitlesAndKeys={[ ['Создано', 'created_at'], From 148bf242e915a0d34f6806c27bc65abe754d061a Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:31:18 +0500 Subject: [PATCH 32/44] prettier --- .../user/components/profile/profileEdit/index.tsx | 4 ++-- .../user/components/profile/profileInfo/index.tsx | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/schools/domains/user/components/profile/profileEdit/index.tsx b/apps/schools/domains/user/components/profile/profileEdit/index.tsx index bfb1756e..7ccfc3da 100644 --- a/apps/schools/domains/user/components/profile/profileEdit/index.tsx +++ b/apps/schools/domains/user/components/profile/profileEdit/index.tsx @@ -63,7 +63,7 @@ export function ProfileEdit() { required={true} label={ - * Ф.И.О. + * Ф.И.О. } name={USER_NAME} @@ -78,7 +78,7 @@ export function ProfileEdit() { required={true} label={ - * Email сотрудника + * Email сотрудника } name={USER_EMAIL} diff --git a/apps/schools/domains/user/components/profile/profileInfo/index.tsx b/apps/schools/domains/user/components/profile/profileInfo/index.tsx index 78e0a7b7..1c8f00ab 100644 --- a/apps/schools/domains/user/components/profile/profileInfo/index.tsx +++ b/apps/schools/domains/user/components/profile/profileInfo/index.tsx @@ -40,11 +40,7 @@ export function ProfileInfo() { ) : ( results.data?.results.map((employee) => (
- + router.push(RoutePath[AppRoutes.USER_EDIT])}> + From ac6bb70b07a73ade01bbfc6d298ad62fa8b5f8fe Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:35:30 +0500 Subject: [PATCH 33/44] fix warnings --- .../domains/circle/components/circleList/index.tsx | 2 -- apps/schools/domains/query/components/queryList/index.tsx | 2 -- .../domains/student/components/currentStudent/index.tsx | 3 +-- .../domains/student/components/studentList/index.tsx | 8 +------- .../domains/ticket/components/ticketList/index.tsx | 2 -- 5 files changed, 2 insertions(+), 15 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 1daad16b..f87fe06b 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -13,8 +13,6 @@ import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' import { HighlightText } from '@domains/common/components/table/forming' import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' -import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' -import { scrollToTop } from '@domains/common/utils/scrollInDirection' export function CircleList() { const [searchRequestText, setSearchRequestText] = useState('') diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index cb0a8ad6..87f3016c 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -20,8 +20,6 @@ import { useQueryState } from 'next-usequerystate' import { parseAsArrayOf, parseAsString } from 'next-usequerystate' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' import SearchInput from '@domains/common/components/searchInput' -import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' -import { scrollToTop } from '@domains/common/utils/scrollInDirection' export function QueryList() { const { organizationId } = useOrganization() diff --git a/apps/schools/domains/student/components/currentStudent/index.tsx b/apps/schools/domains/student/components/currentStudent/index.tsx index adb5121c..63640f14 100644 --- a/apps/schools/domains/student/components/currentStudent/index.tsx +++ b/apps/schools/domains/student/components/currentStudent/index.tsx @@ -15,12 +15,11 @@ import { Field } from '@domains/common/components/field' import { useDeleteStudentMutation } from '@domains/student/redux/studentApi' import { ActionBar } from '@domains/common/components/stickyBlock/actionBar' import DeleteModal from '@domains/common/components/deleteModal' -import { GetCircleInviteStudent, GetStudent } from '@domains/common/redux/serializers' +import { GetStudent } from '@domains/common/redux/serializers' import { useOrganization } from '@domains/organization/providers/organizationProvider' import parentAcceptedPhone from '@public/icons/parentAcceptedMobile.svg' import parentDeclinedPhone from '@public/icons/parentDeclinedMobile.svg' import { AppRoutes, DynamicAppRoutes, DynamicRoutePath, RoutePath } from '@domains/common/constants/routerEnums' -import { ReturnedData } from '@domains/common/redux/interfaces' const CurrentStudent = () => { const [isModalVisible, setIsModalVisible] = useState(false) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 32d1e10d..ee1e9543 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react' +import React, { useState } from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' @@ -12,12 +12,6 @@ import { useGetAllStudentInvitationsQuery, useGetAllStudentsQuery } from '@domai import { StatusesEnum } from '@domains/common/constants/Enums' import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' -import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' -import { scrollToTop } from '@domains/common/utils/scrollInDirection' -import { handlePaginationChange } from '@domains/common/handlers/paginationChange' -import { calculateResults } from '@domains/student/handlers/resultsCalculate' -import { getTotalPages } from '@domains/common/utils/getTotalPages' -import { ReturnedData } from '@domains/common/redux/interfaces' export function StudentList() { const [searchRequestText, setSearchRequestText] = useState('') diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 319a9099..3f3c6b8e 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -19,8 +19,6 @@ import Image from 'next/image' import dot from '@public/icons/dot.svg' import SearchInput from '@domains/common/components/searchInput' import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface' -import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' -import { scrollToTop } from '@domains/common/utils/scrollInDirection' type HandleInputChange = (text: React.ChangeEvent | string) => void type HandleChange = ( From 146e42744be88824c9d0f12aca87986e4cec623a Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:44:19 +0500 Subject: [PATCH 34/44] Translate antd into Russian --- apps/schools/pages/_app.tsx | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/schools/pages/_app.tsx b/apps/schools/pages/_app.tsx index e474bc22..71ee6594 100644 --- a/apps/schools/pages/_app.tsx +++ b/apps/schools/pages/_app.tsx @@ -10,7 +10,8 @@ import Head from 'next/head' import { OrganizationProvider } from '@domains/organization/providers/organizationProvider' import { BaseLayout } from '@domains/common/components/containers/BaseLayoutComponents/BaseLayout' import { LayoutContextProvider } from '@domains/user/providers/baseLayoutProvider' -import { message } from 'antd' +import { ConfigProvider, message } from 'antd' +import ru_RU from 'antd/lib/locale/ru_RU' import { EventBusProvider } from '@domains/common/providers/eventBusProvider' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' @@ -49,17 +50,19 @@ function MyApp({ Component, pageProps }: CustomAppProps): JSX.Element { - - - - Открытые школы - - - - - - - + + + + + Открытые школы + + + + + + + + From 0915ffcefe3e9e9cab9c48935291884b68b067ce Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:44:38 +0500 Subject: [PATCH 35/44] prettier --- .../user/components/profile/profileEdit/index.tsx | 4 ++-- .../user/components/profile/profileInfo/index.tsx | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/schools/domains/user/components/profile/profileEdit/index.tsx b/apps/schools/domains/user/components/profile/profileEdit/index.tsx index bfb1756e..7ccfc3da 100644 --- a/apps/schools/domains/user/components/profile/profileEdit/index.tsx +++ b/apps/schools/domains/user/components/profile/profileEdit/index.tsx @@ -63,7 +63,7 @@ export function ProfileEdit() { required={true} label={ - * Ф.И.О. + * Ф.И.О. } name={USER_NAME} @@ -78,7 +78,7 @@ export function ProfileEdit() { required={true} label={ - * Email сотрудника + * Email сотрудника } name={USER_EMAIL} diff --git a/apps/schools/domains/user/components/profile/profileInfo/index.tsx b/apps/schools/domains/user/components/profile/profileInfo/index.tsx index 78e0a7b7..1c8f00ab 100644 --- a/apps/schools/domains/user/components/profile/profileInfo/index.tsx +++ b/apps/schools/domains/user/components/profile/profileInfo/index.tsx @@ -40,11 +40,7 @@ export function ProfileInfo() { ) : ( results.data?.results.map((employee) => (
- + router.push(RoutePath[AppRoutes.USER_EDIT])}> + From 74750c84328760e80a0133817fff4c74b580a744 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:26:38 +0500 Subject: [PATCH 36/44] prettier --- .../domains/circle/components/circleList/index.tsx | 6 +++--- .../domains/circle/components/currentCircle/index.tsx | 2 +- apps/schools/domains/common/components/table/index.tsx | 2 +- .../schools/domains/common/components/table/interfaces.ts | 2 +- .../domains/employee/components/employeeList/index.tsx | 4 ++-- apps/schools/domains/query/components/queryList/index.tsx | 2 +- .../domains/student/components/studentList/index.tsx | 4 ++-- .../domains/ticket/components/ticketList/index.tsx | 8 ++++---- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 8a9d24e7..72321657 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -13,15 +13,15 @@ import EmptyWrapper from '@domains/common/components/containers/EmptyWrapper' import { HighlightText } from '@domains/common/components/table/forming' import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' -import { useQueryState } from "next-usequerystate"; +import { useQueryState } from 'next-usequerystate' export function CircleList() { const [searchRequestText, setSearchRequestText] = useQueryState('search') const { organizationId } = useOrganization() const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ - organization_id: organizationId, - or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), + organization_id: organizationId, + or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns), }) return ( diff --git a/apps/schools/domains/circle/components/currentCircle/index.tsx b/apps/schools/domains/circle/components/currentCircle/index.tsx index bb89ebfd..dd0398c2 100644 --- a/apps/schools/domains/circle/components/currentCircle/index.tsx +++ b/apps/schools/domains/circle/components/currentCircle/index.tsx @@ -25,7 +25,7 @@ import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { StatusesEnum } from '@domains/common/constants/Enums' import { ErrorType } from '@store/commonApi' import { AppRoutes, DynamicAppRoutes, DynamicRoutePath, RoutePath } from '@domains/common/constants/routerEnums' -import {useQueryState} from "next-usequerystate"; +import { useQueryState } from 'next-usequerystate' const CurrentCircle = () => { const [isModalVisible, setIsModalVisible] = useState(false) diff --git a/apps/schools/domains/common/components/table/index.tsx b/apps/schools/domains/common/components/table/index.tsx index 108f962e..f01e598b 100644 --- a/apps/schools/domains/common/components/table/index.tsx +++ b/apps/schools/domains/common/components/table/index.tsx @@ -9,7 +9,7 @@ import { typeTable } from '@domains/common/constants/Table' import { CustomTableProps } from '@domains/common/components/table/interfaces' import { calculateAverageWidth } from '@domains/common/utils/calculateAverageWidth' import { ColumnType } from 'antd/lib/table/interface' -import { useQueryState } from "next-usequerystate"; +import { useQueryState } from 'next-usequerystate' export const Table = (props: CustomTableProps) => { const { diff --git a/apps/schools/domains/common/components/table/interfaces.ts b/apps/schools/domains/common/components/table/interfaces.ts index 332235ab..54ba112b 100644 --- a/apps/schools/domains/common/components/table/interfaces.ts +++ b/apps/schools/domains/common/components/table/interfaces.ts @@ -3,7 +3,7 @@ import { ReturnedData } from '@domains/common/redux/interfaces' import { TableProps } from 'antd' import { ColumnFilterItem } from 'antd/lib/table/interface' import { Key } from 'antd/es/table/interface' -import {Options} from "next-usequerystate"; +import { Options } from 'next-usequerystate' export interface CustomFieldsProps { [key: string]: React.FC<{ diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 43c0c900..5024dec1 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -15,12 +15,12 @@ import { useQueryState } from 'next-usequerystate' import { scrollToTop } from '@domains/common/utils/scrollInDirection' export function EmployeeList() { - const [searchRequest, setSearchRequest] = useQueryState('search') + const [searchRequest, setSearchRequest] = useQueryState('search') const { organizationId } = useOrganization() const { data, isFetching } = useGetAllEmployeesQuery({ organization: organizationId, - or_search: createSearchTextForRequest(searchRequest || '', searchColumns), + or_search: createSearchTextForRequest(searchRequest || '', searchColumns), }) return ( diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index 5f82f32d..61be9087 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -70,7 +70,7 @@ export function QueryList() { const { data: queries, isFetching: isQueriesFetching } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, - or_search: createSearchTextForRequest(searchRequest || '', searchStudentsColumns) + or_search: createSearchTextForRequest(searchRequest || '', searchStudentsColumns), }) const countAllQueries = useMemo( diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index fa14028f..e64a9ac1 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -17,10 +17,10 @@ import { scrollToTop } from '@domains/common/utils/scrollInDirection' import { handlePaginationChange } from '@domains/common/handlers/paginationChange' import { calculateResults } from '@domains/student/handlers/resultsCalculate' import { getTotalPages } from '@domains/common/utils/getTotalPages' -import { useQueryState } from "next-usequerystate" +import { useQueryState } from 'next-usequerystate' export function StudentList() { - const [searchRequestText, setSearchRequestText] = useQueryState('search') + const [searchRequestText, setSearchRequestText] = useQueryState('search') const { organizationId } = useOrganization() const { data: invites, isLoading: isLoadingInvites } = useGetAllStudentInvitationsQuery({ diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 3f12e7b7..595f0cd7 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -29,10 +29,10 @@ type HandleChange = ( ) => void export function TicketList() { - const [inputText, setInputText] = useState('') - const [isTableLoading, setIsTableLoading] = useState(false) - const { organizationId } = useOrganization() - const [searchRequest, setSearchRequest] = useQueryState('search') + const [inputText, setInputText] = useState('') + const [isTableLoading, setIsTableLoading] = useState(false) + const { organizationId } = useOrganization() + const [searchRequest, setSearchRequest] = useQueryState('search') const [statuses, setStatuses] = useQueryState( 'statuses', From c0fd3ffc10f15a207c58660b386b27664259b628 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:10:23 +0500 Subject: [PATCH 37/44] add 500 errorCode in middleware --- apps/schools/store/middlewares.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/schools/store/middlewares.ts b/apps/schools/store/middlewares.ts index 26ab2c8c..a698e4c0 100644 --- a/apps/schools/store/middlewares.ts +++ b/apps/schools/store/middlewares.ts @@ -23,6 +23,7 @@ const errorCodes: ErrorCodes = { 403: 'Недостаточно прав для выполнения операции. Обратитесь к администратору для получения необходимых разрешений', 404: 'Объект не найден. Пожалуйста, убедитесь, что указанный ресурс существует и повторите запрос', 429: 'Слишком много попыток. Пожалуйста, подождите некоторое время и повторите запрос позже', + 500: 'Сервер обнаружил внутреннюю ошибку и не смог выполнить запрос. Пожалуйста, повторите попытку позже', } interface Action { From 49089ffac9e345f6ec7c722deb801e10ec04758b Mon Sep 17 00:00:00 2001 From: zavarin-michael Date: Fri, 23 Aug 2024 12:38:22 +0500 Subject: [PATCH 38/44] trying to fix build error in transformResponse --- apps/schools/domains/organization/redux/organizationApi.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index bd63a421..4c9563fa 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -73,7 +73,7 @@ const organizationApi = commonApi.injectEndpoints({ }), transformResponse: (response: ReturnedData) => { return mapReturnedData(response, (query) => { - const transformedQuery = structuredClone(query) + const transformedQuery = structuredClone(query) as unknown as TableTypeStudent transformedQuery.id = query.id transformedQuery.student_name = query.name transformedQuery.student_phone = query.student_profile.phone @@ -182,7 +182,7 @@ const organizationApi = commonApi.injectEndpoints({ }), transformResponse: (response: ReturnedData) => { return mapReturnedData(response, (query) => { - const transformedQuery = structuredClone(query) + const transformedQuery = structuredClone(query) as unknown as TableTypeStudent transformedQuery.id = query.body.id || '' transformedQuery.student_name = query.body.name transformedQuery.student_phone = query.additional.phone From 94925d4da5f1372ded0e8b8fa52f120770e7053e Mon Sep 17 00:00:00 2001 From: zavarin-michael Date: Fri, 23 Aug 2024 13:02:49 +0500 Subject: [PATCH 39/44] add NODE_OPTIONS=--max-old-space-size=4096 --- apps/schools/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/package.json b/apps/schools/package.json index d0cebe1c..07a0de0e 100644 --- a/apps/schools/package.json +++ b/apps/schools/package.json @@ -10,7 +10,7 @@ "dev": "npm run open-browser && next dev", "dev:console": "next dev", "open-browser": "start http://localhost:3000", - "build": "next build", + "build": "set NODE_OPTIONS=--max-old-space-size=4096 && next build", "start": "next start", "test": "jest -c test/jest.config.js", "cypress:open": "cypress open", From 2e08ef69419fad0a7c34867062e6880c679e4ed9 Mon Sep 17 00:00:00 2001 From: zavarin-michael Date: Fri, 23 Aug 2024 13:14:55 +0500 Subject: [PATCH 40/44] changed NODE_OPTIONS to --max-old-space-size=16384 --- apps/schools/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/package.json b/apps/schools/package.json index 07a0de0e..0f116302 100644 --- a/apps/schools/package.json +++ b/apps/schools/package.json @@ -10,7 +10,7 @@ "dev": "npm run open-browser && next dev", "dev:console": "next dev", "open-browser": "start http://localhost:3000", - "build": "set NODE_OPTIONS=--max-old-space-size=4096 && next build", + "build": "set NODE_OPTIONS=--max-old-space-size=16384 && next build", "start": "next start", "test": "jest -c test/jest.config.js", "cypress:open": "cypress open", From 5222c9d94e74d0ec2a6d62592f48fa50b449b487 Mon Sep 17 00:00:00 2001 From: zavarin-michael Date: Fri, 23 Aug 2024 13:41:24 +0500 Subject: [PATCH 41/44] deleted from package.json NODE_OPTIONS but added to Dockerfile --- apps/schools/dev.Dockerfile | 1 + apps/schools/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/schools/dev.Dockerfile b/apps/schools/dev.Dockerfile index 1f20126f..a526c560 100644 --- a/apps/schools/dev.Dockerfile +++ b/apps/schools/dev.Dockerfile @@ -2,6 +2,7 @@ FROM node:18-alpine AS runner RUN node -v +ENV NODE_OPTIONS="--max-old-space-size=4096" ENV NODE_TLS_REJECT_UNAUTHORIZED=0 ENV NODE_ENV production ENV NEXT_TELEMETRY_DISABLED 1 diff --git a/apps/schools/package.json b/apps/schools/package.json index 0f116302..d0cebe1c 100644 --- a/apps/schools/package.json +++ b/apps/schools/package.json @@ -10,7 +10,7 @@ "dev": "npm run open-browser && next dev", "dev:console": "next dev", "open-browser": "start http://localhost:3000", - "build": "set NODE_OPTIONS=--max-old-space-size=16384 && next build", + "build": "next build", "start": "next start", "test": "jest -c test/jest.config.js", "cypress:open": "cypress open", From 1f476a2b7750883ff9f7d7afdd104c1f3a26a2c4 Mon Sep 17 00:00:00 2001 From: zavarin-michael Date: Fri, 23 Aug 2024 13:51:35 +0500 Subject: [PATCH 42/44] added NODE_OPTIONS to prod Dockerfile --- apps/schools/prod.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/schools/prod.Dockerfile b/apps/schools/prod.Dockerfile index 1f20126f..a526c560 100644 --- a/apps/schools/prod.Dockerfile +++ b/apps/schools/prod.Dockerfile @@ -2,6 +2,7 @@ FROM node:18-alpine AS runner RUN node -v +ENV NODE_OPTIONS="--max-old-space-size=4096" ENV NODE_TLS_REJECT_UNAUTHORIZED=0 ENV NODE_ENV production ENV NEXT_TELEMETRY_DISABLED 1 From bcc914cc7e49b317d444a7f382e47cbc7582d0f3 Mon Sep 17 00:00:00 2001 From: zavarin-michael Date: Mon, 26 Aug 2024 14:58:59 +0500 Subject: [PATCH 43/44] small fixes in registration --- .../domains/user/components/auth/registerForm/index.tsx | 6 ++++-- apps/schools/domains/user/handlers/auth/register.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 2bd20dd7..43967535 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -36,8 +36,10 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const registerComplete = useCallback(() => { const { password } = form.getFieldsValue(['password']) - registrationHandler(phone, password, userRegistration, onError, form).then(async () => { - await getLazyUser({}) + registrationHandler(phone, password, userRegistration, onError, form).then(async (response) => { + if (!('error' in response)) { + await getLazyUser({}) + } }) }, [form, signInByPhone, getLazyUser]) diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index 356a3ef0..f237cff9 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -109,6 +109,7 @@ export async function registrationHandler( }, ]) } + return response } export async function resendOtpHandler(recaptchaToken: string, resendOtpMutation: any, onError: () => void) { From fe9cbeb4fcccc26cdb12f83c5a4c6e941bb31fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <33755295+zavarin-michael@users.noreply.github.com> Date: Thu, 29 Aug 2024 13:29:32 +0500 Subject: [PATCH 44/44] add new invalidate tag User and perform router push only after employee profile update --- .../domains/employee/redux/employeeApi.ts | 2 +- .../components/auth/registerForm/index.tsx | 3 +-- .../components/profile/profileEdit/index.tsx | 3 --- .../domains/user/providers/authProvider.tsx | 12 +---------- .../domains/user/redux/authenticationApi.ts | 4 ++++ apps/schools/domains/user/redux/userApi.ts | 1 + apps/schools/pages/auth/register.tsx | 21 ++++++++----------- apps/schools/store/commonApi.ts | 11 +++++++++- 8 files changed, 27 insertions(+), 30 deletions(-) diff --git a/apps/schools/domains/employee/redux/employeeApi.ts b/apps/schools/domains/employee/redux/employeeApi.ts index bb3cd859..a494c846 100644 --- a/apps/schools/domains/employee/redux/employeeApi.ts +++ b/apps/schools/domains/employee/redux/employeeApi.ts @@ -44,7 +44,7 @@ const employeeApi = commonApi.injectEndpoints({ method: 'PATCH', body: data, }), - invalidatesTags: ['Employee'], + invalidatesTags: ['Employee', 'User'], }), deleteEmployeeById: build.mutation<{}, DeleteEmployeeByIdData>({ query: (data) => ({ diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 43967535..2dd9d6c4 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -53,8 +53,7 @@ export const RegisterForm: React.FC = ({ onFinish, onError } name: name, email: email, } - updateProfile(updateEmail) - onFinish() + updateProfile(updateEmail).then(() => onFinish()) } }, [data, updateProfile]) diff --git a/apps/schools/domains/user/components/profile/profileEdit/index.tsx b/apps/schools/domains/user/components/profile/profileEdit/index.tsx index 7ccfc3da..3b0f27f2 100644 --- a/apps/schools/domains/user/components/profile/profileEdit/index.tsx +++ b/apps/schools/domains/user/components/profile/profileEdit/index.tsx @@ -13,11 +13,9 @@ import Link from 'next/link' import { useChangeUserProfileFormValidators } from '@domains/user/components/profile/profileEdit/hooks' import { useUpdateEmployeeProfileByIdMutation } from '@domains/employee/redux/employeeApi' import { handleSubmitForm } from '@domains/user/handlers/profile/profileEdit' -import { EventKey, useEventBus } from '@domains/common/providers/eventBusProvider' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' export function ProfileEdit() { - const { emit } = useEventBus() const { user } = useUserProfile() const [form] = Form.useForm() @@ -52,7 +50,6 @@ export function ProfileEdit() { onFinish={() => { handleSubmitForm(user.employee_profile?.id ?? '', form, mutation).then((isSuccess) => { if (isSuccess) { - emit(EventKey.RefetchProfileQuery) router.push(RoutePath[AppRoutes.USER_LIST]) } }) diff --git a/apps/schools/domains/user/providers/authProvider.tsx b/apps/schools/domains/user/providers/authProvider.tsx index ff942eed..996a3623 100644 --- a/apps/schools/domains/user/providers/authProvider.tsx +++ b/apps/schools/domains/user/providers/authProvider.tsx @@ -3,7 +3,6 @@ import { useRouter } from 'next/router' import { useGetUserQuery } from '../redux/authenticationApi' import Cookies from 'universal-cookie' import { GetUserProfiles } from '@domains/user/redux/interfaces' -import { EventKey, useEventBus } from '@domains/common/providers/eventBusProvider' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' export const UserProfileContext = createContext<{ @@ -24,18 +23,13 @@ export const useUserProfile = () => useContext(UserProfileContext) export const AuthProvider: React.FC = ({ children }) => { const router = useRouter() - const { on } = useEventBus() const [token, setToken] = useState('') const [user, setUser] = useState({}) - const { data, error, refetch } = useGetUserQuery({}) + const { data, error } = useGetUserQuery({}) const cookies = new Cookies() useEffect(() => { - const unsubscribeOnRefetchProfileQuery = on(EventKey.RefetchProfileQuery, () => { - refetch() - }) - if (router.pathname === RoutePath[AppRoutes.MOBILE_RECAPTCHA]) return const jwtToken = typeof window !== 'undefined' ? cookies.get('jwtToken') : null @@ -45,10 +39,6 @@ export const AuthProvider: React.FC = ({ children }) => { } else { router.push(RoutePath[AppRoutes.AUTH_SIGN_IN]) } - - return () => { - unsubscribeOnRefetchProfileQuery() - } }, []) useEffect(() => { diff --git a/apps/schools/domains/user/redux/authenticationApi.ts b/apps/schools/domains/user/redux/authenticationApi.ts index 8ecc265d..02038d89 100644 --- a/apps/schools/domains/user/redux/authenticationApi.ts +++ b/apps/schools/domains/user/redux/authenticationApi.ts @@ -9,6 +9,7 @@ const authenticationApi = commonApi.injectEndpoints({ method: 'POST', body: data, }), + invalidatesTags: ['User'], }), logout: build.mutation<{}, {}>({ query: (data) => ({ @@ -16,6 +17,7 @@ const authenticationApi = commonApi.injectEndpoints({ method: 'POST', body: data, }), + invalidatesTags: ['User'], }), getUser: build.query<{ user: GetUserProfiles }, {}>({ query: (data) => ({ @@ -23,6 +25,7 @@ const authenticationApi = commonApi.injectEndpoints({ method: 'GET', data: data, }), + providesTags: ['User'], }), updateUser: build.mutation<{ user: GetUser }, UpdateUserData>({ query: (data) => ({ @@ -30,6 +33,7 @@ const authenticationApi = commonApi.injectEndpoints({ method: 'PATCH', body: data, }), + invalidatesTags: ['User'], }), updatePassword: build.mutation<{}, UpdatePasswordData>({ query: (data) => ({ diff --git a/apps/schools/domains/user/redux/userApi.ts b/apps/schools/domains/user/redux/userApi.ts index f5463a82..2cd03145 100644 --- a/apps/schools/domains/user/redux/userApi.ts +++ b/apps/schools/domains/user/redux/userApi.ts @@ -19,6 +19,7 @@ const userApi = commonApi.injectEndpoints({ method: 'POST', body: data, }), + invalidatesTags: ['User'], }), resetPassword: build.mutation<{}, PasswordReset>({ query: (data) => ({ diff --git a/apps/schools/pages/auth/register.tsx b/apps/schools/pages/auth/register.tsx index 887bc244..88de9f5e 100644 --- a/apps/schools/pages/auth/register.tsx +++ b/apps/schools/pages/auth/register.tsx @@ -5,18 +5,15 @@ import React, { useState } from 'react' import { Dictionary } from '@reduxjs/toolkit' import { ContainerPage } from '../_app' import AuthLayout, { IAuthLayoutProps } from '../../domains/user/components/auth/containers/AuthLayout' -import { FormContainer } from '../../domains/user/components/auth/formContainer' -import { InputPhoneForm } from '../../domains/user/components/auth/sharedForms/InputPhoneForm' -import { TabsAuthAction } from '../../domains/user/components/auth/headerActions' -import { ValidatePhoneForm } from '../../domains/user/components/auth/sharedForms/ValidatePhoneForm' -import { RegisterForm } from '../../domains/user/components/auth/registerForm' -import { CENTRALIZED } from '../../domains/common/components/styles/constantStyles' +import { FormContainer } from '@domains/user/components/auth/formContainer' +import { InputPhoneForm } from '@domains/user/components/auth/sharedForms/InputPhoneForm' +import { TabsAuthAction } from '@domains/user/components/auth/headerActions' +import { ValidatePhoneForm } from '@domains/user/components/auth/sharedForms/ValidatePhoneForm' +import { RegisterForm } from '@domains/user/components/auth/registerForm' +import { CENTRALIZED } from '@domains/common/components/styles/constantStyles' import { Row } from 'antd' -import { - RegistrationDisclaimer, - RegistrationPhoneButtonLabel, -} from '../../domains/user/components/auth/constants/labels' -import { FirebaseReCaptcha } from '../../domains/user/providers/firebaseReCaptchaProvider' +import { RegistrationDisclaimer, RegistrationPhoneButtonLabel } from '@domains/user/components/auth/constants/labels' +import { FirebaseReCaptcha } from '@domains/user/providers/firebaseReCaptchaProvider' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' const RegisterPage: ContainerPage = (props) => { @@ -56,7 +53,7 @@ const RegisterPage: ContainerPage = (props) => { <> (window.location.href = '/')} + onFinish={() => Router.push(RoutePath[AppRoutes.USER_LIST])} onError={() => { setStep('inputPhone') Router.push(RoutePath[AppRoutes.AUTH_REGISTER]) diff --git a/apps/schools/store/commonApi.ts b/apps/schools/store/commonApi.ts index 257c4acb..908a4fff 100644 --- a/apps/schools/store/commonApi.ts +++ b/apps/schools/store/commonApi.ts @@ -43,6 +43,15 @@ export const commonApi = createApi({ return headers }, }) as BaseQueryFn, - tagTypes: ['Circle', 'Student', 'StudentJoinCircleQuery', 'Organization', 'Employee', 'Ticket', 'TicketComments'], + tagTypes: [ + 'Circle', + 'Student', + 'StudentJoinCircleQuery', + 'Organization', + 'Employee', + 'Ticket', + 'TicketComments', + 'User', + ], endpoints: (_) => ({}), })