import { get, post } from './request'
import { ApiResponse } from './common'

/**
 * 签到数据接口
 */
export interface SigninData {
    has_signin: boolean
    credits: number
    // signin_record: Array<{ date: string; points: number; expiryDate: string }>
}

/**
 * 签到响应接口
 */
export interface SigninResponse {
    credits: number
}

/**
 * 获取用户签到状态和积分信息
 * @returns Promise<SigninData>
 */
export const getSigninStatus = async (): Promise<ApiResponse> => {
    const response = await get<ApiResponse<SigninData>>('/api/user_fission/check_today_signin')
    return response
}

/**
 * 执行签到操作
 * @returns Promise<SigninResponse>
 */
export const performSignin = async (): Promise<ApiResponse> => {
    const response = await post<ApiResponse<SigninResponse>>('/api/user_fission/signin', {})
    return response
}
