format
This commit is contained in:
parent
2df36b9d7f
commit
b6ad40f24e
@ -1,12 +1,11 @@
|
|||||||
import { CircularProgress, List, ListItem, Box, useTheme, Pagination } from "@mui/material";
|
import { CircularProgress, List, ListItem, Box, useTheme, Pagination } from "@mui/material";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import TicketCard from "./TicketCard";
|
import TicketCard from "./TicketCard";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import { apiRequestHandler } from "@utils/api/apiRequestHandler";
|
import { apiRequestHandler } from "@utils/api/apiRequestHandler";
|
||||||
import { ApiError, Ticket } from "@utils/api/types";
|
import { ApiError, Ticket } from "@utils/api/types";
|
||||||
|
|
||||||
|
|
||||||
const TICKETS_PER_PAGE = 10;
|
const TICKETS_PER_PAGE = 10;
|
||||||
|
|
||||||
export default function TicketList() {
|
export default function TicketList() {
|
||||||
@ -17,8 +16,7 @@ export default function TicketList() {
|
|||||||
const [currentPage, setCurrentPage] = useState<number>(0);
|
const [currentPage, setCurrentPage] = useState<number>(0);
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(
|
useEffect(function fetchTickets() {
|
||||||
function fetchTickets() {
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
|
|
||||||
@ -39,12 +37,9 @@ export default function TicketList() {
|
|||||||
return () => {
|
return () => {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
};
|
};
|
||||||
},
|
}, [currentPage, enqueueSnackbar]);
|
||||||
[currentPage, enqueueSnackbar]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(
|
useEffect(function subscribeToTickets() {
|
||||||
function subscribeToTickets() {
|
|
||||||
const unsubscribe = apiRequestHandler.subscribeToAllTickets({
|
const unsubscribe = apiRequestHandler.subscribeToAllTickets({
|
||||||
onMessage(event) {
|
onMessage(event) {
|
||||||
console.log("SSE received:", event.data);
|
console.log("SSE received:", event.data);
|
||||||
@ -72,9 +67,7 @@ export default function TicketList() {
|
|||||||
return () => {
|
return () => {
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
};
|
};
|
||||||
},
|
}, [tickets]);
|
||||||
[tickets]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
Loading…
Reference in New Issue
Block a user