|
|
@ -34,6 +34,12 @@ export type OffersTableProps = Readonly<{
|
|
|
|
country: string | null;
|
|
|
|
country: string | null;
|
|
|
|
countryFilter: string;
|
|
|
|
countryFilter: string;
|
|
|
|
jobTitleFilter: string;
|
|
|
|
jobTitleFilter: string;
|
|
|
|
|
|
|
|
onSort: (
|
|
|
|
|
|
|
|
sortDirection: OFFER_TABLE_SORT_ORDER,
|
|
|
|
|
|
|
|
sortType: OfferTableSortType | null,
|
|
|
|
|
|
|
|
) => void;
|
|
|
|
|
|
|
|
selectedSortDirection: OFFER_TABLE_SORT_ORDER;
|
|
|
|
|
|
|
|
selectedSortType: OfferTableSortType | null;
|
|
|
|
}>;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
|
|
export default function OffersTable({
|
|
|
|
export default function OffersTable({
|
|
|
@ -42,6 +48,9 @@ export default function OffersTable({
|
|
|
|
companyName,
|
|
|
|
companyName,
|
|
|
|
companyFilter,
|
|
|
|
companyFilter,
|
|
|
|
jobTitleFilter,
|
|
|
|
jobTitleFilter,
|
|
|
|
|
|
|
|
selectedSortDirection,
|
|
|
|
|
|
|
|
selectedSortType,
|
|
|
|
|
|
|
|
onSort,
|
|
|
|
}: OffersTableProps) {
|
|
|
|
}: OffersTableProps) {
|
|
|
|
const [currency, setCurrency] = useState(
|
|
|
|
const [currency, setCurrency] = useState(
|
|
|
|
getCurrencyForCountry(country).toString(),
|
|
|
|
getCurrencyForCountry(country).toString(),
|
|
|
@ -66,14 +75,11 @@ export default function OffersTable({
|
|
|
|
isYoeCategoryInitialized,
|
|
|
|
isYoeCategoryInitialized,
|
|
|
|
] = useSearchParamSingle<keyof typeof YOE_CATEGORY_PARAM>('yoeCategory');
|
|
|
|
] = useSearchParamSingle<keyof typeof YOE_CATEGORY_PARAM>('yoeCategory');
|
|
|
|
|
|
|
|
|
|
|
|
const [
|
|
|
|
const [, , isSortDirectionInitialized] =
|
|
|
|
selectedSortDirection,
|
|
|
|
useSearchParamSingle<OFFER_TABLE_SORT_ORDER>('sortDirection');
|
|
|
|
setSelectedSortDirection,
|
|
|
|
|
|
|
|
isSortDirectionInitialized,
|
|
|
|
|
|
|
|
] = useSearchParamSingle<OFFER_TABLE_SORT_ORDER>('sortDirection');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [selectedSortType, setSelectedSortType, isSortTypeInitialized] =
|
|
|
|
const [, , isSortTypeInitialized] =
|
|
|
|
useSearchParamSingle<OfferTableSortType>('sortType');
|
|
|
|
useSearchParamSingle<OfferTableSortType | null>('sortType');
|
|
|
|
|
|
|
|
|
|
|
|
const areFilterParamsInitialized = useMemo(() => {
|
|
|
|
const areFilterParamsInitialized = useMemo(() => {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -126,10 +132,6 @@ export default function OffersTable({
|
|
|
|
pathname,
|
|
|
|
pathname,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
setSelectedSortDirection(OFFER_TABLE_SORT_ORDER.UNSORTED);
|
|
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
}, [selectedYoeCategory]);
|
|
|
|
|
|
|
|
const topRef = useRef<HTMLDivElement>(null);
|
|
|
|
const topRef = useRef<HTMLDivElement>(null);
|
|
|
|
const { showToast } = useToast();
|
|
|
|
const { showToast } = useToast();
|
|
|
|
const { isLoading: isResultsLoading } = trpc.useQuery(
|
|
|
|
const { isLoading: isResultsLoading } = trpc.useQuery(
|
|
|
@ -141,7 +143,6 @@ export default function OffersTable({
|
|
|
|
currency,
|
|
|
|
currency,
|
|
|
|
limit: NUMBER_OF_OFFERS_PER_PAGE,
|
|
|
|
limit: NUMBER_OF_OFFERS_PER_PAGE,
|
|
|
|
offset: pagination.currentPage,
|
|
|
|
offset: pagination.currentPage,
|
|
|
|
// SortBy: selectedSortBy ?? '-monthYearReceived',
|
|
|
|
|
|
|
|
sortBy:
|
|
|
|
sortBy:
|
|
|
|
selectedSortDirection && selectedSortType
|
|
|
|
selectedSortDirection && selectedSortType
|
|
|
|
? `${selectedSortDirection}${selectedSortType}`
|
|
|
|
? `${selectedSortDirection}${selectedSortType}`
|
|
|
@ -169,19 +170,6 @@ export default function OffersTable({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const onSort = (
|
|
|
|
|
|
|
|
sortDirection: OFFER_TABLE_SORT_ORDER,
|
|
|
|
|
|
|
|
sortType: OfferTableSortType,
|
|
|
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
gaEvent({
|
|
|
|
|
|
|
|
action: 'offers_table_sort',
|
|
|
|
|
|
|
|
category: 'engagement',
|
|
|
|
|
|
|
|
label: `${sortType} - ${sortDirection}`,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
setSelectedSortType(sortType);
|
|
|
|
|
|
|
|
setSelectedSortDirection(sortDirection);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function renderFilters() {
|
|
|
|
function renderFilters() {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="flex items-center justify-between p-4 text-xs text-slate-700 sm:grid-cols-4 sm:text-sm md:text-base">
|
|
|
|
<div className="flex items-center justify-between p-4 text-xs text-slate-700 sm:grid-cols-4 sm:text-sm md:text-base">
|
|
|
@ -204,6 +192,7 @@ export default function OffersTable({
|
|
|
|
label={itemLabel}
|
|
|
|
label={itemLabel}
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
setSelectedYoeCategory(value);
|
|
|
|
setSelectedYoeCategory(value);
|
|
|
|
|
|
|
|
onSort(OFFER_TABLE_SORT_ORDER.UNSORTED, null);
|
|
|
|
gaEvent({
|
|
|
|
gaEvent({
|
|
|
|
action: `offers.table_filter_yoe_category_${value}`,
|
|
|
|
action: `offers.table_filter_yoe_category_${value}`,
|
|
|
|
category: 'engagement',
|
|
|
|
category: 'engagement',
|
|
|
@ -291,12 +280,11 @@ export default function OffersTable({
|
|
|
|
<Spinner display="block" size="lg" />
|
|
|
|
<Spinner display="block" size="lg" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{(!isLoading && !offers) ||
|
|
|
|
{!isLoading && (!offers || offers.length === 0) && (
|
|
|
|
(offers.length === 0 && (
|
|
|
|
|
|
|
|
<div className="py-16 text-lg">
|
|
|
|
<div className="py-16 text-lg">
|
|
|
|
<div className="flex justify-center">No data yet 🥺</div>
|
|
|
|
<div className="flex justify-center">No data yet 🥺</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<OffersTablePagination
|
|
|
|
<OffersTablePagination
|
|
|
|
endNumber={
|
|
|
|
endNumber={
|
|
|
|