feat(SW-245): Delete credit card
This commit is contained in:
committed by
Michael Zetterberg
parent
2af17ef4d8
commit
e9a6499086
@@ -13,6 +13,8 @@ export namespace endpoints {
|
||||
upcomingStays = "booking/v1/Stays/future",
|
||||
previousStays = "booking/v1/Stays/past",
|
||||
hotels = "hotel/v1/Hotels",
|
||||
intiateSaveCard = `${creditCards}/initiateSaveCard`,
|
||||
deleteCreditCard = `${profile}/creditCards`,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const fetch = fetchRetry(global.fetch, {
|
||||
})
|
||||
|
||||
export async function get(
|
||||
endpoint: Endpoint | `${endpoints.v1.hotels}/${string}`,
|
||||
endpoint: Endpoint | `${Endpoint}/${string}`,
|
||||
options: RequestOptionsWithOutBody,
|
||||
params?: URLSearchParams
|
||||
) {
|
||||
@@ -38,7 +38,7 @@ export async function get(
|
||||
}
|
||||
|
||||
export async function patch(
|
||||
endpoint: Endpoint,
|
||||
endpoint: Endpoint | `${Endpoint}/${string}`,
|
||||
options: RequestOptionsWithJSONBody
|
||||
) {
|
||||
const { body, ...requestOptions } = options
|
||||
@@ -54,11 +54,12 @@ export async function patch(
|
||||
|
||||
export async function post(
|
||||
endpoint: Endpoint | `${Endpoint}/${string}`,
|
||||
options: RequestOptionsWithJSONBody
|
||||
options: RequestOptionsWithJSONBody,
|
||||
params?: URLSearchParams
|
||||
) {
|
||||
const { body, ...requestOptions } = options
|
||||
return fetch(
|
||||
`${env.API_BASEURL}/${endpoint}`,
|
||||
`${env.API_BASEURL}/${endpoint}${params ? `?${params.toString()}` : ""}`,
|
||||
merge.all([
|
||||
defaultOptions,
|
||||
{ body: JSON.stringify(body), method: "POST" },
|
||||
@@ -68,11 +69,12 @@ export async function post(
|
||||
}
|
||||
|
||||
export async function remove(
|
||||
endpoint: Endpoint,
|
||||
options: RequestOptionsWithOutBody
|
||||
endpoint: Endpoint | `${Endpoint}/${string}`,
|
||||
options: RequestOptionsWithOutBody,
|
||||
params?: URLSearchParams
|
||||
) {
|
||||
return fetch(
|
||||
`${env.API_BASEURL}/${endpoint}`,
|
||||
`${env.API_BASEURL}/${endpoint}${params ? `?${params.toString()}` : ""}`,
|
||||
merge.all([defaultOptions, { method: "DELETE" }, options])
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { createTRPCReact } from "@trpc/react-query"
|
||||
import { inferRouterInputs, inferRouterOutputs } from "@trpc/server"
|
||||
|
||||
import type { AppRouter } from "@/server"
|
||||
|
||||
export const trpc = createTRPCReact<AppRouter>()
|
||||
|
||||
export type RouterInput = inferRouterInputs<AppRouter>
|
||||
export type RouterOutput = inferRouterOutputs<AppRouter>
|
||||
|
||||
Reference in New Issue
Block a user