import type { invitations, users } from "@folo-services/drizzle"
import type { InferSelectModel } from "drizzle-orm"

import type { SerializedModel, SuccessResponse } from "../../types"

// Database types
type Invitation = SerializedModel<InferSelectModel<typeof invitations>>
type User = SerializedModel<InferSelectModel<typeof users>>

// Request types
export interface CreateInvitationRequest {
  TOTPCode?: string
}

export interface UseInvitationRequest {
  code: string
}

// Response data types
export interface InvitationWithUser extends Omit<Invitation, "fromUserId"> {
  fromUser: Pick<User, "id" | "name" | "image">
}

// Response types
export type GetInvitationLimitationResponse = SuccessResponse<number>
export type GetInvitationsListResponse = SuccessResponse<InvitationWithUser[]>
export type CreateInvitationResponse = SuccessResponse<string>
export type UseInvitationResponse = SuccessResponse<null>
