From 7fba951b8374aba212c294f897c4d9d1d6af5441 Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 13 Jun 2024 14:18:34 +0500 Subject: [PATCH 01/37] fix field name --- .../domains/user/components/auth/registerForm/index.tsx | 6 +++++- apps/schools/domains/user/handlers/auth/register.ts | 7 ++++++- 2 files changed, 11 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 4cb4b579..35e2bfd9 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,6 +11,8 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import { useUsersMutation } from '@domains/user/redux/userApi' +import {PARENT_EMAIL, STUDENT_PHONE} from "@domains/student/components/createStudentForm/constants"; +import {USER_EMAIL} from "@domains/user/components/profile/profileEdit/constants"; const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
@@ -78,7 +80,9 @@ export const RegisterForm: React.FC = ({ onFinish, onError } data-cy='register-email-item' validateFirst > - + diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index 17542557..00150722 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -85,9 +85,14 @@ export async function registrationHandler( let token = localStorage.getItem('token') const cookies = new Cookies() cookies.remove('jwtToken') + + const { email } = formComponent.getFieldsValue(['email']); + const { name } = formComponent.getFieldsValue(['name']); + let response = await withLoadingMessage(LoadingMsg, userRegistrationMutation, { token: token, - name: phone, + name: name, + email: email, password: password, }) if (!('error' in response)) { From fa070ceef8a7a0052d24d48fa84cc85ec5265f03 Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 13 Jun 2024 14:19:10 +0500 Subject: [PATCH 02/37] fix field name --- .../schools/domains/user/components/auth/registerForm/index.tsx | 2 -- 1 file changed, 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 35e2bfd9..abda09a5 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,8 +11,6 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import { useUsersMutation } from '@domains/user/redux/userApi' -import {PARENT_EMAIL, STUDENT_PHONE} from "@domains/student/components/createStudentForm/constants"; -import {USER_EMAIL} from "@domains/user/components/profile/profileEdit/constants"; const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
From 41188d8a48c4ff5c23dd7dc0be0460699d9e302c Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 13 Jun 2024 15:01:59 +0500 Subject: [PATCH 03/37] add function send email after success (not work) --- .../user/components/auth/registerForm/index.tsx | 6 ++++-- .../schools/domains/user/handlers/auth/register.ts | 14 ++++++++++++++ 2 files changed, 18 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 abda09a5..7dfd8982 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -27,10 +27,11 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { signInByPhone } = /*useContext(AuthLayoutContext)*/ { signInByPhone: () => {}, } + const [sendEmail] = useUsersMutation(); const registerComplete = useCallback(async () => { const { password } = form.getFieldsValue(['password']) - registrationHandler(phone, password, userRegistration, onFinish, onError, form) + await registrationHandler(phone, password, userRegistration, onFinish, onError, form, sendEmail) }, [form, signInByPhone]) const initialValues = { phone } @@ -80,7 +81,8 @@ export const RegisterForm: React.FC = ({ onFinish, onError } > + placeholder={'email@example.com'} + /> diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index 00150722..109436db 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -21,6 +21,8 @@ export async function tokenHandler( registrationMutation: any, onFinish: () => void, ) { + console.log(formComponent.getFieldsValue()) + if (recaptchaToken === '') return let { phone: inputPhone } = formComponent.getFieldsValue(['phone']) @@ -74,6 +76,15 @@ export async function otpHandler( } } +export async function sendEmail(token: string, email: string, sendEmailMutation: any) { + let response = await sendEmailMutation({ token, email }); + if (!('error' in response)) { + message.success("Email successfully sent."); + } else { + message.error("Failed to send email."); + } +} + export async function registrationHandler( phone: string, password: string, @@ -81,6 +92,7 @@ export async function registrationHandler( onFinish: () => void, onError: () => void, formComponent: FormInstance, + sendEmailMutation: any ) { let token = localStorage.getItem('token') const cookies = new Cookies() @@ -98,6 +110,8 @@ export async function registrationHandler( if (!('error' in response)) { cookies.set('jwtToken', response.data.token, { path: '/' }) message.success(SuccessRegistrationMsg) + const { email } = formComponent.getFieldsValue(['email']); + await sendEmail(response.data.token, email, sendEmailMutation); onFinish() } else if (response.error?.status === 401) { message.error(PleaseReloadPageMsg) From 7c983e2936fbbe384a32929133d02c9a94403c28 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:02:16 +0500 Subject: [PATCH 04/37] moved the reformattedData to transformResponse --- .../circle/components/circleList/index.tsx | 8 +--- .../components/circleList/interfaces.ts | 2 +- .../circle/components/currentCircle/index.tsx | 12 +----- .../schools/domains/circle/redux/circleApi.ts | 19 ++++++++- .../organization/redux/organizationApi.ts | 41 ++++++++++++++++++- .../query/components/queryList/index.tsx | 16 +------- .../ticket/components/ticketList/index.tsx | 17 ++------ 7 files changed, 66 insertions(+), 49 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 83b7faaf..7abbf2ef 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -24,12 +24,6 @@ export function CircleList() { or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), }) - const reformattedData = mapReturnedData(circles, (circle) => { - const transformedCircle = structuredClone(circle) as unknown as TableType - transformedCircle.accepted_count = circle.student_profile_queries.ACCEPTED - return transformedCircle - }) - return ( { CANCELED: 0, } - const reformattedData = mapReturnedData(students, (student) => { - const transformedCircle = structuredClone(student) as unknown as CurrentCircleRowType - transformedCircle.id = student.id - transformedCircle.student_name = student.name - transformedCircle.student_phone = student.student_profile.phone - transformedCircle.parent_names = student.student_profile.parent_names?.replaceAll(',', ',\n') - transformedCircle.parent_phones = student.student_profile.parent_phones?.replaceAll(',', '\n') - return transformedCircle - }) - const countAllQueries = sumObjectValues(queriesCount) const addressVars = getVarsForAddressColumn(circle?.circle.address ?? '') @@ -141,7 +131,7 @@ const CurrentCircle = () => { ['Ф. И. О родителя', 'parent_names'], ['Телефон родителя', 'parent_phones'], ]} - data={reformattedData} + data={students} mainRoute={RoutePath[AppRoutes.STUDENT_LIST]} isLoading={isLoading} needNumbering={true} diff --git a/apps/schools/domains/circle/redux/circleApi.ts b/apps/schools/domains/circle/redux/circleApi.ts index c4fb8c49..02e3e3b2 100644 --- a/apps/schools/domains/circle/redux/circleApi.ts +++ b/apps/schools/domains/circle/redux/circleApi.ts @@ -9,6 +9,9 @@ import { ChangeCircleData, } from './interfaces' import { GetCircle, GetQueryStatus, GetStudent } from '@domains/common/redux/serializers' +import { BaseQueryMeta, BaseQueryResult } from '@reduxjs/toolkit/dist/query/baseQueryTypes' +import { mapReturnedData } from '@domains/common/redux/utils' +import { CurrentCircleRowType } from '@domains/circle/components/currentCircle/interfaces' const circleApi = commonApi.injectEndpoints({ endpoints: (build) => ({ @@ -43,12 +46,26 @@ const circleApi = commonApi.injectEndpoints({ }), providesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }], }), - getCircleStudents: build.query, CircleStudentsData>({ + getCircleStudents: build.query, CircleStudentsData>({ query: (params) => ({ url: `/organization-management/circles/${params.circle_id}/students`, method: 'GET', params: params, }), + transformResponse: (response: ReturnedData) => { + return mapReturnedData(response, (student: GetStudent) => { + return { + ...student, + student_name: student.name, + student_profile: { + ...student.student_profile, + phone: student.student_profile.phone, + parent_names: student.student_profile.parent_names, + parent_phones: student.student_profile.parent_phones, + }, + } + })! + }, providesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }], }), deleteCircle: build.mutation<{ circle: GetCircle }, CircleData>({ diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index 2a4e2af2..298cd1d6 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -33,6 +33,11 @@ import { UpdateOrganizationInviteEmployee, } from '@domains/common/redux/serializers' import { GetTicket, GetTicketData, GetTicketsData } from '@domains/ticket/redux/serializers' +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 { useMemo } from 'react' const organizationApi = commonApi.injectEndpoints({ endpoints: (build) => ({ @@ -68,12 +73,19 @@ const organizationApi = commonApi.injectEndpoints({ }), providesTags: (result) => providesList(result?.results, 'Student'), }), - getAllCircles: build.query, GetOrganizationCircleListData>({ + getAllCircles: build.query, GetOrganizationCircleListData>({ query: (params) => ({ url: `/organization-management/organizations/${params.organization_id}/circles`, method: 'GET', params: params, }), + transformResponse: (response: ReturnedData) => { + return mapReturnedData(response, (circle) => { + const transformedCircle = structuredClone(circle) as unknown as TableTypeCircle + transformedCircle.accepted_count = circle.student_profile_queries.ACCEPTED + return transformedCircle + })! + }, providesTags: (result) => providesList(result?.results, 'Circle'), }), getCurrentCircle: build.query<{ circle: GetOrganizationCircleList }, GetCurrentCircleData>({ @@ -165,6 +177,20 @@ const organizationApi = commonApi.injectEndpoints({ method: 'GET', params: params, }), + transformResponse: (response: ReturnedData) => { + return useMemo( + () => + mapReturnedData(response, (query) => { + const transformedQuery = structuredClone(query) as unknown as TableTypeQuery + transformedQuery.parent_name = query.additional.parent_name + transformedQuery.parent_phone = query.additional.parent_phone + transformedQuery.circle_name = query.recipient.name + transformedQuery.student_name = query.body.name + return transformedQuery + }), + [response], + )! + }, providesTags: (result) => providesList(result?.results, 'StudentJoinCircleQuery'), }), getOrganizationAnalytics: build.query<{ analytics: GetAnalytics }, GetAnalyticsData>({ @@ -189,6 +215,19 @@ const organizationApi = commonApi.injectEndpoints({ method: 'GET', params: params, }), + transformResponse: (response: ReturnedData) => { + return mapReturnedData(response, (query) => { + return { + ...query, + content: query.last_comment.value, + sender: 'Семья ' + query.sender?.name, + contentTrimmed: + query.last_comment.value.length > 200 + ? query.last_comment.value.slice(0, 200) + '…' + : query.last_comment.value, + } as TableTypeTickets + })! + }, providesTags: ['Ticket'], }), getTicket: build.query<{ ticket: GetTicket }, GetTicketData>({ diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index e466a7b7..e88897d8 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -11,7 +11,6 @@ import { useGetOrganizationAnalyticsQuery, } 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 { isReactElement } from '@domains/common/utils/react' import { sumObjectValues } from '@domains/common/utils/sumObjectValues' @@ -79,19 +78,6 @@ export function QueryList() { [analytics, isAnalyticsLoading], ) - const reformattedData = useMemo( - () => - mapReturnedData(queries, (query) => { - const transformedQuery = structuredClone(query) as unknown as TableType - transformedQuery.parent_name = query.additional.parent_name - transformedQuery.parent_phone = query.additional.parent_phone - transformedQuery.circle_name = query.recipient.name - transformedQuery.student_name = query.body.name - return transformedQuery - }), - [queries], - ) - useEffect(() => { if (!isQueriesLoading && queries) { setIsTableLoading(false) @@ -130,7 +116,7 @@ export function QueryList() { ['Телефон родителя', 'parent_phone'], ['Кружок', 'circle_name'], ]} - data={reformattedData} + data={queries} isLoading={isQueriesLoading} mainRoute={RoutePath[AppRoutes.QUERY_LIST]} searchFields={[ diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 163a6a14..e6c70866 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -20,6 +20,8 @@ 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 { ReturnedData } from '@domains/common/redux/interfaces' +import { GetTicket } from '@domains/ticket/redux/serializers' type HandleInputChange = (text: React.ChangeEvent | string) => void type HandleChange = ( @@ -74,16 +76,6 @@ export function TicketList() { or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), }) - const reformattedData = mapReturnedData(tickets, (query) => { - const transformedQuery = structuredClone(query) as unknown as TableType - transformedQuery.content = query.last_comment.value - if (transformedQuery.content.length > 200) { - transformedQuery.content = transformedQuery.content.slice(0, 200) + '…' - } - transformedQuery.sender = 'Семья ' + query.sender?.name - return transformedQuery - }) - useEffect(() => { if (!isTicketsLoading) { setIsTableLoading(false) @@ -142,7 +134,7 @@ export function TicketList() { ['Отправитель', 'sender'], ]} customWidths={[10, 10, 40, 30]} - data={reformattedData} + data={tickets as ReturnedData} isLoading={isTicketsLoading} mainRoute={RoutePath[AppRoutes.TICKETS_LIST]} searchFields={['created_at', 'content', 'sender']} @@ -158,12 +150,11 @@ export function TicketList() { return (
- {reformattedData?.results[index].unread_sender_comments_count > 0 && ( + {parseInt(tickets?.results[index]?.unread_sender_comments_count ?? '0') > 0 && (
{'Unread
)} -
From e7d30dd974b6cb4b38572f1aacd1cec13de22a08 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:02:47 +0500 Subject: [PATCH 05/37] prettier --- .../domains/user/components/profile/profileEdit/hooks.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/user/components/profile/profileEdit/hooks.ts b/apps/schools/domains/user/components/profile/profileEdit/hooks.ts index 6ba350f6..20c0d407 100644 --- a/apps/schools/domains/user/components/profile/profileEdit/hooks.ts +++ b/apps/schools/domains/user/components/profile/profileEdit/hooks.ts @@ -1,9 +1,10 @@ import { useMemo } from 'react' import { ValidatorsMap } from '@domains/common/redux/interfaces' import { - PersonNameMustContainMsg, PersonNameMustNotStartOrAndMsg, + PersonNameMustContainMsg, + PersonNameMustNotStartOrAndMsg, PleaseInputYourEmailMsg, - PleaseInputYourNameMsg + PleaseInputYourNameMsg, } from '@domains/user/components/auth/constants/message' import { getGreaterValidator } from '@domains/common/utils/validators' import { USER_EMAIL, USER_NAME } from '@domains/user/components/profile/profileEdit/constants' From c540842bdbdd3a3e7d4cfa5ce272623e8f1e7df3 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:10:01 +0500 Subject: [PATCH 06/37] fix middleware bug --- .../organization/redux/organizationApi.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index 298cd1d6..b4646cca 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -178,18 +178,14 @@ const organizationApi = commonApi.injectEndpoints({ params: params, }), transformResponse: (response: ReturnedData) => { - return useMemo( - () => - mapReturnedData(response, (query) => { - const transformedQuery = structuredClone(query) as unknown as TableTypeQuery - transformedQuery.parent_name = query.additional.parent_name - transformedQuery.parent_phone = query.additional.parent_phone - transformedQuery.circle_name = query.recipient.name - transformedQuery.student_name = query.body.name - return transformedQuery - }), - [response], - )! + return mapReturnedData(response, (query) => { + const transformedQuery = structuredClone(query) as unknown as TableTypeQuery + transformedQuery.parent_name = query.additional.parent_name + transformedQuery.parent_phone = query.additional.parent_phone + transformedQuery.circle_name = query.recipient.name + transformedQuery.student_name = query.body.name + return transformedQuery + })! }, providesTags: (result) => providesList(result?.results, 'StudentJoinCircleQuery'), }), From d5cfb37f0347ba3727baeea428243be091d00b10 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:08:59 +0500 Subject: [PATCH 07/37] fix CurrentCircleTableType and search bug in ticketList --- .../domains/circle/components/currentCircle/index.tsx | 5 ++--- .../circle/components/currentCircle/interfaces.ts | 10 +++++++++- apps/schools/domains/circle/redux/circleApi.ts | 5 ++--- .../domains/organization/redux/organizationApi.ts | 3 +-- .../domains/ticket/components/ticketList/index.tsx | 11 ++++------- .../ticket/components/ticketList/interfaces.ts | 1 + 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/schools/domains/circle/components/currentCircle/index.tsx b/apps/schools/domains/circle/components/currentCircle/index.tsx index 625f3602..48cbcb25 100644 --- a/apps/schools/domains/circle/components/currentCircle/index.tsx +++ b/apps/schools/domains/circle/components/currentCircle/index.tsx @@ -13,14 +13,13 @@ import { useOrganization } from '@domains/organization/providers/organizationPro import { CARD_HEAD_STYLE } from '@domains/circle/components/currentCircle/styles/styles' import { Table } from '@domains/common/components/table' import { createSearchTextForRequest } from '@domains/common/utils/searchText' -import { mapReturnedData } from '@domains/common/redux/utils' import { ActionBar } from '@domains/common/components/stickyBlock/actionBar' import { sumObjectValues } from '@domains/common/utils/sumObjectValues' import android from '@public/image/Android.svg' import { searchColumns } from './constants' -import { CurrentCircleRowType } from './interfaces' +import { RowType, TableType } from './interfaces' import styles from './styles/styles.module.scss' import { getVarsForAddressColumn } from '@domains/common/utils/geo' import { StatusesEnum } from '@domains/common/constants/Enums' @@ -124,7 +123,7 @@ const CurrentCircle = () => {
- + columnsTitlesAndKeys={[ ['Ф. И. О обучающегося', 'student_name'], ['Телефон обучающегося', 'student_phone'], diff --git a/apps/schools/domains/circle/components/currentCircle/interfaces.ts b/apps/schools/domains/circle/components/currentCircle/interfaces.ts index 04ae9bf0..18b1f49c 100644 --- a/apps/schools/domains/circle/components/currentCircle/interfaces.ts +++ b/apps/schools/domains/circle/components/currentCircle/interfaces.ts @@ -1,4 +1,12 @@ -export interface CurrentCircleRowType { +export interface RowType { + id?: string + student_name: string + student_phone?: string + parent_names?: string + parent_phones?: string +} + +export interface TableType { id?: string student_name: string student_phone?: string diff --git a/apps/schools/domains/circle/redux/circleApi.ts b/apps/schools/domains/circle/redux/circleApi.ts index 02e3e3b2..ca8fab83 100644 --- a/apps/schools/domains/circle/redux/circleApi.ts +++ b/apps/schools/domains/circle/redux/circleApi.ts @@ -9,9 +9,8 @@ import { ChangeCircleData, } from './interfaces' import { GetCircle, GetQueryStatus, GetStudent } from '@domains/common/redux/serializers' -import { BaseQueryMeta, BaseQueryResult } from '@reduxjs/toolkit/dist/query/baseQueryTypes' import { mapReturnedData } from '@domains/common/redux/utils' -import { CurrentCircleRowType } from '@domains/circle/components/currentCircle/interfaces' +import { TableType as CurrentCircleTableType } from '@domains/circle/components/currentCircle/interfaces' const circleApi = commonApi.injectEndpoints({ endpoints: (build) => ({ @@ -46,7 +45,7 @@ const circleApi = commonApi.injectEndpoints({ }), providesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }], }), - getCircleStudents: build.query, CircleStudentsData>({ + getCircleStudents: build.query, CircleStudentsData>({ query: (params) => ({ url: `/organization-management/circles/${params.circle_id}/students`, method: 'GET', diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index b4646cca..c2c3233b 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -37,7 +37,6 @@ 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 { useMemo } from 'react' const organizationApi = commonApi.injectEndpoints({ endpoints: (build) => ({ @@ -205,7 +204,7 @@ const organizationApi = commonApi.injectEndpoints({ }), providesTags: ['Ticket'], }), - getAllTickets: build.query, GetTicketsData>({ + getAllTickets: build.query, GetTicketsData>({ query: (params) => ({ url: `/organization-management/organizations/${params.organization_id}/family-tickets`, method: 'GET', diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index e6c70866..1c53f668 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -8,7 +8,6 @@ import { RowType, TableType } from './interfaces' import { searchTicketsColumns, StatusDictionary } from './constants' import { useGetAllTicketsQuery, useGetTicketsAnalyticsQuery } 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 { isReactElement } from '@domains/common/utils/react' import { BubbleFilter } from '@domains/common/components/bubbleFilter' @@ -20,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 { ReturnedData } from '@domains/common/redux/interfaces' -import { GetTicket } from '@domains/ticket/redux/serializers' type HandleInputChange = (text: React.ChangeEvent | string) => void type HandleChange = ( @@ -44,7 +41,7 @@ export function TicketList() { }), ) - const { data: analytics, isLoading: isAnalyticsLoading } = useGetTicketsAnalyticsQuery({ + const { data: analytics } = useGetTicketsAnalyticsQuery({ organization_id: organizationId, }) @@ -77,10 +74,10 @@ export function TicketList() { }) useEffect(() => { - if (!isTicketsLoading) { + if (!isTicketsLoading && tickets) { setIsTableLoading(false) } - }, [isTicketsLoading]) + }, [isTicketsLoading, tickets]) const handleInputChange: HandleInputChange = useCallback( (text) => { @@ -134,7 +131,7 @@ export function TicketList() { ['Отправитель', 'sender'], ]} customWidths={[10, 10, 40, 30]} - data={tickets as ReturnedData} + data={tickets} isLoading={isTicketsLoading} mainRoute={RoutePath[AppRoutes.TICKETS_LIST]} searchFields={['created_at', 'content', 'sender']} diff --git a/apps/schools/domains/ticket/components/ticketList/interfaces.ts b/apps/schools/domains/ticket/components/ticketList/interfaces.ts index 23ecccc0..4a3c0fe3 100644 --- a/apps/schools/domains/ticket/components/ticketList/interfaces.ts +++ b/apps/schools/domains/ticket/components/ticketList/interfaces.ts @@ -12,4 +12,5 @@ export interface TableType { status?: string content?: string sender?: string + unread_sender_comments_count?: string } From fbc88b0aa7fe10671b31daedbd7f7ade4175c4bc Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:10:42 +0500 Subject: [PATCH 08/37] rename TableTypeCurrentCircle --- apps/schools/domains/circle/redux/circleApi.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/circle/redux/circleApi.ts b/apps/schools/domains/circle/redux/circleApi.ts index ca8fab83..f2a16777 100644 --- a/apps/schools/domains/circle/redux/circleApi.ts +++ b/apps/schools/domains/circle/redux/circleApi.ts @@ -10,7 +10,7 @@ import { } from './interfaces' import { GetCircle, GetQueryStatus, GetStudent } from '@domains/common/redux/serializers' import { mapReturnedData } from '@domains/common/redux/utils' -import { TableType as CurrentCircleTableType } from '@domains/circle/components/currentCircle/interfaces' +import { TableType as TableTypeCurrentCircle } from '@domains/circle/components/currentCircle/interfaces' const circleApi = commonApi.injectEndpoints({ endpoints: (build) => ({ @@ -45,7 +45,7 @@ const circleApi = commonApi.injectEndpoints({ }), providesTags: (result, error, arg) => [{ type: 'Circle', id: arg.circle_id }], }), - getCircleStudents: build.query, CircleStudentsData>({ + getCircleStudents: build.query, CircleStudentsData>({ query: (params) => ({ url: `/organization-management/circles/${params.circle_id}/students`, method: 'GET', From b06e4352036e5b195274cfa4d4d41e42e2df740e Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:34:27 +0500 Subject: [PATCH 09/37] del parseInt --- apps/schools/domains/ticket/components/ticketList/index.tsx | 2 +- apps/schools/domains/ticket/components/ticketList/interfaces.ts | 2 +- apps/schools/domains/ticket/redux/serializers.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 1c53f668..95159982 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -147,7 +147,7 @@ export function TicketList() { return (
- {parseInt(tickets?.results[index]?.unread_sender_comments_count ?? '0') > 0 && ( + {(tickets?.results[index] as TableType).unread_sender_comments_count > 0 && (
{'Unread
diff --git a/apps/schools/domains/ticket/components/ticketList/interfaces.ts b/apps/schools/domains/ticket/components/ticketList/interfaces.ts index 4a3c0fe3..b5a81bce 100644 --- a/apps/schools/domains/ticket/components/ticketList/interfaces.ts +++ b/apps/schools/domains/ticket/components/ticketList/interfaces.ts @@ -12,5 +12,5 @@ export interface TableType { status?: string content?: string sender?: string - unread_sender_comments_count?: string + unread_sender_comments_count: number } diff --git a/apps/schools/domains/ticket/redux/serializers.ts b/apps/schools/domains/ticket/redux/serializers.ts index c8b9edc7..2290bbc9 100644 --- a/apps/schools/domains/ticket/redux/serializers.ts +++ b/apps/schools/domains/ticket/redux/serializers.ts @@ -6,7 +6,7 @@ export interface GetTicket { last_comment: GetTicketComment recipient: GetOrganization created_at: string - unread_sender_comments_count?: string + unread_sender_comments_count: number unread_recipient_comments_count?: string sender?: GetFamily status?: QueriesTypes From 071585bedc088f93d983bee88b5465b10d447a22 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: Fri, 14 Jun 2024 12:52:56 +0500 Subject: [PATCH 10/37] family name fix in ticket list --- apps/schools/domains/organization/redux/organizationApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/organization/redux/organizationApi.ts b/apps/schools/domains/organization/redux/organizationApi.ts index c2c3233b..6dcafe3d 100644 --- a/apps/schools/domains/organization/redux/organizationApi.ts +++ b/apps/schools/domains/organization/redux/organizationApi.ts @@ -215,7 +215,7 @@ const organizationApi = commonApi.injectEndpoints({ return { ...query, content: query.last_comment.value, - sender: 'Семья ' + query.sender?.name, + sender: query.sender?.name, contentTrimmed: query.last_comment.value.length > 200 ? query.last_comment.value.slice(0, 200) + '…' From 094379f397c264ee3e009bf275efeb605fb46536 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: Fri, 14 Jun 2024 13:20:50 +0500 Subject: [PATCH 11/37] fix name of column --- apps/schools/domains/ticket/components/ticketList/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 95159982..cfb048fc 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() { ['Создано', 'created_at'], ['Статус', 'status'], ['Содержание', 'content'], - ['Отправитель', 'sender'], + ['Семья', 'sender'], ]} customWidths={[10, 10, 40, 30]} data={tickets} From 6792aea758eb652095532391ba2e70f67a4f1149 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: Fri, 14 Jun 2024 14:36:34 +0500 Subject: [PATCH 12/37] add expires value for all set cookie methods in project --- apps/schools/domains/common/constants/Cookies.ts | 1 + .../domains/user/components/auth/containers/PopupCookie.tsx | 3 ++- apps/schools/domains/user/handlers/auth/register.ts | 3 ++- apps/schools/domains/user/handlers/auth/signin.ts | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 apps/schools/domains/common/constants/Cookies.ts diff --git a/apps/schools/domains/common/constants/Cookies.ts b/apps/schools/domains/common/constants/Cookies.ts new file mode 100644 index 00000000..407e93b0 --- /dev/null +++ b/apps/schools/domains/common/constants/Cookies.ts @@ -0,0 +1 @@ +export const oneYearExpiresDate = new Date(Date.now() + 60 * 60 * 24 * 365 * 1000); diff --git a/apps/schools/domains/user/components/auth/containers/PopupCookie.tsx b/apps/schools/domains/user/components/auth/containers/PopupCookie.tsx index a93dcc70..11c89f04 100644 --- a/apps/schools/domains/user/components/auth/containers/PopupCookie.tsx +++ b/apps/schools/domains/user/components/auth/containers/PopupCookie.tsx @@ -7,6 +7,7 @@ import { Button } from '@domains/common/components/button' import { Typography } from 'antd' import Cookie from 'universal-cookie' import { COOKIE_AGREEMENT_KEY } from '@domains/user/components/auth/constants/variables' +import { oneYearExpiresDate } from '@domains/common/constants/Cookies' export const PopupCookie = () => { const cookies = new Cookie() @@ -15,7 +16,7 @@ export const PopupCookie = () => { const [cookiesNotAccepted, setCookiesNotAccepted] = useState(true) const acceptCookieAgreement = useCallback(() => { - cookies.set(COOKIE_AGREEMENT_KEY, 'true') + cookies.set(COOKIE_AGREEMENT_KEY, 'true', { expires: oneYearExpiresDate }) setCookiesNotAccepted(false) setIsShown(false) }, []) diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index 17542557..5e6fa4c9 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -13,6 +13,7 @@ import { import { withLoadingMessage } from '@domains/common/utils/loading' import Cookies from 'universal-cookie' import { AppRoutes, RoutePath } from '@domains/common/constants/routerEnums' +import { oneYearExpiresDate } from '@domains/common/constants/Cookies' export async function tokenHandler( recaptchaToken: string, @@ -91,7 +92,7 @@ export async function registrationHandler( password: password, }) if (!('error' in response)) { - cookies.set('jwtToken', response.data.token, { path: '/' }) + cookies.set('jwtToken', response.data.token, { path: '/', expires: oneYearExpiresDate }) message.success(SuccessRegistrationMsg) onFinish() } else if (response.error?.status === 401) { diff --git a/apps/schools/domains/user/handlers/auth/signin.ts b/apps/schools/domains/user/handlers/auth/signin.ts index d62be8f3..77fc79dd 100644 --- a/apps/schools/domains/user/handlers/auth/signin.ts +++ b/apps/schools/domains/user/handlers/auth/signin.ts @@ -2,6 +2,7 @@ import { FormInstance, message } from 'antd' import { LoadingMsg, SuccessSignInMsg, WrongLoginOrPasswordMsg } from '@domains/user/components/auth/constants/message' import { withLoadingMessage } from '@domains/common/utils/loading' import Cookies from 'universal-cookie' +import { oneYearExpiresDate } from '@domains/common/constants/Cookies' export async function loginHandler(phone: string, password: string, login: any, formComponent: FormInstance) { const cookies = new Cookies() @@ -11,7 +12,7 @@ export async function loginHandler(phone: string, password: string, login: any, password: password, }) if ('data' in response) { - cookies.set('jwtToken', response.data.token, { path: '/' }) + cookies.set('jwtToken', response.data.token, { path: '/', expires: oneYearExpiresDate }) message.success(SuccessSignInMsg) window.location.href = '/' } else if (response.error?.data.error.message.indexOf('non_field_errors') >= 0) { From db43ff62528e50e581277a6de2dfd3daf2be80ac Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 14 Jun 2024 15:34:58 +0500 Subject: [PATCH 13/37] add mutation for send email --- .../components/auth/registerForm/index.tsx | 18 ++++++++++++++---- apps/schools/domains/user/redux/userApi.ts | 9 ++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 7dfd8982..20d4568a 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -10,7 +10,7 @@ import { IRegisterFormProps } from './interfaces' import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' -import { useUsersMutation } from '@domains/user/redux/userApi' +import {useSendEmailMutation, useUsersMutation} from '@domains/user/redux/userApi' const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
@@ -27,12 +27,22 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { signInByPhone } = /*useContext(AuthLayoutContext)*/ { signInByPhone: () => {}, } - const [sendEmail] = useUsersMutation(); + const [sendEmail] = useSendEmailMutation(); const registerComplete = useCallback(async () => { - const { password } = form.getFieldsValue(['password']) + const { password, email } = form.getFieldsValue(['password', 'email']); await registrationHandler(phone, password, userRegistration, onFinish, onError, form, sendEmail) - }, [form, signInByPhone]) + .then(() => { + sendEmail({ + variables: { + email: email + } + }); + }) + .catch((error) => { + console.error(error); + }); + }, [form, signInByPhone, sendEmail]); const initialValues = { phone } diff --git a/apps/schools/domains/user/redux/userApi.ts b/apps/schools/domains/user/redux/userApi.ts index f5463a82..66f5eba5 100644 --- a/apps/schools/domains/user/redux/userApi.ts +++ b/apps/schools/domains/user/redux/userApi.ts @@ -54,8 +54,15 @@ const userApi = commonApi.injectEndpoints({ body: { otp: data.otp }, }), }), + sendEmail: build.mutation<{}, {}>({ + query: (data) => ({ + url: '/organization-management/employees/employee-profile', + method: 'POST', + body: data, + }), + }), }), }) -export const { useTokenMutation, useVerifyMutation, useUsersMutation, useResetPasswordMutation, useResendMutation } = +export const { useTokenMutation, useVerifyMutation, useUsersMutation, useResetPasswordMutation, useResendMutation, useSendEmailMutation} = userApi From 15a4c1e6af3cd7b1052de34f524ff802c5ebd260 Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 14:09:19 +0500 Subject: [PATCH 14/37] delete unnecessary code --- .../components/auth/registerForm/index.tsx | 24 +++++++------------ apps/schools/domains/user/redux/userApi.ts | 11 ++------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 20d4568a..ce342ea5 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -10,7 +10,8 @@ import { IRegisterFormProps } from './interfaces' import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' -import {useSendEmailMutation, useUsersMutation} from '@domains/user/redux/userApi' +import {useUsersMutation} from '@domains/user/redux/userApi' +import {useUserProfile} from "@domains/user/providers/authProvider"; const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
@@ -27,24 +28,17 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { signInByPhone } = /*useContext(AuthLayoutContext)*/ { signInByPhone: () => {}, } - const [sendEmail] = useSendEmailMutation(); + const { user } = useUserProfile(); const registerComplete = useCallback(async () => { - const { password, email } = form.getFieldsValue(['password', 'email']); + const { password } = form.getFieldsValue(['password']); + await registrationHandler(phone, password, userRegistration, onFinish, onError, form, sendEmail) - .then(() => { - sendEmail({ - variables: { - email: email - } - }); - }) - .catch((error) => { - console.error(error); - }); - }, [form, signInByPhone, sendEmail]); + }, [form, signInByPhone]); - const initialValues = { phone } + const initialValues = { + phone + } return (
({ - query: (data) => ({ - url: '/organization-management/employees/employee-profile', - method: 'POST', - body: data, - }), - }), + }) }), }) -export const { useTokenMutation, useVerifyMutation, useUsersMutation, useResetPasswordMutation, useResendMutation, useSendEmailMutation} = +export const { useTokenMutation, useVerifyMutation, useUsersMutation, useResetPasswordMutation, useResendMutation} = userApi From fa55eea036a5f26b067ac050ae9e8d6135a8bdfc Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 14:09:53 +0500 Subject: [PATCH 15/37] delete unnecessary code --- .../schools/domains/user/components/auth/registerForm/index.tsx | 2 -- 1 file changed, 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 ce342ea5..29f04615 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,7 +11,6 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import {useUsersMutation} from '@domains/user/redux/userApi' -import {useUserProfile} from "@domains/user/providers/authProvider"; const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
@@ -28,7 +27,6 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { signInByPhone } = /*useContext(AuthLayoutContext)*/ { signInByPhone: () => {}, } - const { user } = useUserProfile(); const registerComplete = useCallback(async () => { const { password } = form.getFieldsValue(['password']); From e6f8b6dff4743664e918901ec7d78a887d6b1273 Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 14:13:39 +0500 Subject: [PATCH 16/37] delete unnecessary code --- .../user/components/auth/registerForm/index.tsx | 2 +- .../schools/domains/user/handlers/auth/register.ts | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 29f04615..90287051 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -31,7 +31,7 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const registerComplete = useCallback(async () => { const { password } = form.getFieldsValue(['password']); - await registrationHandler(phone, password, userRegistration, onFinish, onError, form, sendEmail) + await registrationHandler(phone, password, userRegistration, onFinish, onError, form) }, [form, signInByPhone]); const initialValues = { diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index 109436db..25f7fa02 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -76,23 +76,13 @@ export async function otpHandler( } } -export async function sendEmail(token: string, email: string, sendEmailMutation: any) { - let response = await sendEmailMutation({ token, email }); - if (!('error' in response)) { - message.success("Email successfully sent."); - } else { - message.error("Failed to send email."); - } -} - export async function registrationHandler( phone: string, password: string, userRegistrationMutation: any, onFinish: () => void, onError: () => void, - formComponent: FormInstance, - sendEmailMutation: any + formComponent: FormInstance ) { let token = localStorage.getItem('token') const cookies = new Cookies() @@ -110,8 +100,6 @@ export async function registrationHandler( if (!('error' in response)) { cookies.set('jwtToken', response.data.token, { path: '/' }) message.success(SuccessRegistrationMsg) - const { email } = formComponent.getFieldsValue(['email']); - await sendEmail(response.data.token, email, sendEmailMutation); onFinish() } else if (response.error?.status === 401) { message.error(PleaseReloadPageMsg) From 61cacaa214451bf518ad30d7e0c8f70c0d30630f Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:48:18 +0500 Subject: [PATCH 17/37] add pagination --- .../circle/components/circleList/index.tsx | 14 ++++++++++++++ .../employee/components/employeeList/index.tsx | 16 +++++++++++++++- .../domains/query/components/queryList/index.tsx | 14 ++++++++++++++ .../student/components/studentList/index.tsx | 14 ++++++++++++++ .../ticket/components/ticketList/index.tsx | 16 +++++++++++++++- 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 7abbf2ef..c3231c5c 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -19,9 +19,14 @@ export function CircleList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() + const [page, setPage] = useState(1) + const [pageSize, setPageSize] = useState(10) + const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + page, + page_size: pageSize, }) return ( @@ -52,6 +57,15 @@ export function CircleList() { ['Адрес', 'address'], ['Кол-во принятых заявок', 'accepted_count'], ]} + pagination={{ + current: page, + pageSize: pageSize, + total: circles?.count, + onChange: (page, pageSize) => { + setPage(page) + setPageSize(pageSize) + }, + }} 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 9aaccc0e..f9815f5a 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, { useCallback, useState } from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' @@ -16,9 +16,14 @@ export function EmployeeList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() + const [page, setPage] = useState(1) + const [pageSize, setPageSize] = useState(10) + const { data, isLoading } = useGetAllEmployeesQuery({ organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchColumns), + page, + page_size: pageSize, }) return ( @@ -41,6 +46,15 @@ export function EmployeeList() { ['Должность', 'position'], ['Телефон', 'phone'], ]} + pagination={{ + current: page, + pageSize: pageSize, + total: data?.count, + onChange: (page, pageSize) => { + setPage(page) + setPageSize(pageSize) + }, + }} data={data} isLoading={isLoading} mainRoute={RoutePath[AppRoutes.EMPLOYEE_LIST]} diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index e88897d8..fe9ef874 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -68,9 +68,14 @@ export function QueryList() { return items }, [analytics, statuses]) + const [page, setPage] = useState(1) + const [pageSize, setPageSize] = useState(10) + const { data: queries, isLoading: isQueriesLoading } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + page, + page_size: pageSize, }) const countAllQueries = useMemo( @@ -116,6 +121,15 @@ export function QueryList() { ['Телефон родителя', 'parent_phone'], ['Кружок', 'circle_name'], ]} + pagination={{ + current: page, + pageSize: pageSize, + total: queries?.count, + onChange: (page, pageSize) => { + setPage(page) + setPageSize(pageSize) + }, + }} data={queries} isLoading={isQueriesLoading} mainRoute={RoutePath[AppRoutes.QUERY_LIST]} diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index f72267d6..8676e0f2 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -23,9 +23,14 @@ export function StudentList() { or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), }) + const [page, setPage] = useState(1) + const [pageSize, setPageSize] = useState(10) + const { data: students, isLoading: isLoadingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), + page, + page_size: pageSize, }) const data = { @@ -87,6 +92,15 @@ export function StudentList() { ['Телефон обучающегося', 'student_phone'], ['Телефон родителя', 'parent_phone'], ]} + pagination={{ + current: page, + pageSize: pageSize, + total: students?.count, + onChange: (page, pageSize) => { + setPage(page) + setPageSize(pageSize) + }, + }} filterFields={['circle_name']} data={data} isLoading={isLoadingInvites || isLoadingStudents} diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index cfb048fc..b79ed31d 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -68,9 +68,14 @@ export function TicketList() { } as BubbleFilterListItem } + const [page, setPage] = useState(1) + const [pageSize, setPageSize] = useState(10) + const { data: tickets, isLoading: isTicketsLoading } = useGetAllTicketsQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), + page, + page_size: pageSize, }) useEffect(() => { @@ -103,7 +108,7 @@ export function TicketList() { const localStatuses = [...(filters['status'] ?? [])] as string[] setStatuses(localStatuses.length === 0 ? null : localStatuses) }, - [setStatuses], + [setPage, setPageSize, setStatuses], ) return ( @@ -123,6 +128,15 @@ export function TicketList() {
loading={isTableLoading} + pagination={{ + current: page, + pageSize: pageSize, + total: tickets?.count, + onChange: (page, pageSize) => { + setPage(page) + setPageSize(pageSize) + }, + }} customType={'tableWithoutSearch'} columnsTitlesAndKeys={[ ['Создано', 'created_at'], From bd3adc59c17d274298261b5cd64679803f1eeda9 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:07:22 +0500 Subject: [PATCH 18/37] add scroll to top when change page --- apps/schools/domains/circle/components/circleList/index.tsx | 1 + apps/schools/domains/employee/components/employeeList/index.tsx | 1 + apps/schools/domains/query/components/queryList/index.tsx | 1 + apps/schools/domains/student/components/studentList/index.tsx | 1 + apps/schools/domains/ticket/components/ticketList/index.tsx | 1 + 5 files changed, 5 insertions(+) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index c3231c5c..6f0175e7 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -64,6 +64,7 @@ export function CircleList() { onChange: (page, pageSize) => { setPage(page) setPageSize(pageSize) + window.scrollTo({ top: 0, left: 0 }) }, }} data={circles} diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index f9815f5a..39f239c2 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -53,6 +53,7 @@ export function EmployeeList() { onChange: (page, pageSize) => { setPage(page) setPageSize(pageSize) + window.scrollTo({ top: 0, left: 0 }) }, }} data={data} diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index fe9ef874..bcbd54e6 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -128,6 +128,7 @@ export function QueryList() { onChange: (page, pageSize) => { setPage(page) setPageSize(pageSize) + window.scrollTo({ top: 0, left: 0 }) }, }} data={queries} diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 8676e0f2..a51631ae 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -99,6 +99,7 @@ export function StudentList() { onChange: (page, pageSize) => { setPage(page) setPageSize(pageSize) + window.scrollTo({ top: 0, left: 0 }) }, }} filterFields={['circle_name']} diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index b79ed31d..a606e815 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -135,6 +135,7 @@ export function TicketList() { onChange: (page, pageSize) => { setPage(page) setPageSize(pageSize) + window.scrollTo({ top: 0, left: 0 }) }, }} customType={'tableWithoutSearch'} From 3c66cba113465716064def73a79f0077e364db6b Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:08:25 +0500 Subject: [PATCH 19/37] prettier --- apps/schools/domains/common/constants/Cookies.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/common/constants/Cookies.ts b/apps/schools/domains/common/constants/Cookies.ts index 407e93b0..596a4336 100644 --- a/apps/schools/domains/common/constants/Cookies.ts +++ b/apps/schools/domains/common/constants/Cookies.ts @@ -1 +1 @@ -export const oneYearExpiresDate = new Date(Date.now() + 60 * 60 * 24 * 365 * 1000); +export const oneYearExpiresDate = new Date(Date.now() + 60 * 60 * 24 * 365 * 1000) From db2b798a8bb310aa30c656f07cf323f5678085f8 Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 17:17:22 +0500 Subject: [PATCH 20/37] add email profile --- .../components/auth/registerForm/index.tsx | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 90287051..74897d21 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,6 +11,8 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import {useUsersMutation} from '@domains/user/redux/userApi' +import {useGetAllEmployeesQuery, useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; +import {useUserProfile} from "@domains/user/providers/authProvider"; const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
@@ -27,11 +29,29 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { signInByPhone } = /*useContext(AuthLayoutContext)*/ { signInByPhone: () => {}, } - + const [updateProfile] = useUpdateEmployeeProfileByIdMutation(); + const { user } = useUserProfile() + const { data: allEmployees, isLoading: employeesLoading } = useGetAllEmployeesQuery({employee_profile: user.employee_profile?.id,}); + console.log(allEmployees); const registerComplete = useCallback(async () => { const { password } = form.getFieldsValue(['password']); await registrationHandler(phone, password, userRegistration, onFinish, onError, form) + .then(() => { + const { email } = form.getFieldsValue(['email']); + const { name } = form.getFieldsValue(['name']); + + if (!employeesLoading && allEmployees) { + if (user.employee_profile?.id) { + const updateEmail = { + employee_profile_id: user.employee_profile.id, + name: name, + email: email + } + updateProfile(updateEmail); + } + } + }) }, [form, signInByPhone]); const initialValues = { From 781cb189c46de1c351d3a5fa8d833f39c29f133a Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 17:18:01 +0500 Subject: [PATCH 21/37] refactoring --- .../components/auth/registerForm/index.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 74897d21..5f6c7b31 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -30,9 +30,7 @@ export const RegisterForm: React.FC = ({ onFinish, onError } signInByPhone: () => {}, } const [updateProfile] = useUpdateEmployeeProfileByIdMutation(); - const { user } = useUserProfile() - const { data: allEmployees, isLoading: employeesLoading } = useGetAllEmployeesQuery({employee_profile: user.employee_profile?.id,}); - console.log(allEmployees); + const { user } = useUserProfile(); const registerComplete = useCallback(async () => { const { password } = form.getFieldsValue(['password']); @@ -41,15 +39,13 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { email } = form.getFieldsValue(['email']); const { name } = form.getFieldsValue(['name']); - if (!employeesLoading && allEmployees) { - if (user.employee_profile?.id) { - const updateEmail = { - employee_profile_id: user.employee_profile.id, - name: name, - email: email - } - updateProfile(updateEmail); + if (user.employee_profile?.id) { + const updateEmail = { + employee_profile_id: user.employee_profile.id, + name: name, + email: email } + updateProfile(updateEmail); } }) }, [form, signInByPhone]); From 45030a1ce42c0f6721f78d7c02511d7f7c9b873f Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 17:18:47 +0500 Subject: [PATCH 22/37] refactoring --- .../schools/domains/user/components/auth/registerForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 5f6c7b31..8b69849e 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,7 +11,7 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import {useUsersMutation} from '@domains/user/redux/userApi' -import {useGetAllEmployeesQuery, useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; +import {useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; import {useUserProfile} from "@domains/user/providers/authProvider"; const RequiredFlagWrapper: React.FC> = (props) => { From ccb49e93a1973127984c34ce57989071156ccc06 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:24:21 +0500 Subject: [PATCH 23/37] fix page and pageSize combined in state var --- .../circle/components/circleList/index.tsx | 20 ++++++++++------- .../components/employeeList/index.tsx | 20 ++++++++++------- .../query/components/queryList/index.tsx | 20 ++++++++++------- .../student/components/studentList/index.tsx | 20 ++++++++++------- .../ticket/components/ticketList/index.tsx | 22 +++++++++++-------- 5 files changed, 61 insertions(+), 41 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 6f0175e7..db76442e 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -19,14 +19,16 @@ export function CircleList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() - const [page, setPage] = useState(1) - const [pageSize, setPageSize] = useState(10) + const [state, setState] = useState({ + page: 1, + pageSize: 10, + }) const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page, - page_size: pageSize, + page: state.page, + page_size: state.pageSize, }) return ( @@ -58,12 +60,14 @@ export function CircleList() { ['Кол-во принятых заявок', 'accepted_count'], ]} pagination={{ - current: page, - pageSize: pageSize, + current: state.page, + pageSize: state.pageSize, total: circles?.count, onChange: (page, pageSize) => { - setPage(page) - setPageSize(pageSize) + setState({ + page, + pageSize, + }) window.scrollTo({ top: 0, left: 0 }) }, }} diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 39f239c2..6e68f661 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -16,14 +16,16 @@ export function EmployeeList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() - const [page, setPage] = useState(1) - const [pageSize, setPageSize] = useState(10) + const [state, setState] = useState({ + page: 1, + pageSize: 10, + }) const { data, isLoading } = useGetAllEmployeesQuery({ organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchColumns), - page, - page_size: pageSize, + page: state.page, + page_size: state.pageSize, }) return ( @@ -47,12 +49,14 @@ export function EmployeeList() { ['Телефон', 'phone'], ]} pagination={{ - current: page, - pageSize: pageSize, + current: state.page, + pageSize: state.pageSize, total: data?.count, onChange: (page, pageSize) => { - setPage(page) - setPageSize(pageSize) + setState({ + page, + pageSize, + }) window.scrollTo({ top: 0, left: 0 }) }, }} diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index bcbd54e6..00d39db5 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -68,14 +68,16 @@ export function QueryList() { return items }, [analytics, statuses]) - const [page, setPage] = useState(1) - const [pageSize, setPageSize] = useState(10) + const [state, setState] = useState({ + page: 1, + pageSize: 10, + }) const { data: queries, isLoading: isQueriesLoading } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page, - page_size: pageSize, + page: state.page, + page_size: state.pageSize, }) const countAllQueries = useMemo( @@ -122,12 +124,14 @@ export function QueryList() { ['Кружок', 'circle_name'], ]} pagination={{ - current: page, - pageSize: pageSize, + current: state.page, + pageSize: state.pageSize, total: queries?.count, onChange: (page, pageSize) => { - setPage(page) - setPageSize(pageSize) + setState({ + page, + pageSize, + }) window.scrollTo({ top: 0, left: 0 }) }, }} diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index a51631ae..927e88c4 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -23,14 +23,16 @@ export function StudentList() { or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), }) - const [page, setPage] = useState(1) - const [pageSize, setPageSize] = useState(10) + const [state, setState] = useState({ + page: 1, + pageSize: 10, + }) const { data: students, isLoading: isLoadingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page, - page_size: pageSize, + page: state.page, + page_size: state.pageSize, }) const data = { @@ -93,12 +95,14 @@ export function StudentList() { ['Телефон родителя', 'parent_phone'], ]} pagination={{ - current: page, - pageSize: pageSize, + current: state.page, + pageSize: state.pageSize, total: students?.count, onChange: (page, pageSize) => { - setPage(page) - setPageSize(pageSize) + setState({ + page, + pageSize, + }) window.scrollTo({ top: 0, left: 0 }) }, }} diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index a606e815..7d1918f9 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -68,14 +68,16 @@ export function TicketList() { } as BubbleFilterListItem } - const [page, setPage] = useState(1) - const [pageSize, setPageSize] = useState(10) + const [state, setState] = useState({ + page: 1, + pageSize: 10, + }) const { data: tickets, isLoading: isTicketsLoading } = useGetAllTicketsQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), - page, - page_size: pageSize, + page: state.page, + page_size: state.pageSize, }) useEffect(() => { @@ -108,7 +110,7 @@ export function TicketList() { const localStatuses = [...(filters['status'] ?? [])] as string[] setStatuses(localStatuses.length === 0 ? null : localStatuses) }, - [setPage, setPageSize, setStatuses], + [setStatuses], ) return ( @@ -129,12 +131,14 @@ export function TicketList() { loading={isTableLoading} pagination={{ - current: page, - pageSize: pageSize, + current: state.page, + pageSize: state.pageSize, total: tickets?.count, onChange: (page, pageSize) => { - setPage(page) - setPageSize(pageSize) + setState({ + page, + pageSize, + }) window.scrollTo({ top: 0, left: 0 }) }, }} From 380b866e8b22c70f3bc9297f80ea9b8d7903e02f Mon Sep 17 00:00:00 2001 From: nenichv Date: Thu, 20 Jun 2024 18:14:16 +0500 Subject: [PATCH 24/37] fix --- .../components/auth/registerForm/index.tsx | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 8b69849e..c938eee4 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,7 +11,7 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import {useUsersMutation} from '@domains/user/redux/userApi' -import {useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; +import {useGetAllEmployeesQuery, useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; import {useUserProfile} from "@domains/user/providers/authProvider"; const RequiredFlagWrapper: React.FC> = (props) => { @@ -29,8 +29,13 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { signInByPhone } = /*useContext(AuthLayoutContext)*/ { signInByPhone: () => {}, } + const [updateProfile] = useUpdateEmployeeProfileByIdMutation(); - const { user } = useUserProfile(); + const { user } = useUserProfile() + const { data: allEmployees, isLoading: employeesLoading } = useGetAllEmployeesQuery({ + employee_profile: user.employee_profile?.id, + }); + const registerComplete = useCallback(async () => { const { password } = form.getFieldsValue(['password']); @@ -39,13 +44,15 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const { email } = form.getFieldsValue(['email']); const { name } = form.getFieldsValue(['name']); - if (user.employee_profile?.id) { - const updateEmail = { - employee_profile_id: user.employee_profile.id, - name: name, - email: email + if (!employeesLoading && allEmployees) { + if (user.employee_profile?.id) { + const updateEmail = { + employee_profile_id: user.employee_profile.id, + name: name, + email: email + } + updateProfile(updateEmail); } - updateProfile(updateEmail); } }) }, [form, signInByPhone]); From d7223aed92e5d192ea10d072161cfda2290de67d Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 21 Jun 2024 12:18:48 +0500 Subject: [PATCH 25/37] delete log --- apps/schools/domains/user/handlers/auth/register.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index 25f7fa02..ea410c4b 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -21,8 +21,6 @@ export async function tokenHandler( registrationMutation: any, onFinish: () => void, ) { - console.log(formComponent.getFieldsValue()) - if (recaptchaToken === '') return let { phone: inputPhone } = formComponent.getFieldsValue(['phone']) From 0b931deb623d3d8cbf7264b6618c37b8230b40b7 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:53:09 +0500 Subject: [PATCH 26/37] page params transfer in constants, use isFetching instead of isLoading --- .../circle/components/circleList/index.tsx | 5 +++-- apps/schools/domains/common/constants/Table.ts | 2 ++ .../employee/components/employeeList/index.tsx | 9 +++++---- .../domains/query/components/queryList/index.tsx | 15 ++++++++------- .../student/components/studentList/index.tsx | 11 ++++++----- .../ticket/components/ticketList/index.tsx | 15 ++++++++------- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index db76442e..4c2eef0f 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -14,14 +14,15 @@ 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' +import { defaultPaginationTablePage, defaultPaginationTablePageSize } from '@domains/common/constants/Table' export function CircleList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() const [state, setState] = useState({ - page: 1, - pageSize: 10, + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, }) const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ diff --git a/apps/schools/domains/common/constants/Table.ts b/apps/schools/domains/common/constants/Table.ts index 4f177cec..3004ba17 100644 --- a/apps/schools/domains/common/constants/Table.ts +++ b/apps/schools/domains/common/constants/Table.ts @@ -1 +1,3 @@ export const typeTable = ['tableWithoutSearch'] +export const defaultPaginationTablePage = 1 +export const defaultPaginationTablePageSize = 10 diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 6e68f661..894e8028 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -11,17 +11,18 @@ 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' export function EmployeeList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() const [state, setState] = useState({ - page: 1, - pageSize: 10, + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, }) - const { data, isLoading } = useGetAllEmployeesQuery({ + const { data, isFetching } = useGetAllEmployeesQuery({ organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchColumns), page: state.page, @@ -61,7 +62,7 @@ export function EmployeeList() { }, }} data={data} - isLoading={isLoading} + isLoading={isFetching} mainRoute={RoutePath[AppRoutes.EMPLOYEE_LIST]} searchFields={searchColumns} searchRequestText={searchRequestText} diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index 00d39db5..4f561271 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -20,6 +20,7 @@ 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' export function QueryList() { const { organizationId } = useOrganization() @@ -69,11 +70,11 @@ export function QueryList() { }, [analytics, statuses]) const [state, setState] = useState({ - page: 1, - pageSize: 10, + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, }) - const { data: queries, isLoading: isQueriesLoading } = useGetAllJoinCircleQueriesQuery({ + const { data: queries, isFetching: isQueriesFetching } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), page: state.page, @@ -86,10 +87,10 @@ export function QueryList() { ) useEffect(() => { - if (!isQueriesLoading && queries) { + if (!isQueriesFetching && queries) { setIsTableLoading(false) } - }, [isQueriesLoading, queries]) + }, [isQueriesFetching, queries]) const handleSearchChange = useCallback((value: string) => { setIsTableLoading(true) @@ -104,7 +105,7 @@ export function QueryList() { descriptionText={'Дождитесь первой заявки'} pageTitle={'Заявки'} data={queries} - isLoading={isQueriesLoading} + isLoading={isQueriesFetching} searchTrigger={searchRequestText} >
@@ -136,7 +137,7 @@ export function QueryList() { }, }} data={queries} - isLoading={isQueriesLoading} + isLoading={isQueriesFetching} mainRoute={RoutePath[AppRoutes.QUERY_LIST]} searchFields={[ 'created_at', diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 927e88c4..29a8d36a 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -12,6 +12,7 @@ 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' export function StudentList() { const [searchRequestText, setSearchRequestText] = useState('') @@ -24,11 +25,11 @@ export function StudentList() { }) const [state, setState] = useState({ - page: 1, - pageSize: 10, + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, }) - const { data: students, isLoading: isLoadingStudents } = useGetAllStudentsQuery({ + const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), page: state.page, @@ -71,7 +72,7 @@ export function StudentList() { buttonText={'Добавить обучающегося'} pageTitle={'Обучающиеся'} data={data} - isLoading={isLoadingStudents || isLoadingInvites} + isLoading={isFetchingStudents || isLoadingInvites} handleRunTask={() => router.push(RoutePath[AppRoutes.STUDENT_CREATE])} searchTrigger={searchRequestText} > @@ -108,7 +109,7 @@ export function StudentList() { }} filterFields={['circle_name']} data={data} - isLoading={isLoadingInvites || isLoadingStudents} + isLoading={isLoadingInvites || isFetchingStudents} mainRoute={RoutePath[AppRoutes.STUDENT_LIST]} searchFields={['student_name', 'student_phone', 'parent_phone', 'circle_name']} searchRequestText={searchRequestText} diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 7d1918f9..caa4b761 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -19,6 +19,7 @@ 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' type HandleInputChange = (text: React.ChangeEvent | string) => void type HandleChange = ( @@ -69,11 +70,11 @@ export function TicketList() { } const [state, setState] = useState({ - page: 1, - pageSize: 10, + page: defaultPaginationTablePage, + pageSize: defaultPaginationTablePageSize, }) - const { data: tickets, isLoading: isTicketsLoading } = useGetAllTicketsQuery({ + const { data: tickets, isFetching: isTicketsFetching } = useGetAllTicketsQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), page: state.page, @@ -81,10 +82,10 @@ export function TicketList() { }) useEffect(() => { - if (!isTicketsLoading && tickets) { + if (!isTicketsFetching && tickets) { setIsTableLoading(false) } - }, [isTicketsLoading, tickets]) + }, [isTicketsFetching, tickets]) const handleInputChange: HandleInputChange = useCallback( (text) => { @@ -119,7 +120,7 @@ export function TicketList() { descriptionText={'Дождитесь первого обращения'} pageTitle={'Обращения'} data={tickets} - isLoading={isTicketsLoading} + isLoading={isTicketsFetching} searchTrigger={searchRequestText} >
@@ -151,7 +152,7 @@ export function TicketList() { ]} customWidths={[10, 10, 40, 30]} data={tickets} - isLoading={isTicketsLoading} + isLoading={isTicketsFetching} mainRoute={RoutePath[AppRoutes.TICKETS_LIST]} searchFields={['created_at', 'content', 'sender']} customFields={{ From 95843123badbc344cb62f424f5df0b2f3073b420 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 21 Jun 2024 13:04:16 +0500 Subject: [PATCH 27/37] Add scrollTo function in common domain utils --- .../schools/domains/circle/components/circleList/index.tsx | 3 ++- apps/schools/domains/common/utils/scrollInDirection.ts | 7 +++++++ .../domains/employee/components/employeeList/index.tsx | 3 ++- apps/schools/domains/query/components/queryList/index.tsx | 3 ++- .../domains/student/components/studentList/index.tsx | 3 ++- .../schools/domains/ticket/components/ticketList/index.tsx | 3 ++- 6 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 apps/schools/domains/common/utils/scrollInDirection.ts diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index 4c2eef0f..da691681 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -15,6 +15,7 @@ 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('') @@ -69,7 +70,7 @@ export function CircleList() { page, pageSize, }) - window.scrollTo({ top: 0, left: 0 }) + scrollToTop() }, }} data={circles} diff --git a/apps/schools/domains/common/utils/scrollInDirection.ts b/apps/schools/domains/common/utils/scrollInDirection.ts new file mode 100644 index 00000000..6175b7c1 --- /dev/null +++ b/apps/schools/domains/common/utils/scrollInDirection.ts @@ -0,0 +1,7 @@ +export function scrollToTop() { + window.scrollTo({ top: 0, left: 0 }) +} + +export function scrollToBottom() { + window.scrollTo({ top: document.body.scrollHeight, left: 0 }) +} diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 894e8028..77d0d88c 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -12,6 +12,7 @@ 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('') @@ -58,7 +59,7 @@ export function EmployeeList() { page, pageSize, }) - window.scrollTo({ top: 0, left: 0 }) + scrollToTop() }, }} data={data} diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index 4f561271..ba0d767a 100644 --- a/apps/schools/domains/query/components/queryList/index.tsx +++ b/apps/schools/domains/query/components/queryList/index.tsx @@ -21,6 +21,7 @@ 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() @@ -133,7 +134,7 @@ export function QueryList() { page, pageSize, }) - window.scrollTo({ top: 0, left: 0 }) + scrollToTop() }, }} data={queries} diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index 29a8d36a..b0c7c458 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -13,6 +13,7 @@ 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' export function StudentList() { const [searchRequestText, setSearchRequestText] = useState('') @@ -104,7 +105,7 @@ export function StudentList() { page, pageSize, }) - window.scrollTo({ top: 0, left: 0 }) + scrollToTop() }, }} filterFields={['circle_name']} diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index caa4b761..8616d0a4 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -20,6 +20,7 @@ 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 = ( @@ -140,7 +141,7 @@ export function TicketList() { page, pageSize, }) - window.scrollTo({ top: 0, left: 0 }) + scrollToTop() }, }} customType={'tableWithoutSearch'} From e5409eb8c578d0665785cd277d7ff8be06e42ed6 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 21 Jun 2024 13:04:56 +0500 Subject: [PATCH 28/37] fix --- apps/schools/domains/employee/components/employeeList/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 77d0d88c..9fd8245a 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, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { Typography } from 'antd' import router from 'next/router' import styles from './styles/styles.module.scss' From ea3142ec6630affe4ad20332349703cb27120f14 Mon Sep 17 00:00:00 2001 From: lev tarasov <56757711+levil664@users.noreply.github.com> Date: Fri, 21 Jun 2024 13:07:09 +0500 Subject: [PATCH 29/37] fix --- .../domains/circle/components/circleList/index.tsx | 12 ++++++------ .../employee/components/employeeList/index.tsx | 12 ++++++------ .../domains/query/components/queryList/index.tsx | 12 ++++++------ .../domains/student/components/studentList/index.tsx | 12 ++++++------ .../domains/ticket/components/ticketList/index.tsx | 12 ++++++------ 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/apps/schools/domains/circle/components/circleList/index.tsx b/apps/schools/domains/circle/components/circleList/index.tsx index da691681..d9a1c062 100644 --- a/apps/schools/domains/circle/components/circleList/index.tsx +++ b/apps/schools/domains/circle/components/circleList/index.tsx @@ -21,7 +21,7 @@ export function CircleList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() - const [state, setState] = useState({ + const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }) @@ -29,8 +29,8 @@ export function CircleList() { const { data: circles, isFetching: isFetching } = useGetAllCirclesQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: state.page, - page_size: state.pageSize, + page: paginationParams.page, + page_size: paginationParams.pageSize, }) return ( @@ -62,11 +62,11 @@ export function CircleList() { ['Кол-во принятых заявок', 'accepted_count'], ]} pagination={{ - current: state.page, - pageSize: state.pageSize, + current: paginationParams.page, + pageSize: paginationParams.pageSize, total: circles?.count, onChange: (page, pageSize) => { - setState({ + setPaginationParams({ page, pageSize, }) diff --git a/apps/schools/domains/employee/components/employeeList/index.tsx b/apps/schools/domains/employee/components/employeeList/index.tsx index 9fd8245a..7247578b 100644 --- a/apps/schools/domains/employee/components/employeeList/index.tsx +++ b/apps/schools/domains/employee/components/employeeList/index.tsx @@ -18,7 +18,7 @@ export function EmployeeList() { const [searchRequestText, setSearchRequestText] = useState('') const { organizationId } = useOrganization() - const [state, setState] = useState({ + const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }) @@ -26,8 +26,8 @@ export function EmployeeList() { const { data, isFetching } = useGetAllEmployeesQuery({ organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchColumns), - page: state.page, - page_size: state.pageSize, + page: paginationParams.page, + page_size: paginationParams.pageSize, }) return ( @@ -51,11 +51,11 @@ export function EmployeeList() { ['Телефон', 'phone'], ]} pagination={{ - current: state.page, - pageSize: state.pageSize, + current: paginationParams.page, + pageSize: paginationParams.pageSize, total: data?.count, onChange: (page, pageSize) => { - setState({ + setPaginationParams({ page, pageSize, }) diff --git a/apps/schools/domains/query/components/queryList/index.tsx b/apps/schools/domains/query/components/queryList/index.tsx index ba0d767a..e140c8b8 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() { return items }, [analytics, statuses]) - const [state, setState] = useState({ + const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }) @@ -78,8 +78,8 @@ export function QueryList() { const { data: queries, isFetching: isQueriesFetching } = useGetAllJoinCircleQueriesQuery({ circle__organization__id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: state.page, - page_size: state.pageSize, + page: paginationParams.page, + page_size: paginationParams.pageSize, }) const countAllQueries = useMemo( @@ -126,11 +126,11 @@ export function QueryList() { ['Кружок', 'circle_name'], ]} pagination={{ - current: state.page, - pageSize: state.pageSize, + current: paginationParams.page, + pageSize: paginationParams.pageSize, total: queries?.count, onChange: (page, pageSize) => { - setState({ + setPaginationParams({ page, pageSize, }) diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx index b0c7c458..f5af871a 100644 --- a/apps/schools/domains/student/components/studentList/index.tsx +++ b/apps/schools/domains/student/components/studentList/index.tsx @@ -25,7 +25,7 @@ export function StudentList() { or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns), }) - const [state, setState] = useState({ + const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }) @@ -33,8 +33,8 @@ export function StudentList() { const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({ circle__organization: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns), - page: state.page, - page_size: state.pageSize, + page: paginationParams.page, + page_size: paginationParams.pageSize, }) const data = { @@ -97,11 +97,11 @@ export function StudentList() { ['Телефон родителя', 'parent_phone'], ]} pagination={{ - current: state.page, - pageSize: state.pageSize, + current: paginationParams.page, + pageSize: paginationParams.pageSize, total: students?.count, onChange: (page, pageSize) => { - setState({ + setPaginationParams({ page, pageSize, }) diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx index 8616d0a4..7245b37a 100644 --- a/apps/schools/domains/ticket/components/ticketList/index.tsx +++ b/apps/schools/domains/ticket/components/ticketList/index.tsx @@ -70,7 +70,7 @@ export function TicketList() { } as BubbleFilterListItem } - const [state, setState] = useState({ + const [paginationParams, setPaginationParams] = useState({ page: defaultPaginationTablePage, pageSize: defaultPaginationTablePageSize, }) @@ -78,8 +78,8 @@ export function TicketList() { const { data: tickets, isFetching: isTicketsFetching } = useGetAllTicketsQuery({ organization_id: organizationId, or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns), - page: state.page, - page_size: state.pageSize, + page: paginationParams.page, + page_size: paginationParams.pageSize, }) useEffect(() => { @@ -133,11 +133,11 @@ export function TicketList() { loading={isTableLoading} pagination={{ - current: state.page, - pageSize: state.pageSize, + current: paginationParams.page, + pageSize: paginationParams.pageSize, total: tickets?.count, onChange: (page, pageSize) => { - setState({ + setPaginationParams({ page, pageSize, }) From b331773a2d8d150e64c57769d730f0d3faec0b50 Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 21 Jun 2024 15:13:30 +0500 Subject: [PATCH 30/37] fix and add lazy get user query instead of useUserProfile --- .../components/auth/registerForm/index.tsx | 44 +++++++++---------- .../domains/user/redux/authenticationApi.ts | 1 + 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index c938eee4..a1f1b118 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -1,5 +1,5 @@ import { Col, Form, Row } from 'antd' -import React, { PropsWithChildren, useCallback, useContext, useState } from 'react' +import React, {PropsWithChildren, useCallback, useContext, useEffect, useState} from 'react' import styles from '../styles/formStyles.module.scss' import { ResponsiveCol } from '../containers/ResponsiveCol' @@ -13,6 +13,7 @@ import { registrationHandler } from '@domains/user/handlers/auth/register' import {useUsersMutation} from '@domains/user/redux/userApi' import {useGetAllEmployeesQuery, useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; import {useUserProfile} from "@domains/user/providers/authProvider"; +import {useLazyGetUserQuery} from "@domains/user/redux/authenticationApi"; const RequiredFlagWrapper: React.FC> = (props) => { return
{props.children}
@@ -31,31 +32,30 @@ export const RegisterForm: React.FC = ({ onFinish, onError } } const [updateProfile] = useUpdateEmployeeProfileByIdMutation(); - const { user } = useUserProfile() - const { data: allEmployees, isLoading: employeesLoading } = useGetAllEmployeesQuery({ - employee_profile: user.employee_profile?.id, - }); + const [getLazyUser, {data}] = useLazyGetUserQuery(); - const registerComplete = useCallback(async () => { + const registerComplete = useCallback(() => { const { password } = form.getFieldsValue(['password']); - await registrationHandler(phone, password, userRegistration, onFinish, onError, form) - .then(() => { - const { email } = form.getFieldsValue(['email']); - const { name } = form.getFieldsValue(['name']); + registrationHandler(phone, password, userRegistration, onFinish, onError, form) + .then(async () => { + await getLazyUser(); + }); + }, [form, signInByPhone, getLazyUser]); - if (!employeesLoading && allEmployees) { - if (user.employee_profile?.id) { - const updateEmail = { - employee_profile_id: user.employee_profile.id, - name: name, - email: email - } - updateProfile(updateEmail); - } - } - }) - }, [form, signInByPhone]); + useEffect(() => { + const { email } = form.getFieldsValue(['email']); + const { name } = form.getFieldsValue(['name']); + + if (data && data.user.employee_profile?.id) { + const updateEmail = { + employee_profile_id: data.user.employee_profile.id, + name: name, + email: email + }; + updateProfile(updateEmail); + } + }, [data, updateProfile]); const initialValues = { phone diff --git a/apps/schools/domains/user/redux/authenticationApi.ts b/apps/schools/domains/user/redux/authenticationApi.ts index c4eaf1e1..8ecc265d 100644 --- a/apps/schools/domains/user/redux/authenticationApi.ts +++ b/apps/schools/domains/user/redux/authenticationApi.ts @@ -45,6 +45,7 @@ export const { useLoginMutation, useLogoutMutation, useGetUserQuery, + useLazyGetUserQuery, useUpdateUserMutation, useUpdatePasswordMutation, } = authenticationApi From a763d4cef324e768c974ab909172585a86e1ea20 Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 21 Jun 2024 15:14:25 +0500 Subject: [PATCH 31/37] refactoring --- .../domains/user/components/auth/registerForm/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 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 a1f1b118..5fd3bac4 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -11,8 +11,7 @@ import { BUTTON_FORM_GUTTER_20 } from '../constants/styles' import { FirebaseReCaptchaContext } from '@domains/user/providers/firebaseReCaptchaProvider' import { registrationHandler } from '@domains/user/handlers/auth/register' import {useUsersMutation} from '@domains/user/redux/userApi' -import {useGetAllEmployeesQuery, useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; -import {useUserProfile} from "@domains/user/providers/authProvider"; +import {useUpdateEmployeeProfileByIdMutation} from "@domains/employee/redux/employeeApi"; import {useLazyGetUserQuery} from "@domains/user/redux/authenticationApi"; const RequiredFlagWrapper: React.FC> = (props) => { From 18336b9b506840bbd7e2eefb10f47843f2793573 Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 21 Jun 2024 15:19:35 +0500 Subject: [PATCH 32/37] refactoring --- .../schools/domains/user/components/auth/registerForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 5fd3bac4..6b105ca0 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -38,7 +38,7 @@ export const RegisterForm: React.FC = ({ onFinish, onError } registrationHandler(phone, password, userRegistration, onFinish, onError, form) .then(async () => { - await getLazyUser(); + await getLazyUser({}); }); }, [form, signInByPhone, getLazyUser]); From 3b7fcec1e1de888df24052a3948a8259c502af77 Mon Sep 17 00:00:00 2001 From: nenichv Date: Fri, 21 Jun 2024 17:02:40 +0500 Subject: [PATCH 33/37] refactoring --- .../domains/user/components/auth/registerForm/index.tsx | 3 ++- apps/schools/domains/user/handlers/auth/register.ts | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/schools/domains/user/components/auth/registerForm/index.tsx b/apps/schools/domains/user/components/auth/registerForm/index.tsx index 6b105ca0..a9c1c849 100644 --- a/apps/schools/domains/user/components/auth/registerForm/index.tsx +++ b/apps/schools/domains/user/components/auth/registerForm/index.tsx @@ -36,7 +36,7 @@ export const RegisterForm: React.FC = ({ onFinish, onError } const registerComplete = useCallback(() => { const { password } = form.getFieldsValue(['password']); - registrationHandler(phone, password, userRegistration, onFinish, onError, form) + registrationHandler(phone, password, userRegistration, onError, form) .then(async () => { await getLazyUser({}); }); @@ -53,6 +53,7 @@ export const RegisterForm: React.FC = ({ onFinish, onError } email: email }; updateProfile(updateEmail); + onFinish(); } }, [data, updateProfile]); diff --git a/apps/schools/domains/user/handlers/auth/register.ts b/apps/schools/domains/user/handlers/auth/register.ts index ea410c4b..13f3cfea 100644 --- a/apps/schools/domains/user/handlers/auth/register.ts +++ b/apps/schools/domains/user/handlers/auth/register.ts @@ -78,7 +78,6 @@ export async function registrationHandler( phone: string, password: string, userRegistrationMutation: any, - onFinish: () => void, onError: () => void, formComponent: FormInstance ) { @@ -98,7 +97,6 @@ export async function registrationHandler( if (!('error' in response)) { cookies.set('jwtToken', response.data.token, { path: '/' }) message.success(SuccessRegistrationMsg) - onFinish() } else if (response.error?.status === 401) { message.error(PleaseReloadPageMsg) onError() From cd9534bae0b7d91f1f9e200b48d0fd81c5da7fc1 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: Mon, 24 Jun 2024 13:47:53 +0500 Subject: [PATCH 34/37] upgrade version of node in dev.Dockerfile and prod.Dockerfile from 16.x.x to 18.x.x --- apps/schools/dev.Dockerfile | 2 +- apps/schools/prod.Dockerfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/schools/dev.Dockerfile b/apps/schools/dev.Dockerfile index fb5281fb..1f20126f 100644 --- a/apps/schools/dev.Dockerfile +++ b/apps/schools/dev.Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-alpine AS runner +FROM node:18-alpine AS runner RUN node -v diff --git a/apps/schools/prod.Dockerfile b/apps/schools/prod.Dockerfile index b10ae5c4..1f20126f 100644 --- a/apps/schools/prod.Dockerfile +++ b/apps/schools/prod.Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-alpine AS runner +FROM node:18-alpine AS runner RUN node -v @@ -13,4 +13,4 @@ WORKDIR /opt/app RUN yarn install #RUN ["chmod", "+x", "/opt/app/setEnv.sh"] -CMD /bin/sh -c 'source /opt/app/setEnv.sh'; yarn build; yarn start \ No newline at end of file +CMD /bin/sh -c 'source /opt/app/setEnv.sh'; yarn build; yarn start From 846455780bb929fad15747c04eac494ebd92b662 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: Mon, 24 Jun 2024 14:57:17 +0500 Subject: [PATCH 35/37] trying to fix problem with props.text --- apps/schools/domains/common/components/table/forming.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/schools/domains/common/components/table/forming.tsx b/apps/schools/domains/common/components/table/forming.tsx index a1c1668f..3ba0aa9a 100644 --- a/apps/schools/domains/common/components/table/forming.tsx +++ b/apps/schools/domains/common/components/table/forming.tsx @@ -1,5 +1,5 @@ import { ColumnType } from 'antd/lib/table/interface' -import React from 'react' +import React, { ReactElement } from 'react' import styles from './styles/styles.module.scss' import { getSearchText } from '@domains/common/utils/searchText' import { @@ -53,7 +53,7 @@ export function useGenerateFullColumns( const obj = (record as any)[column.dataIndex] if (!isReactElement(obj)) return obj === value - return obj.props.text === value + return (obj as ReactElement).props.text === value }, } } From 8dc562d8d04496a5ebd8aa44960d555e99566177 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: Mon, 24 Jun 2024 15:13:20 +0500 Subject: [PATCH 36/37] changed from es5 to es6 --- apps/schools/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/tsconfig.json b/apps/schools/tsconfig.json index dab73a1e..2f8c4eac 100644 --- a/apps/schools/tsconfig.json +++ b/apps/schools/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es6", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, From aaa53bac9987dfe9c2cb34672856f4c3b4c6592f 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: Mon, 24 Jun 2024 15:27:29 +0500 Subject: [PATCH 37/37] changed from es6 to es2018 --- apps/schools/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/schools/tsconfig.json b/apps/schools/tsconfig.json index 2f8c4eac..88e6bf69 100644 --- a/apps/schools/tsconfig.json +++ b/apps/schools/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es6", + "target": "es2018", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true,