mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
fixed to use hooks
This commit is contained in:
@@ -602,3 +602,48 @@ export const SuccessResponseSchema = z.object({
|
||||
});
|
||||
|
||||
export type SuccessResponse = z.infer<typeof SuccessResponseSchema>;
|
||||
|
||||
// subscription schemas
|
||||
|
||||
export const CreateCheckoutSessionRequestSchema = z.object({
|
||||
billingPeriod: z.enum(["monthly", "annual"]),
|
||||
});
|
||||
|
||||
export type CreateCheckoutSessionRequest = z.infer<typeof CreateCheckoutSessionRequestSchema>;
|
||||
|
||||
export const CreateCheckoutSessionResponseSchema = z.object({
|
||||
url: z.string(),
|
||||
});
|
||||
|
||||
export type CreateCheckoutSessionResponse = z.infer<typeof CreateCheckoutSessionResponseSchema>;
|
||||
|
||||
export const CreatePortalSessionResponseSchema = z.object({
|
||||
url: z.string(),
|
||||
});
|
||||
|
||||
export type CreatePortalSessionResponse = z.infer<typeof CreatePortalSessionResponseSchema>;
|
||||
|
||||
export const SubscriptionRecordSchema = z.object({
|
||||
id: z.number(),
|
||||
userId: z.number(),
|
||||
stripeCustomerId: z.string().nullable(),
|
||||
stripeSubscriptionId: z.string().nullable(),
|
||||
stripeSubscriptionItemId: z.string().nullable(),
|
||||
stripePriceId: z.string().nullable(),
|
||||
status: z.string(),
|
||||
currentPeriodStart: z.string().nullable().optional(),
|
||||
currentPeriodEnd: z.string().nullable().optional(),
|
||||
cancelAtPeriodEnd: z.boolean(),
|
||||
trialEnd: z.string().nullable().optional(),
|
||||
quantity: z.number(),
|
||||
createdAt: z.string().nullable().optional(),
|
||||
updatedAt: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export type SubscriptionRecord = z.infer<typeof SubscriptionRecordSchema>;
|
||||
|
||||
export const GetSubscriptionResponseSchema = z.object({
|
||||
subscription: SubscriptionRecordSchema.nullable(),
|
||||
});
|
||||
|
||||
export type GetSubscriptionResponse = z.infer<typeof GetSubscriptionResponseSchema>;
|
||||
|
||||
@@ -3,6 +3,10 @@ import { z } from "zod";
|
||||
import {
|
||||
ApiErrorSchema,
|
||||
AuthResponseSchema,
|
||||
CreateCheckoutSessionRequestSchema,
|
||||
CreateCheckoutSessionResponseSchema,
|
||||
CreatePortalSessionResponseSchema,
|
||||
GetSubscriptionResponseSchema,
|
||||
IssueByIdQuerySchema,
|
||||
IssueCommentCreateRequestSchema,
|
||||
IssueCommentDeleteRequestSchema,
|
||||
@@ -600,6 +604,38 @@ export const apiContract = c.router({
|
||||
200: z.array(timerListItemResponseSchema),
|
||||
},
|
||||
},
|
||||
|
||||
subscriptionCreateCheckoutSession: {
|
||||
method: "POST",
|
||||
path: "/subscription/create-checkout-session",
|
||||
body: CreateCheckoutSessionRequestSchema,
|
||||
responses: {
|
||||
200: CreateCheckoutSessionResponseSchema,
|
||||
400: ApiErrorSchema,
|
||||
404: ApiErrorSchema,
|
||||
500: ApiErrorSchema,
|
||||
},
|
||||
headers: csrfHeaderSchema,
|
||||
},
|
||||
subscriptionCreatePortalSession: {
|
||||
method: "POST",
|
||||
path: "/subscription/create-portal-session",
|
||||
body: emptyBodySchema,
|
||||
responses: {
|
||||
200: CreatePortalSessionResponseSchema,
|
||||
404: ApiErrorSchema,
|
||||
500: ApiErrorSchema,
|
||||
},
|
||||
headers: csrfHeaderSchema,
|
||||
},
|
||||
subscriptionGet: {
|
||||
method: "GET",
|
||||
path: "/subscription/get",
|
||||
responses: {
|
||||
200: GetSubscriptionResponseSchema,
|
||||
500: ApiErrorSchema,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type ApiContract = typeof apiContract;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
export type {
|
||||
ApiError,
|
||||
AuthResponse,
|
||||
CreateCheckoutSessionRequest,
|
||||
CreateCheckoutSessionResponse,
|
||||
CreatePortalSessionResponse,
|
||||
GetSubscriptionResponse,
|
||||
IssueByIdQuery,
|
||||
IssueCommentCreateRequest,
|
||||
IssueCommentDeleteRequest,
|
||||
@@ -46,6 +50,7 @@ export type {
|
||||
SprintsByProjectQuery,
|
||||
SprintUpdateRequest,
|
||||
StatusCountResponse,
|
||||
SubscriptionRecord as SubscriptionResponse,
|
||||
SuccessResponse,
|
||||
TimerEndRequest,
|
||||
TimerGetQuery,
|
||||
@@ -62,6 +67,10 @@ export type {
|
||||
export {
|
||||
ApiErrorSchema,
|
||||
AuthResponseSchema,
|
||||
CreateCheckoutSessionRequestSchema,
|
||||
CreateCheckoutSessionResponseSchema,
|
||||
CreatePortalSessionResponseSchema,
|
||||
GetSubscriptionResponseSchema,
|
||||
IssueByIdQuerySchema,
|
||||
IssueCommentCreateRequestSchema,
|
||||
IssueCommentDeleteRequestSchema,
|
||||
@@ -110,6 +119,7 @@ export {
|
||||
SprintsByProjectQuerySchema,
|
||||
SprintUpdateRequestSchema,
|
||||
StatusCountResponseSchema,
|
||||
SubscriptionRecordSchema as SubscriptionRecordApiSchema,
|
||||
SuccessResponseSchema,
|
||||
TimerEndRequestSchema,
|
||||
TimerGetQuerySchema,
|
||||
@@ -165,7 +175,7 @@ export type {
|
||||
SprintInsert,
|
||||
SprintRecord,
|
||||
SubscriptionInsert,
|
||||
SubscriptionRecord,
|
||||
SubscriptionRecord as SubscriptionRecordType,
|
||||
TimedSessionInsert,
|
||||
TimedSessionRecord,
|
||||
TimerState,
|
||||
|
||||
Reference in New Issue
Block a user