From 4c07889a752af550c368ad18f489a7d5961e7083 Mon Sep 17 00:00:00 2001 From: Bryann Yeap Kok Keong Date: Wed, 2 Nov 2022 22:54:56 +0800 Subject: [PATCH] [offers][fix] Fix test pages --- .../src/pages/offers/test/createProfile.tsx | 29 +++++++++++++++++-- .../src/pages/offers/test/listOffers.tsx | 26 ++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/apps/portal/src/pages/offers/test/createProfile.tsx b/apps/portal/src/pages/offers/test/createProfile.tsx index 610d4e00..db1a7512 100644 --- a/apps/portal/src/pages/offers/test/createProfile.tsx +++ b/apps/portal/src/pages/offers/test/createProfile.tsx @@ -4,6 +4,20 @@ import { trpc } from '~/utils/trpc'; function Test() { const [createdData, setCreatedData] = useState(''); + const [cities, setCities] = useState< + Array<{ + id: string; + name: string; + state: { + country: { + id: string; + name: string; + }; + id: string; + name: string; + }; + }> + >([]); const [error, setError] = useState(''); const createMutation = trpc.useMutation(['offers.profile.create'], { @@ -89,6 +103,15 @@ function Test() { }); }; + trpc.useQuery(['locations.cities.list', { name: 'Singapore' }], { + onError(err) { + alert(err); + }, + onSuccess(data) { + setCities(data); + }, + }); + const handleClick = () => { createMutation.mutate({ background: { @@ -128,11 +151,11 @@ function Test() { }, offers: [ { + cityId: cities[0].id, comments: 'I am a Raffles Institution almumni', // Comments: '', companyId: 'cl9j4yawz0003utlp1uaa1t8o', jobType: 'FULLTIME', - location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), negotiationStrategy: 'Leveraged having multiple offers', offersFullTime: { @@ -157,10 +180,10 @@ function Test() { }, }, { + cityId: cities[0].id, comments: '', companyId: 'cl9j4yawz0003utlp1uaa1t8o', jobType: 'FULLTIME', - location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), negotiationStrategy: 'Leveraged having multiple offers', offersFullTime: { @@ -315,6 +338,7 @@ function Test() { isEditable: true, offers: [ { + cityId: cities[0].id, comments: 'this IS SO IEUHDAEUIGDI', company: { createdAt: new Date('2022-10-12T16:19:05.196Z'), @@ -329,7 +353,6 @@ function Test() { companyId: 'cl9j4yawz0003utlp1uaa1t8o', id: 'cl9i68fve000ntthj5h9yvqnh', jobType: 'FULLTIME', - location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), negotiationStrategy: 'Charmed the guy with my face', offersFullTime: { diff --git a/apps/portal/src/pages/offers/test/listOffers.tsx b/apps/portal/src/pages/offers/test/listOffers.tsx index b59f50c6..9faf0869 100644 --- a/apps/portal/src/pages/offers/test/listOffers.tsx +++ b/apps/portal/src/pages/offers/test/listOffers.tsx @@ -1,14 +1,38 @@ import React from 'react'; +import { useState } from 'react'; import { trpc } from '~/utils/trpc'; function Test() { + const [cities, setCities] = useState< + Array<{ + id: string; + name: string; + state: { + country: { + id: string; + name: string; + }; + id: string; + name: string; + }; + }> + >([]); + trpc.useQuery(['locations.cities.list', { name: 'Singapore' }], { + onError(err) { + alert(err); + }, + onSuccess(data) { + setCities(data); + }, + }); + const data = trpc.useQuery([ 'offers.list', { + cityId: cities[0].id, currency: 'SGD', limit: 100, - location: 'Singapore, Singapore', offset: 0, sortBy: '-totalCompensation', yoeCategory: 2,