42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { z } from "zod"
|
|
|
|
// import * as api from "@/lib/api"
|
|
import { protectedProcedure } from "@/server/trpc"
|
|
|
|
import { getSasToken } from "./getSasToken"
|
|
|
|
const outputSchema = z.object({
|
|
transferState: z.enum(["success"]),
|
|
})
|
|
|
|
const transferPointsInputSchema = z.object({
|
|
points: z.number(),
|
|
})
|
|
|
|
export const transferPoints = protectedProcedure
|
|
.output(outputSchema)
|
|
.input(transferPointsInputSchema)
|
|
.mutation(async function ({ ctx, input }) {
|
|
const sasAuthToken = getSasToken()
|
|
|
|
console.log("[SAS] transfer points")
|
|
console.log({ sasAuthToken })
|
|
console.log({ points: input.points })
|
|
|
|
// const apiResponse = await api.post(api.endpoints.v1.Profile.link, {
|
|
// headers: {
|
|
// Authorization: `Bearer ${ctx.session.token.access_token}`,
|
|
// },
|
|
// body: {
|
|
// partner: "sas_eb",
|
|
// tocDate: getCurrentDateWithoutTime(),
|
|
// partnerSpecific: {
|
|
// eurobonusAccessToken: sasAuthToken,
|
|
// },
|
|
// },
|
|
// })
|
|
|
|
console.log(`[SAS] transfer points success`)
|
|
return { transferState: "success" }
|
|
})
|