From b47cfceb09c1231af13e3ee5f6b1c9c645125b9b Mon Sep 17 00:00:00 2001 From: Bryann Yeap Kok Keong Date: Thu, 3 Nov 2022 01:05:53 +0800 Subject: [PATCH] [offers][chore] Change location filter from city to country --- .../components/offers/table/OffersTable.tsx | 4 +-- .../portal/src/server/router/offers/offers.ts | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/portal/src/components/offers/table/OffersTable.tsx b/apps/portal/src/components/offers/table/OffersTable.tsx index e31ce619..2f6f99a0 100644 --- a/apps/portal/src/components/offers/table/OffersTable.tsx +++ b/apps/portal/src/components/offers/table/OffersTable.tsx @@ -55,9 +55,9 @@ export default function OffersTable({ [ 'offers.list', { - // Location: 'Singapore, Singapore', // TODO: Geolocation - cityId: cityFilter, companyId: companyFilter, + // Location: 'Singapore, Singapore', // TODO: Geolocation + countryId: cityFilter, currency, limit: NUMBER_OF_OFFERS_IN_PAGE, offset: pagination.currentPage, diff --git a/apps/portal/src/server/router/offers/offers.ts b/apps/portal/src/server/router/offers/offers.ts index fd0bc258..490180f0 100644 --- a/apps/portal/src/server/router/offers/offers.ts +++ b/apps/portal/src/server/router/offers/offers.ts @@ -42,8 +42,8 @@ const getYoeRange = (yoeCategory: number | null | undefined) => { export const offersRouter = createRouter().query('list', { input: z.object({ - cityId: z.string().nullish(), companyId: z.string().nullish(), + countryId: z.string().nullish(), currency: z.string().nullish(), dateEnd: z.date().nullish(), dateStart: z.date().nullish(), @@ -131,10 +131,14 @@ export const offersRouter = createRouter().query('list', { where: { AND: [ { - cityId: - input.cityId != null && input.cityId.length !== 0 - ? input.cityId - : undefined, + location: { + state: { + countryId: + input.countryId != null && input.countryId.length !== 0 + ? input.countryId + : undefined, + }, + }, }, { offersIntern: { @@ -247,10 +251,14 @@ export const offersRouter = createRouter().query('list', { where: { AND: [ { - cityId: - input.cityId != null && input.cityId.length !== 0 - ? input.cityId - : undefined, + location: { + state: { + countryId: + input.countryId != null && input.countryId.length !== 0 + ? input.countryId + : undefined, + }, + }, }, { offersIntern: {