feat(submissions): Implement submissions page with paginated table
This commit introduces a new page for users to view their submissions in a structured and paginated table. This allows users to easily track their submission history and access key details. The main changes include: - A new page at `/submissions` to display the submissions list. - A `SubmissionsTable` component to render submission data, including title, country, status, and a link to the submission URL. - Integration of `react-paginate` to handle navigation through large sets of data. - A new `useSubmissions` custom hook using TanStack Query for efficient, paginated data fetching from the API. - Addition of the `currency-symbol-map` dependency to display prices with the correct currency symbol.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { API_ENDPOINTS } from "@/lib/api";
|
||||
import { flagsService } from "@/lib/api/services/flags-service";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
|
||||
export const useGetFlagQuery = (countryCode: string) => {
|
||||
const queryKey = useMemo(
|
||||
() => [API_ENDPOINTS.FLAGS(countryCode)],
|
||||
[countryCode],
|
||||
);
|
||||
|
||||
return useQuery({
|
||||
queryKey,
|
||||
queryFn: () => flagsService.getCountryFlag(countryCode),
|
||||
});
|
||||
};
|
||||
@@ -1,29 +1,23 @@
|
||||
import { API_ENDPOINTS, tendersService } from "@/lib/api";
|
||||
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
|
||||
export const useTendersInfiniteQuery = (params?: Record<string, any>) => {
|
||||
export const useTendersQuery = (params?: Record<string, any>) => {
|
||||
const queryKey = useMemo(
|
||||
() => [API_ENDPOINTS.TENDERS.READ_ALL, "read-tenders", params],
|
||||
[params],
|
||||
);
|
||||
|
||||
return useInfiniteQuery({
|
||||
return useQuery({
|
||||
queryKey,
|
||||
|
||||
queryFn: ({ pageParam = 0 }) =>
|
||||
tendersService.tendersList({ ...params, offset: pageParam }),
|
||||
|
||||
initialPageParam: 0,
|
||||
|
||||
getNextPageParam: (lastPage) => {
|
||||
if (lastPage.meta) {
|
||||
const { offset, limit, total } = lastPage.meta;
|
||||
|
||||
const nextOffset = offset + limit;
|
||||
|
||||
return nextOffset < total ? nextOffset : undefined;
|
||||
}
|
||||
},
|
||||
queryFn: () => tendersService.tendersList({ ...params }),
|
||||
});
|
||||
};
|
||||
|
||||
export const useTenderDetailQuery = (id: string) => {
|
||||
const queryKey = useMemo(() => [API_ENDPOINTS.TENDERS.DETAILS(id)], [id]);
|
||||
return useQuery({
|
||||
queryKey,
|
||||
queryFn: () => tendersService.tenderDetails(id),
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user