From 7c79186530aae17ebab7dd39c04741c92eeb0897 Mon Sep 17 00:00:00 2001 From: Daria Mikhailova Date: Thu, 1 Feb 2024 17:52:10 +1300 Subject: [PATCH] renamed var --- src/client/components/OfficeFloorMap.tsx | 9 ++++++--- src/client/components/ui/ImageWithPanZoom.tsx | 2 +- src/modules/events/client/components/EventsPage.tsx | 4 ++-- .../events/client/components/UpcomingEvents.tsx | 2 +- src/modules/events/client/queries.ts | 11 ++++------- src/modules/events/server/router.ts | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/client/components/OfficeFloorMap.tsx b/src/client/components/OfficeFloorMap.tsx index de007e55..c3958fee 100644 --- a/src/client/components/OfficeFloorMap.tsx +++ b/src/client/components/OfficeFloorMap.tsx @@ -182,13 +182,16 @@ export const OfficeFloorMap: React.FC = ({ {mapObjects(1)}
diff --git a/src/modules/events/client/components/EventsPage.tsx b/src/modules/events/client/components/EventsPage.tsx index 53fafbdf..de29a7c0 100644 --- a/src/modules/events/client/components/EventsPage.tsx +++ b/src/modules/events/client/components/EventsPage.tsx @@ -71,10 +71,10 @@ const EventsList = ({ export const EventsPage = () => { const officeId = useStore(stores.officeId) - const { data: events, isFetched } = useUpcomingEvents(officeId, true) + const { data: events, isFetched } = useUpcomingEvents(officeId, 'time') const { data: myEvents, isFetched: isMineFetched } = useMyEvents( officeId, - true + 'status' ) if (!isFetched && !isMineFetched) { return null diff --git a/src/modules/events/client/components/UpcomingEvents.tsx b/src/modules/events/client/components/UpcomingEvents.tsx index 8dbb8a77..2e00abe6 100644 --- a/src/modules/events/client/components/UpcomingEvents.tsx +++ b/src/modules/events/client/components/UpcomingEvents.tsx @@ -16,7 +16,7 @@ export const UpcomingEvents: React.FC = () => { const [eventData, setEventData] = useState>([]) useEffect(() => { - if (events?.length && isFetched) { + if (!!events?.length && isFetched) { let limit = page === 1 ? pageSize : page * pageSize const result = paginateArray(events, 1, limit) setEventData(result) diff --git a/src/modules/events/client/queries.ts b/src/modules/events/client/queries.ts index e0815a85..5e8b8306 100644 --- a/src/modules/events/client/queries.ts +++ b/src/modules/events/client/queries.ts @@ -41,13 +41,10 @@ export const useEventsAdmin = ( ) } -export const useUpcomingEvents = ( - officeId: string | null, - byTime?: boolean -) => { +export const useUpcomingEvents = (officeId: string | null, sortBy?: string) => { const path = '/user-api/events/event' return useQuery( - [path, { office: officeId, byTime }], + [path, { office: officeId, sortBy }], async ({ queryKey }) => (await api.get(path, { params: queryKey[1] })) .data, @@ -55,10 +52,10 @@ export const useUpcomingEvents = ( ) } -export const useMyEvents = (officeId: string | null, byStatus?: boolean) => { +export const useMyEvents = (officeId: string | null, sortBy?: string) => { const path = '/user-api/events/event/me' return useQuery( - [path, { office: officeId, byStatus }], + [path, { office: officeId, sortBy }], async ({ queryKey }) => (await api.get(path, { params: queryKey[1] })).data, { enabled: !!officeId } diff --git a/src/modules/events/server/router.ts b/src/modules/events/server/router.ts index c6935a5f..bfff2208 100644 --- a/src/modules/events/server/router.ts +++ b/src/modules/events/server/router.ts @@ -440,7 +440,7 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) { '/event', async ( req: FastifyRequest<{ - Querystring: { byTime?: boolean } + Querystring: { sortBy?: string } }>, reply ) => { @@ -467,7 +467,7 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) { order: ['startDate'], }) - if (!!req.query.byTime) { + if (!!req.query.sortBy && req.query.sortBy === 'time') { const pastEvents = await fastify.db.Event.findAll({ where: { endDate: { @@ -496,7 +496,7 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) { '/event/me', async ( req: FastifyRequest<{ - Querystring: { byStatus?: boolean } + Querystring: { sortBy?: string } }>, reply ) => { @@ -541,7 +541,7 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) { attributes: ['eventId', 'status', 'id'], }) - if (!!req.query.byStatus) { + if (!!req.query.sortBy && req.query.sortBy === 'status') { const result: Record< EventApplicationStatus, Array