fix: update friendTransaction model according to API

This commit is contained in:
Arvid Norlin
2024-05-15 14:01:19 +02:00
parent 9ef9de840c
commit 795fe400cb
4 changed files with 76 additions and 70 deletions
+28 -30
View File
@@ -195,33 +195,32 @@ export const userQueryRouter = router({
if (cursor) {
params.set("offset", cursor.toString())
}
// TODO: att these once API data is confirmed to be available
// const apiResponse = await api.get(
// api.endpoints.v1.friendTransactions,
// {
// headers: {
// Authorization: `Bearer ${opts.ctx.session.token.access_token}`,
// },
// },
// params
// )
// if (!apiResponse.ok) {
// switch (apiResponse.status) {
// case 400:
// throw badRequestError()
// case 401:
// throw unauthorizedError()
// case 403:
// throw forbiddenError()
// default:
// throw internalServerError()
// }
// }
const apiResponse = await api.get(
api.endpoints.v1.friendTransactions,
{
headers: {
Authorization: `Bearer ${opts.ctx.session.token.access_token}`,
},
},
params
)
// const apiJson = await apiResponse.json()
const apiJson = friendTransactionsMockJson
debugger
if (!apiResponse.ok) {
switch (apiResponse.status) {
case 400:
throw badRequestError()
case 401:
throw unauthorizedError()
case 403:
throw forbiddenError()
default:
throw internalServerError()
}
}
const apiJson = await apiResponse.json()
// const apiJson = friendTransactionsMockJson
if (!apiJson.data?.length) {
// throw internalServerError()
@@ -243,15 +242,14 @@ export const userQueryRouter = router({
return {
data: verifiedData.data.data.map(({ attributes }) => ({
checkInDate: attributes.checkInDate,
checkOutDate: attributes.checkOutDate,
checkinDate: attributes.checkinDate,
checkoutDate: attributes.checkoutDate,
awardPoints: attributes.awardPoints,
hotelName: attributes.hotelInformation.hotelName,
city: attributes.hotelInformation.city,
hotelName: attributes.hotelInformation?.hotelName,
city: attributes.hotelInformation?.city,
nights: attributes.nights,
confirmationNumber: attributes.confirmationNumber,
})),
nextCursor,
}
} catch (error) {