11import styled from "styled-components" ;
22import { trans } from "i18n" ;
33import { searchCustomerTickets , createTicket } from "@lowcoder-ee/api/supportApi" ;
4- import { useState , useEffect } from 'react' ;
4+ import { useState , useEffect , useMemo } from 'react' ;
55import { Helmet } from "react-helmet" ;
66import { useUserDetails } from "./useUserDetails" ;
77import StepModal from "components/StepModal" ;
@@ -14,6 +14,7 @@ import { Input } from "antd";
1414import ReactQuill from "react-quill" ;
1515import 'react-quill/dist/quill.snow.css' ;
1616import { Spin } from "antd" ;
17+ import LoadingOutlined from "@ant-design/icons/LoadingOutlined" ;
1718
1819
1920const SupportWrapper = styled . div `
@@ -190,15 +191,16 @@ export function SupportOverview() {
190191 }
191192 } ;
192193
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 ) => {
195198 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 ] ) ;
202204
203205 const handleCreateTicket = async ( ) => {
204206 if ( summary . length > 150 ) {
@@ -273,8 +275,9 @@ export function SupportOverview() {
273275 buttonType = { summary ? "primary" : "normal" }
274276 onClick = { handleCreateTicket }
275277 disabled = { isSubmitting || ! summary }
278+ loading = { isSubmitting }
276279 >
277- { isSubmitting ? < Spin /> : trans ( "support.createTicketSubmit" ) }
280+ { trans ( "support.createTicketSubmit" ) }
278281 </ TacoButton >
279282 < div >
280283 < div style = { { margin : "20px 0 0 0" } } > { trans ( "support.createTicketInfoText" ) } </ div >
@@ -304,7 +307,10 @@ export function SupportOverview() {
304307 </ HeaderWrapper >
305308 < BodyWrapper >
306309 < StyledTable
307- loading = { loading }
310+ loading = { {
311+ spinning : loading ,
312+ indicator : < LoadingOutlined spin style = { { fontSize : 30 } } />
313+ } }
308314 rowClassName = "datasource-can-not-edit"
309315 tableLayout = { "auto" }
310316 scroll = { { x : "100%" } }
0 commit comments