|
|
@ -7,7 +7,7 @@ import OffersTablePagination from '~/components/offers/table/OffersTablePaginati
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
OfferTableFilterOptions,
|
|
|
|
OfferTableFilterOptions,
|
|
|
|
OfferTableSortBy,
|
|
|
|
OfferTableSortBy,
|
|
|
|
OfferTableTabOptions,
|
|
|
|
OfferTableYoeOptions,
|
|
|
|
YOE_CATEGORY,
|
|
|
|
YOE_CATEGORY,
|
|
|
|
} from '~/components/offers/table/types';
|
|
|
|
} from '~/components/offers/table/types';
|
|
|
|
|
|
|
|
|
|
|
@ -29,7 +29,7 @@ export default function OffersTable({
|
|
|
|
jobTitleFilter,
|
|
|
|
jobTitleFilter,
|
|
|
|
}: OffersTableProps) {
|
|
|
|
}: OffersTableProps) {
|
|
|
|
const [currency, setCurrency] = useState(Currency.SGD.toString()); // TODO: Detect location
|
|
|
|
const [currency, setCurrency] = useState(Currency.SGD.toString()); // TODO: Detect location
|
|
|
|
const [selectedTab, setSelectedTab] = useState(YOE_CATEGORY.ENTRY);
|
|
|
|
const [selectedYoe, setSelectedYoe] = useState(YOE_CATEGORY.ENTRY);
|
|
|
|
const [pagination, setPagination] = useState<Paging>({
|
|
|
|
const [pagination, setPagination] = useState<Paging>({
|
|
|
|
currentPage: 0,
|
|
|
|
currentPage: 0,
|
|
|
|
numOfItems: 0,
|
|
|
|
numOfItems: 0,
|
|
|
@ -48,7 +48,7 @@ export default function OffersTable({
|
|
|
|
numOfPages: 0,
|
|
|
|
numOfPages: 0,
|
|
|
|
totalItems: 0,
|
|
|
|
totalItems: 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, [selectedTab, currency]);
|
|
|
|
}, [selectedYoe, currency]);
|
|
|
|
const offersQuery = trpc.useQuery(
|
|
|
|
const offersQuery = trpc.useQuery(
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'offers.list',
|
|
|
|
'offers.list',
|
|
|
@ -60,7 +60,7 @@ export default function OffersTable({
|
|
|
|
offset: pagination.currentPage,
|
|
|
|
offset: pagination.currentPage,
|
|
|
|
sortBy: OfferTableSortBy[selectedFilter] ?? '-monthYearReceived',
|
|
|
|
sortBy: OfferTableSortBy[selectedFilter] ?? '-monthYearReceived',
|
|
|
|
title: jobTitleFilter,
|
|
|
|
title: jobTitleFilter,
|
|
|
|
yoeCategory: selectedTab,
|
|
|
|
yoeCategory: selectedYoe,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -76,22 +76,15 @@ export default function OffersTable({
|
|
|
|
|
|
|
|
|
|
|
|
function renderFilters() {
|
|
|
|
function renderFilters() {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="m-4 flex grid grid-cols-1 items-center justify-between gap-6 sm:grid-cols-4">
|
|
|
|
<div className="flex items-center justify-between p-4 text-sm sm:grid-cols-4 md:text-base">
|
|
|
|
<DropdownMenu
|
|
|
|
<DropdownMenu align="start" label="Filters" size="inherit">
|
|
|
|
align="start"
|
|
|
|
{OfferTableYoeOptions.map(({ label: itemLabel, value }) => (
|
|
|
|
label={
|
|
|
|
|
|
|
|
OfferTableTabOptions.filter(
|
|
|
|
|
|
|
|
({ value: itemValue }) => itemValue === selectedTab,
|
|
|
|
|
|
|
|
)[0].label
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
size="inherit">
|
|
|
|
|
|
|
|
{OfferTableTabOptions.map(({ label: itemLabel, value }) => (
|
|
|
|
|
|
|
|
<DropdownMenu.Item
|
|
|
|
<DropdownMenu.Item
|
|
|
|
key={value}
|
|
|
|
key={value}
|
|
|
|
isSelected={value === selectedTab}
|
|
|
|
isSelected={value === selectedYoe}
|
|
|
|
label={itemLabel}
|
|
|
|
label={itemLabel}
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
setSelectedTab(value);
|
|
|
|
setSelectedYoe(value);
|
|
|
|
gaEvent({
|
|
|
|
gaEvent({
|
|
|
|
action: `offers.table_filter_yoe_category_${value}`,
|
|
|
|
action: `offers.table_filter_yoe_category_${value}`,
|
|
|
|
category: 'engagement',
|
|
|
|
category: 'engagement',
|
|
|
@ -103,7 +96,9 @@ export default function OffersTable({
|
|
|
|
</DropdownMenu>
|
|
|
|
</DropdownMenu>
|
|
|
|
<div className="divide-x-slate-200 col-span-3 flex items-center justify-end space-x-4 divide-x">
|
|
|
|
<div className="divide-x-slate-200 col-span-3 flex items-center justify-end space-x-4 divide-x">
|
|
|
|
<div className="justify-left flex items-center space-x-2">
|
|
|
|
<div className="justify-left flex items-center space-x-2">
|
|
|
|
<span>View all offers in</span>
|
|
|
|
<span className="sr-only sm:not-sr-only sm:inline">
|
|
|
|
|
|
|
|
View all offers in
|
|
|
|
|
|
|
|
</span>
|
|
|
|
<CurrencySelector
|
|
|
|
<CurrencySelector
|
|
|
|
handleCurrencyChange={(value: string) => setCurrency(value)}
|
|
|
|
handleCurrencyChange={(value: string) => setCurrency(value)}
|
|
|
|
selectedCurrency={currency}
|
|
|
|
selectedCurrency={currency}
|
|
|
@ -140,7 +135,7 @@ export default function OffersTable({
|
|
|
|
'Company',
|
|
|
|
'Company',
|
|
|
|
'Title',
|
|
|
|
'Title',
|
|
|
|
'YOE',
|
|
|
|
'YOE',
|
|
|
|
selectedTab === YOE_CATEGORY.INTERN ? 'Monthly Salary' : 'Annual TC',
|
|
|
|
selectedYoe === YOE_CATEGORY.INTERN ? 'Monthly Salary' : 'Annual TC',
|
|
|
|
'Date Offered',
|
|
|
|
'Date Offered',
|
|
|
|
'Actions',
|
|
|
|
'Actions',
|
|
|
|
];
|
|
|
|
];
|
|
|
@ -172,34 +167,32 @@ export default function OffersTable({
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="w-5/6">
|
|
|
|
<div className="relative w-full border border-slate-200">
|
|
|
|
<div className="relative w-full border border-slate-200">
|
|
|
|
{renderFilters()}
|
|
|
|
{renderFilters()}
|
|
|
|
{offersQuery.isLoading ? (
|
|
|
|
{offersQuery.isLoading ? (
|
|
|
|
<div className="col-span-10 pt-4">
|
|
|
|
<div className="col-span-10 pt-4">
|
|
|
|
<Spinner display="block" size="lg" />
|
|
|
|
<Spinner display="block" size="lg" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
) : (
|
|
|
|
<div className="overflow-x-auto">
|
|
|
|
<div className="overflow-x-auto">
|
|
|
|
<table className="w-full divide-y divide-slate-200 border-y border-slate-200 text-left text-slate-600">
|
|
|
|
<table className="w-full divide-y divide-slate-200 border-y border-slate-200 text-left text-slate-600">
|
|
|
|
{renderHeader()}
|
|
|
|
{renderHeader()}
|
|
|
|
<tbody>
|
|
|
|
<tbody>
|
|
|
|
{offers.map((offer) => (
|
|
|
|
{offers.map((offer) => (
|
|
|
|
<OffersRow key={offer.id} row={offer} />
|
|
|
|
<OffersRow key={offer.id} row={offer} />
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
<OffersTablePagination
|
|
|
|
<OffersTablePagination
|
|
|
|
endNumber={
|
|
|
|
endNumber={
|
|
|
|
pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + offers.length
|
|
|
|
pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + offers.length
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handlePageChange={handlePageChange}
|
|
|
|
handlePageChange={handlePageChange}
|
|
|
|
pagination={pagination}
|
|
|
|
pagination={pagination}
|
|
|
|
startNumber={pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + 1}
|
|
|
|
startNumber={pagination.currentPage * NUMBER_OF_OFFERS_IN_PAGE + 1}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|