Заявки
@@ -202,8 +200,8 @@ export function QueryList() {
},
}}
sortFields={['created_at']}
- searchRequestText={searchRequestText}
- setSearchRequestText={setSearchRequestText}
+ searchRequestText={searchRequest || ''}
+ setSearchRequestText={(text) => setSearchRequest(text)}
onChange={(pagination, filters, sorter) => {
const localStatuses = [...(filters['status'] ?? [])] as string[]
setStatuses(localStatuses.length === 0 ? null : localStatuses)
diff --git a/apps/schools/domains/student/components/studentList/index.tsx b/apps/schools/domains/student/components/studentList/index.tsx
index f035c9a2..619998ab 100644
--- a/apps/schools/domains/student/components/studentList/index.tsx
+++ b/apps/schools/domains/student/components/studentList/index.tsx
@@ -1,4 +1,4 @@
-import React, { useCallback, useEffect, useState } from 'react'
+import React, { useCallback, useState } from 'react'
import { Typography } from 'antd'
import router from 'next/router'
import styles from './styles/styles.module.scss'
@@ -17,6 +17,7 @@ import { scrollToTop } from '@domains/common/utils/scrollInDirection'
import { handlePaginationChange } from '@domains/common/handlers/paginationChange'
import { calculateResults } from '@domains/student/handlers/resultsCalculate'
import { getTotalPages } from '@domains/common/utils/getTotalPages'
+import { useQueryState } from "next-usequerystate"
export function StudentList() {
const [queryPaginationParams, setQueryPaginationParams] = useState({
@@ -30,20 +31,20 @@ export function StudentList() {
},
})
- const [searchRequestText, setSearchRequestText] = useState('')
+ const [searchRequestText, setSearchRequestText] = useQueryState('search')
const { organizationId } = useOrganization()
const { data: invites, isLoading: isLoadingInvites } = useGetAllStudentInvitationsQuery({
circle__organization__id: organizationId,
status: StatusesEnum.SENT,
- or_search: createSearchTextForRequest(searchRequestText, searchInvitesColumns),
+ or_search: createSearchTextForRequest(searchRequestText || '', searchInvitesColumns),
page: queryPaginationParams.invites.page,
page_size: queryPaginationParams.invites.pageSize,
})
const { data: students, isFetching: isFetchingStudents } = useGetAllStudentsQuery({
circle__organization: organizationId,
- or_search: createSearchTextForRequest(searchRequestText, searchStudentsColumns),
+ or_search: createSearchTextForRequest(searchRequestText || '', searchStudentsColumns),
page: queryPaginationParams.students.page,
page_size: queryPaginationParams.students.pageSize,
})
@@ -90,7 +91,7 @@ export function StudentList() {
data={data}
isLoading={isFetchingStudents || isLoadingInvites}
handleRunTask={() => router.push(RoutePath[AppRoutes.STUDENT_CREATE])}
- searchTrigger={searchRequestText}
+ searchTrigger={searchRequestText || ''}
>
Обучающиеся
@@ -127,9 +128,9 @@ export function StudentList() {
isLoading={isLoadingInvites || isFetchingStudents}
mainRoute={RoutePath[AppRoutes.STUDENT_LIST]}
searchFields={['student_name', 'student_phone', 'parent_phone', 'circle_name']}
- searchRequestText={searchRequestText}
- setSearchRequestText={setSearchRequestText}
+ searchRequestText={searchRequestText || ''}
+ setSearchRequestText={(text) => setSearchRequestText(text)}
/>
)
-}
+}
\ No newline at end of file
diff --git a/apps/schools/domains/ticket/components/ticketList/index.tsx b/apps/schools/domains/ticket/components/ticketList/index.tsx
index c8fbfc49..f74acbc3 100644
--- a/apps/schools/domains/ticket/components/ticketList/index.tsx
+++ b/apps/schools/domains/ticket/components/ticketList/index.tsx
@@ -32,9 +32,9 @@ type HandleChange = (
export function TicketList() {
const [inputText, setInputText] = useState('')
- const [searchRequestText, setSearchRequestText] = useState('')
const [isTableLoading, setIsTableLoading] = useState(false)
const { organizationId } = useOrganization()
+ const [searchRequest, setSearchRequest] = useQueryState('search')
const [statuses, setStatuses] = useQueryState(
'statuses',
@@ -77,7 +77,7 @@ export function TicketList() {
const { data: tickets, isFetching: isTicketsFetching } = useGetAllTicketsQuery({
organization_id: organizationId,
- or_search: createSearchTextForRequest(searchRequestText, searchTicketsColumns),
+ or_search: createSearchTextForRequest(searchRequest || '', searchTicketsColumns),
page: paginationParams.page,
page_size: paginationParams.pageSize,
})
@@ -93,18 +93,14 @@ export function TicketList() {
if (typeof text === 'string') {
setIsTableLoading(true)
setInputText(text)
- setTimeout(() => {
- setSearchRequestText(text)
- }, 1000)
+ setSearchRequest(text)
} else {
setIsTableLoading(true)
setInputText(text.target.value)
- setTimeout(() => {
- setSearchRequestText(text.target.value)
- }, 1000)
+ setSearchRequest(text.target.value)
}
},
- [setIsTableLoading, setInputText, setSearchRequestText],
+ [setIsTableLoading, setInputText, setSearchRequest],
)
const handleChange: HandleChange = useCallback(
@@ -122,7 +118,7 @@ export function TicketList() {
pageTitle={'Обращения'}
data={tickets}
isLoading={isTicketsFetching}
- searchTrigger={searchRequestText}
+ searchTrigger={searchRequest || ''}
>
Обращения
@@ -209,8 +205,8 @@ export function TicketList() {
},
}}
sortFields={['created_at']}
- searchRequestText={searchRequestText}
- setSearchRequestText={setSearchRequestText}
+ searchRequestText={searchRequest || ''}
+ setSearchRequestText={(text) => setSearchRequest(text)}
onChange={handleChange}
/>