feat(WEB-170): edit profile view
This commit is contained in:
@@ -2,6 +2,8 @@ import { badRequestError, internalServerError } from "@/server/errors/trpc"
|
||||
import { protectedProcedure, router } from "@/server/trpc"
|
||||
import { getUserSchema } from "./output"
|
||||
|
||||
import { extendedUser } from "./temp"
|
||||
|
||||
export const userQueryRouter = router({
|
||||
get: protectedProcedure.query(async function (opts) {
|
||||
// TODO: Make request to get user data from Scandic API
|
||||
@@ -16,11 +18,20 @@ export const userQueryRouter = router({
|
||||
throw internalServerError()
|
||||
}
|
||||
const json = await response.json()
|
||||
const validJson = getUserSchema.parse(json)
|
||||
if (!validJson) {
|
||||
const validJson = getUserSchema.safeParse(json)
|
||||
if (!validJson.success) {
|
||||
throw badRequestError()
|
||||
}
|
||||
return validJson
|
||||
|
||||
const [firstname, lastname] = validJson.data.name.split(" ")
|
||||
const [phone] = validJson.data.phone.split(" ")
|
||||
return {
|
||||
...validJson.data,
|
||||
firstname,
|
||||
lastname,
|
||||
phone,
|
||||
...extendedUser,
|
||||
}
|
||||
}),
|
||||
benefits: router({
|
||||
current: protectedProcedure.query(async function (opts) {
|
||||
|
||||
101
server/routers/user/temp.ts
Normal file
101
server/routers/user/temp.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
export const challenges = {
|
||||
journeys: [
|
||||
{
|
||||
tag: "After work queen",
|
||||
title: "Try 3 Hotel Bars, Pocket 200 Points",
|
||||
},
|
||||
{
|
||||
tag: "Dine & Shine",
|
||||
title: "Visit 3 scandic Restaurants, Earn 150 Points",
|
||||
},
|
||||
],
|
||||
victories: [
|
||||
{
|
||||
tag: "Capital Explorer",
|
||||
title: "Stay in 3 scandic hotels, in three Capitals, Gain 2000 Points",
|
||||
},
|
||||
{
|
||||
tag: "Friends Feast",
|
||||
title: "Dine with 3 Buddies, Snag a Free Breakfast",
|
||||
},
|
||||
{
|
||||
tag: "Eco Warrior",
|
||||
title: "Choose Green, Get 500 Points",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export const shortcuts = [
|
||||
{
|
||||
href: "#",
|
||||
title: "My Benefit",
|
||||
},
|
||||
{
|
||||
href: "#",
|
||||
title: "Program overview",
|
||||
},
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "Scandic Friends shop",
|
||||
// },
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "Fire and safety",
|
||||
// },
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "Our sustainability work",
|
||||
// },
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "How you earn points",
|
||||
// },
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "How you use points",
|
||||
// },
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "Missing points",
|
||||
// },
|
||||
// {
|
||||
// href: "#",
|
||||
// title: "Our term and conditions",
|
||||
// },
|
||||
]
|
||||
|
||||
export const stays = [
|
||||
{
|
||||
dateArrive: new Date("04 27 2024"),
|
||||
dateDepart: new Date("04 28 2024"),
|
||||
guests: 2,
|
||||
hotel: "Scandic Helsinki Hub",
|
||||
},
|
||||
{
|
||||
dateArrive: new Date("05 27 2024"),
|
||||
dateDepart: new Date("05 28 2024"),
|
||||
guests: 2,
|
||||
hotel: "Scandic Örebro Central",
|
||||
},
|
||||
{
|
||||
dateArrive: new Date("06 27 2024"),
|
||||
dateDepart: new Date("06 28 2024"),
|
||||
guests: 2,
|
||||
hotel: "Scandic Oslo City",
|
||||
},
|
||||
]
|
||||
|
||||
export const extendedUser = {
|
||||
country: "United States",
|
||||
dob: dt("1977-07-05").format("YYYY-MM-DD"),
|
||||
journeys: challenges.journeys,
|
||||
membershipId: 30812404844732,
|
||||
nights: 14,
|
||||
points: 20720,
|
||||
qualifyingPoints: 5000,
|
||||
shortcuts,
|
||||
stays,
|
||||
victories: challenges.victories,
|
||||
}
|
||||
Reference in New Issue
Block a user