diff --git a/apps/portal/src/components/offers/table/OffersTable.tsx b/apps/portal/src/components/offers/table/OffersTable.tsx index f5279b47..dc091ac2 100644 --- a/apps/portal/src/components/offers/table/OffersTable.tsx +++ b/apps/portal/src/components/offers/table/OffersTable.tsx @@ -7,7 +7,7 @@ import OffersTablePagination from '~/components/offers/table/OffersTablePaginati import { OfferTableFilterOptions, OfferTableSortBy, - OfferTableTabOptions, + OfferTableYoeOptions, YOE_CATEGORY, } from '~/components/offers/table/types'; @@ -29,7 +29,7 @@ export default function OffersTable({ jobTitleFilter, }: OffersTableProps) { 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({ currentPage: 0, numOfItems: 0, @@ -48,7 +48,7 @@ export default function OffersTable({ numOfPages: 0, totalItems: 0, }); - }, [selectedTab, currency]); + }, [selectedYoe, currency]); const offersQuery = trpc.useQuery( [ 'offers.list', @@ -60,7 +60,7 @@ export default function OffersTable({ offset: pagination.currentPage, sortBy: OfferTableSortBy[selectedFilter] ?? '-monthYearReceived', title: jobTitleFilter, - yoeCategory: selectedTab, + yoeCategory: selectedYoe, }, ], { @@ -76,22 +76,15 @@ export default function OffersTable({ function renderFilters() { return ( -
- itemValue === selectedTab, - )[0].label - } - size="inherit"> - {OfferTableTabOptions.map(({ label: itemLabel, value }) => ( +
+ + {OfferTableYoeOptions.map(({ label: itemLabel, value }) => ( { - setSelectedTab(value); + setSelectedYoe(value); gaEvent({ action: `offers.table_filter_yoe_category_${value}`, category: 'engagement', @@ -103,7 +96,9 @@ export default function OffersTable({
- View all offers in + + View all offers in + setCurrency(value)} selectedCurrency={currency} @@ -140,7 +135,7 @@ export default function OffersTable({ 'Company', 'Title', 'YOE', - selectedTab === YOE_CATEGORY.INTERN ? 'Monthly Salary' : 'Annual TC', + selectedYoe === YOE_CATEGORY.INTERN ? 'Monthly Salary' : 'Annual TC', 'Date Offered', 'Actions', ]; @@ -172,34 +167,32 @@ export default function OffersTable({ }; return ( -
-
- {renderFilters()} - {offersQuery.isLoading ? ( -
- -
- ) : ( -
- - {renderHeader()} - - {offers.map((offer) => ( - - ))} - -
-
- )} - -
+
+ {renderFilters()} + {offersQuery.isLoading ? ( +
+ +
+ ) : ( +
+ + {renderHeader()} + + {offers.map((offer) => ( + + ))} + +
+
+ )} +
); } diff --git a/apps/portal/src/components/offers/table/types.ts b/apps/portal/src/components/offers/table/types.ts index ca14aa32..cb29f1cc 100644 --- a/apps/portal/src/components/offers/table/types.ts +++ b/apps/portal/src/components/offers/table/types.ts @@ -6,7 +6,7 @@ export enum YOE_CATEGORY { SENIOR = 3, } -export const OfferTableTabOptions = [ +export const OfferTableYoeOptions = [ { label: 'Fresh Grad (0-2 YOE)', value: YOE_CATEGORY.ENTRY, diff --git a/apps/portal/src/components/shared/Container.tsx b/apps/portal/src/components/shared/Container.tsx new file mode 100644 index 00000000..b32b852e --- /dev/null +++ b/apps/portal/src/components/shared/Container.tsx @@ -0,0 +1,26 @@ +import clsx from 'clsx'; +import React from 'react'; + +type Props = Readonly<{ + children: React.ReactNode; + className?: string; + variant?: 'narrow' | 'normal'; +}>; + +export default function Container({ + children, + className, + variant = 'normal', +}: Props) { + return ( +
+ {children} +
+ ); +} diff --git a/apps/portal/src/pages/offers/index.tsx b/apps/portal/src/pages/offers/index.tsx index aa235c81..2bc90e0c 100644 --- a/apps/portal/src/pages/offers/index.tsx +++ b/apps/portal/src/pages/offers/index.tsx @@ -5,10 +5,14 @@ import { Banner } from '@tih/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import OffersTable from '~/components/offers/table/OffersTable'; import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead'; +import Container from '~/components/shared/Container'; +import type { JobTitleType } from '~/components/shared/JobTitles'; import JobTitlesTypeahead from '~/components/shared/JobTitlesTypahead'; export default function OffersHomePage() { - const [jobTitleFilter, setjobTitleFilter] = useState('software-engineer'); + const [jobTitleFilter, setJobTitleFilter] = useState( + 'software-engineer', + ); const [companyFilter, setCompanyFilter] = useState(''); const { event: gaEvent } = useGoogleAnalytics(); @@ -42,14 +46,14 @@ export default function OffersHomePage() { textSize="inherit" onSelect={(option) => { if (option) { - setjobTitleFilter(option.value); + setJobTitleFilter(option.value as JobTitleType); gaEvent({ action: `offers.table_filter_job_title_${option.value}`, category: 'engagement', label: 'Filter by job title', }); } else { - setjobTitleFilter(''); + setJobTitleFilter(''); } }} /> @@ -74,12 +78,12 @@ export default function OffersHomePage() {
-
+ -
+ ); } diff --git a/packages/ui/src/Banner/Banner.tsx b/packages/ui/src/Banner/Banner.tsx index 1d41397d..24a0b873 100644 --- a/packages/ui/src/Banner/Banner.tsx +++ b/packages/ui/src/Banner/Banner.tsx @@ -19,7 +19,8 @@ export default function Banner({ children, size = 'md', onHide }: Props) { size === 'xs' && 'text-xs', )}>
-
+

{children}

{onHide != null && (