1
1
import styled from "styled-components" ;
2
2
import { trans } from "i18n" ;
3
3
import { searchCustomerTickets , createTicket } from "@lowcoder-ee/api/supportApi" ;
4
- import { useState , useEffect } from 'react' ;
4
+ import { useState , useEffect , useMemo } from 'react' ;
5
5
import { Helmet } from "react-helmet" ;
6
6
import { useUserDetails } from "./useUserDetails" ;
7
7
import StepModal from "components/StepModal" ;
@@ -14,6 +14,7 @@ import { Input } from "antd";
14
14
import ReactQuill from "react-quill" ;
15
15
import 'react-quill/dist/quill.snow.css' ;
16
16
import { Spin } from "antd" ;
17
+ import LoadingOutlined from "@ant-design/icons/LoadingOutlined" ;
17
18
18
19
19
20
const SupportWrapper = styled . div `
@@ -190,15 +191,16 @@ export function SupportOverview() {
190
191
}
191
192
} ;
192
193
193
- const filteredTickets = supportTickets . filter ( ( ticket : any ) => {
194
- if ( searchValue ) {
194
+ const filteredTickets = useMemo ( ( ) => {
195
+ if ( ! Boolean ( searchValue ) ) return supportTickets ;
196
+
197
+ return supportTickets . filter ( ( ticket : any ) => {
195
198
return (
196
- ticket . title . toLowerCase ( ) . includes ( searchValue . trim ( ) . toLowerCase ( ) ) ||
197
- ticket . description . toLowerCase ( ) . includes ( searchValue . trim ( ) . toLowerCase ( ) )
198
- ) ;
199
- }
200
- return true ;
201
- } ) ;
199
+ ticket . title ?. toLowerCase ( ) . includes ( searchValue . trim ( ) . toLowerCase ( ) ) ||
200
+ ticket . description ?. toLowerCase ( ) . includes ( searchValue . trim ( ) . toLowerCase ( ) )
201
+ )
202
+ } ) ;
203
+ } , [ searchValue , supportTickets ] ) ;
202
204
203
205
const handleCreateTicket = async ( ) => {
204
206
if ( summary . length > 150 ) {
@@ -273,8 +275,9 @@ export function SupportOverview() {
273
275
buttonType = { summary ? "primary" : "normal" }
274
276
onClick = { handleCreateTicket }
275
277
disabled = { isSubmitting || ! summary }
278
+ loading = { isSubmitting }
276
279
>
277
- { isSubmitting ? < Spin /> : trans ( "support.createTicketSubmit" ) }
280
+ { trans ( "support.createTicketSubmit" ) }
278
281
</ TacoButton >
279
282
< div >
280
283
< div style = { { margin : "20px 0 0 0" } } > { trans ( "support.createTicketInfoText" ) } </ div >
@@ -304,7 +307,10 @@ export function SupportOverview() {
304
307
</ HeaderWrapper >
305
308
< BodyWrapper >
306
309
< StyledTable
307
- loading = { loading }
310
+ loading = { {
311
+ spinning : loading ,
312
+ indicator : < LoadingOutlined spin style = { { fontSize : 30 } } />
313
+ } }
308
314
rowClassName = "datasource-can-not-edit"
309
315
tableLayout = { "auto" }
310
316
scroll = { { x : "100%" } }
0 commit comments