|
|
@ -2,18 +2,15 @@ import { useEffect, useState } from 'react';
|
|
|
|
import { HorizontalDivider, Select, Spinner, Tabs } from '@tih/ui';
|
|
|
|
import { HorizontalDivider, Select, Spinner, Tabs } from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
|
|
import OffersTablePagination from '~/components/offers/table/OffersTablePagination';
|
|
|
|
import OffersTablePagination from '~/components/offers/table/OffersTablePagination';
|
|
|
|
import type {
|
|
|
|
|
|
|
|
OfferTableRowData,
|
|
|
|
|
|
|
|
PaginationType,
|
|
|
|
|
|
|
|
} from '~/components/offers/table/types';
|
|
|
|
|
|
|
|
import { YOE_CATEGORY } from '~/components/offers/table/types';
|
|
|
|
import { YOE_CATEGORY } from '~/components/offers/table/types';
|
|
|
|
|
|
|
|
|
|
|
|
import CurrencySelector from '~/utils/offers/currency/CurrencySelector';
|
|
|
|
import CurrencySelector from '~/utils/offers/currency/CurrencySelector';
|
|
|
|
import { formatDate } from '~/utils/offers/time';
|
|
|
|
|
|
|
|
import { trpc } from '~/utils/trpc';
|
|
|
|
import { trpc } from '~/utils/trpc';
|
|
|
|
|
|
|
|
|
|
|
|
import OffersRow from './OffersRow';
|
|
|
|
import OffersRow from './OffersRow';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import type { DashboardOffer, Paging } from '~/types/offers';
|
|
|
|
|
|
|
|
|
|
|
|
const NUMBER_OF_OFFERS_IN_PAGE = 10;
|
|
|
|
const NUMBER_OF_OFFERS_IN_PAGE = 10;
|
|
|
|
export type OffersTableProps = Readonly<{
|
|
|
|
export type OffersTableProps = Readonly<{
|
|
|
|
companyFilter: string;
|
|
|
|
companyFilter: string;
|
|
|
@ -25,18 +22,18 @@ export default function OffersTable({
|
|
|
|
}: OffersTableProps) {
|
|
|
|
}: OffersTableProps) {
|
|
|
|
const [currency, setCurrency] = useState('SGD'); // TODO: Detect location
|
|
|
|
const [currency, setCurrency] = useState('SGD'); // TODO: Detect location
|
|
|
|
const [selectedTab, setSelectedTab] = useState(YOE_CATEGORY.ENTRY);
|
|
|
|
const [selectedTab, setSelectedTab] = useState(YOE_CATEGORY.ENTRY);
|
|
|
|
const [pagination, setPagination] = useState<PaginationType>({
|
|
|
|
const [pagination, setPagination] = useState<Paging>({
|
|
|
|
currentPage: 1,
|
|
|
|
currentPage: 0,
|
|
|
|
numOfItems: 1,
|
|
|
|
numOfItems: 0,
|
|
|
|
numOfPages: 0,
|
|
|
|
numOfPages: 0,
|
|
|
|
totalItems: 0,
|
|
|
|
totalItems: 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const [offers, setOffers] = useState<Array<OfferTableRowData>>([]);
|
|
|
|
const [offers, setOffers] = useState<Array<DashboardOffer>>([]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
setPagination({
|
|
|
|
setPagination({
|
|
|
|
currentPage: 1,
|
|
|
|
currentPage: 0,
|
|
|
|
numOfItems: 1,
|
|
|
|
numOfItems: 0,
|
|
|
|
numOfPages: 0,
|
|
|
|
numOfPages: 0,
|
|
|
|
totalItems: 0,
|
|
|
|
totalItems: 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -48,7 +45,7 @@ export default function OffersTable({
|
|
|
|
companyId: companyFilter,
|
|
|
|
companyId: companyFilter,
|
|
|
|
limit: NUMBER_OF_OFFERS_IN_PAGE,
|
|
|
|
limit: NUMBER_OF_OFFERS_IN_PAGE,
|
|
|
|
location: 'Singapore, Singapore', // TODO: Geolocation
|
|
|
|
location: 'Singapore, Singapore', // TODO: Geolocation
|
|
|
|
offset: pagination.currentPage - 1,
|
|
|
|
offset: 0,
|
|
|
|
sortBy: '-monthYearReceived',
|
|
|
|
sortBy: '-monthYearReceived',
|
|
|
|
title: jobTitleFilter,
|
|
|
|
title: jobTitleFilter,
|
|
|
|
yoeCategory: selectedTab,
|
|
|
|
yoeCategory: selectedTab,
|
|
|
@ -56,28 +53,19 @@ export default function OffersTable({
|
|
|
|
],
|
|
|
|
],
|
|
|
|
{
|
|
|
|
{
|
|
|
|
onSuccess: (response) => {
|
|
|
|
onSuccess: (response) => {
|
|
|
|
const filteredData = response.data.map((res) => {
|
|
|
|
// Const filteredData = response.data.map((res) => {
|
|
|
|
return {
|
|
|
|
// return {
|
|
|
|
company: res.company.name,
|
|
|
|
// company: res.company.name,
|
|
|
|
date: formatDate(res.monthYearReceived),
|
|
|
|
// date: res.monthYearReceived,
|
|
|
|
id: res.OffersFullTime
|
|
|
|
// id: res.id,
|
|
|
|
? res.OffersFullTime!.id
|
|
|
|
// profileId: res.profileId,
|
|
|
|
: res.OffersIntern!.id,
|
|
|
|
// income: res.income,
|
|
|
|
profileId: res.profileId,
|
|
|
|
// title: res.title,
|
|
|
|
salary: res.OffersFullTime
|
|
|
|
// yoe: res.totalYoe,
|
|
|
|
? res.OffersFullTime?.totalCompensation.value
|
|
|
|
// };
|
|
|
|
: res.OffersIntern?.monthlySalary.value,
|
|
|
|
// });
|
|
|
|
title: res.OffersFullTime ? res.OffersFullTime?.level : '',
|
|
|
|
setOffers(response.data);
|
|
|
|
yoe: 100,
|
|
|
|
setPagination(response.paging);
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
setOffers(filteredData);
|
|
|
|
|
|
|
|
setPagination({
|
|
|
|
|
|
|
|
currentPage: response.paging.currentPage + 1,
|
|
|
|
|
|
|
|
numOfItems: response.paging.numOfItems,
|
|
|
|
|
|
|
|
numOfPages: response.paging.numOfPages,
|
|
|
|
|
|
|
|
totalItems: response.paging.totalItems,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -90,15 +78,15 @@ export default function OffersTable({
|
|
|
|
label="Table Navigation"
|
|
|
|
label="Table Navigation"
|
|
|
|
tabs={[
|
|
|
|
tabs={[
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Fresh Grad (0-3 YOE)',
|
|
|
|
label: 'Fresh Grad (0-2 YOE)',
|
|
|
|
value: YOE_CATEGORY.ENTRY,
|
|
|
|
value: YOE_CATEGORY.ENTRY,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Mid (4-7 YOE)',
|
|
|
|
label: 'Mid (3-5 YOE)',
|
|
|
|
value: YOE_CATEGORY.MID,
|
|
|
|
value: YOE_CATEGORY.MID,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Senior (8+ YOE)',
|
|
|
|
label: 'Senior (6+ YOE)',
|
|
|
|
value: YOE_CATEGORY.SENIOR,
|
|
|
|
value: YOE_CATEGORY.SENIOR,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -187,14 +175,11 @@ export default function OffersTable({
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
<OffersTablePagination
|
|
|
|
<OffersTablePagination
|
|
|
|
endNumber={
|
|
|
|
endNumber={
|
|
|
|
(pagination.currentPage - 1) * NUMBER_OF_OFFERS_IN_PAGE +
|
|
|
|
pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + offers.length
|
|
|
|
offers.length
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handlePageChange={handlePageChange}
|
|
|
|
handlePageChange={handlePageChange}
|
|
|
|
pagination={pagination}
|
|
|
|
pagination={pagination}
|
|
|
|
startNumber={
|
|
|
|
startNumber={pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + 1}
|
|
|
|
(pagination.currentPage - 1) * NUMBER_OF_OFFERS_IN_PAGE + 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|