Skip to content

Commit

Permalink
fix: update mock housing handler (POST to GET)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicguillois committed Dec 17, 2024
1 parent 6da9b49 commit d1e4c13
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions frontend/src/mocks/handlers/housing-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,24 @@ export const housingHandlers: RequestHandler[] = [
http.get<Record<string, never>, HousingPayload, HousingCountDTO>(
`${config.apiEndpoint}/api/housing/count`,
async ({ request }) => {
const payload = await request.json();
const url = new URL(request.url);
const queryParams = url.searchParams;
const campaignIds =
queryParams.get('campaignIds')?.split(',') ?? undefined;
const housingKinds =
queryParams.get('housingKinds')?.split(',') ?? undefined;
const status = queryParams.get('status')
? [Number(queryParams.get('status'))]
: undefined;
const statuses =
status ??
queryParams.get('statusList')?.split(',').map(Number) ??
undefined;

const subset: HousingDTO[] = fp.pipe(
filterByCampaign(payload.filters?.campaignIds?.filter((id): id is string => id !== null)),
filterByHousingKind(payload.filters?.housingKinds),
filterByStatus(
payload.filters?.status
? [payload.filters.status]
: payload.filters?.statusList
)
filterByCampaign(campaignIds),
filterByHousingKind(housingKinds),
filterByStatus(statuses)
)(data.housings);

const owners: number = fp.uniqBy(
Expand Down

0 comments on commit d1e4c13

Please sign in to comment.