diff --git a/apps/portal/src/components/global/AppShell.tsx b/apps/portal/src/components/global/AppShell.tsx
index c601257b..3a29256c 100644
--- a/apps/portal/src/components/global/AppShell.tsx
+++ b/apps/portal/src/components/global/AppShell.tsx
@@ -61,7 +61,7 @@ function ProfileJewel() {
Open user menu
{session?.user?.image == null ? (
- Render some icon
+ TODO: Render some icon
) : (
{company.name}
-
+
{location.cityName} ({location.countryCode})
|
diff --git a/apps/portal/src/components/offers/table/OffersTable.tsx b/apps/portal/src/components/offers/table/OffersTable.tsx
index 7b2f4811..3b78e783 100644
--- a/apps/portal/src/components/offers/table/OffersTable.tsx
+++ b/apps/portal/src/components/offers/table/OffersTable.tsx
@@ -1,6 +1,6 @@
import clsx from 'clsx';
import { useRouter } from 'next/router';
-import { useEffect, useMemo, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
import { JobType } from '@prisma/client';
import { DropdownMenu, Spinner, useToast } from '@tih/ui';
@@ -23,13 +23,15 @@ import OffersRow from './OffersRow';
import type { DashboardOffer, GetOffersResponse, Paging } from '~/types/offers';
-const NUMBER_OF_OFFERS_IN_PAGE = 10;
+const NUMBER_OF_OFFERS_PER_PAGE = 20;
+
export type OffersTableProps = Readonly<{
companyFilter: string;
companyName?: string;
countryFilter: string;
jobTitleFilter: string;
}>;
+
export default function OffersTable({
countryFilter,
companyName,
@@ -101,15 +103,16 @@ export default function OffersTable({
pathname,
]);
+ const topRef = useRef(null);
const { showToast } = useToast();
- trpc.useQuery(
+ const { isLoading: isResultsLoading } = trpc.useQuery(
[
'offers.list',
{
companyId: companyFilter,
countryId: countryFilter,
currency,
- limit: NUMBER_OF_OFFERS_IN_PAGE,
+ limit: NUMBER_OF_OFFERS_PER_PAGE,
offset: pagination.currentPage,
sortBy: selectedSortBy ?? '-monthYearReceived',
title: jobTitleFilter,
@@ -257,17 +260,27 @@ export default function OffersTable({
};
return (
-
- {renderFilters()}
+
+
{renderFilters()}
+
{isLoading ? (
) : (
-
+
{renderHeader()}
-
+
{offers.map((offer) => (
))}
@@ -283,11 +296,18 @@ export default function OffersTable({
)}
{
+ topRef?.current?.scrollIntoView({
+ block: 'start',
+ });
+ handlePageChange(number);
+ }}
+ isInitialFetch={isLoading}
+ isLoading={isResultsLoading}
pagination={pagination}
- startNumber={pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + 1}
+ startNumber={pagination.currentPage * NUMBER_OF_OFFERS_PER_PAGE + 1}
/>
);
diff --git a/apps/portal/src/components/offers/table/OffersTablePagination.tsx b/apps/portal/src/components/offers/table/OffersTablePagination.tsx
index 45dd7831..fd227cfa 100644
--- a/apps/portal/src/components/offers/table/OffersTablePagination.tsx
+++ b/apps/portal/src/components/offers/table/OffersTablePagination.tsx
@@ -1,37 +1,51 @@
import { useEffect, useState } from 'react';
-import { Pagination } from '@tih/ui';
+import { Pagination, Spinner } from '@tih/ui';
import type { Paging } from '~/types/offers';
type OffersTablePaginationProps = Readonly<{
endNumber: number;
handlePageChange: (page: number) => void;
+ isInitialFetch?: boolean;
+ isLoading?: boolean;
pagination: Paging;
startNumber: number;
}>;
export default function OffersTablePagination({
+ isInitialFetch,
+ isLoading,
endNumber,
pagination,
startNumber,
handlePageChange,
}: OffersTablePaginationProps) {
const [screenWidth, setScreenWidth] = useState(0);
+
useEffect(() => {
setScreenWidth(window.innerWidth);
}, []);
+
return (
-