
import { API_FAST_PLANS, API_FAST_CHECKS,API_FAST_CLOCKS, API_CLOCK_RECORDS } from './http/api'
import { request } from './http/request';

export const getPlans = () => {
    return new Promise((resolve) => {
        request({
            url: API_FAST_PLANS, method: 'GET', data: {}
        }).then(res => {
            resolve(res);
            console.log(res);
            // dispatch(loginSuccess(res));
        })
    })
}

export const setPlan = (params: Record<string, any> | undefined) => {
    return new Promise((resolve) => {
        request({
            url: API_FAST_PLANS, method: 'POST', data: { ...params }
        }).then(res => {
            resolve(res);
            console.log(res);
            // dispatch(loginSuccess(res));
        })
    })
}

export const getChecks = () => {
    return new Promise((resolve) => {
        request({
            url: API_FAST_CHECKS, method: 'GET', data: {}
        }).then(res => {
            resolve(res);
        })
    })
}

export const getClocks = () => {
    return new Promise((resolve) => {
        request({
            url: API_FAST_CLOCKS, method: 'GET', data: {}
        }).then(res => {
            resolve(res);
        })
    })
}

export const getClockRecords = (params:any)=>{
    return new Promise((resolve) => {
        request({
            url: API_CLOCK_RECORDS, method: 'GET', data: {...params}
        }).then(res => {
            resolve(res);
        })
    })

}

export const recordCheck = (params: Record<string, any> | undefined) => {
    return new Promise((resolve) => {
        request({
            url: API_FAST_CLOCKS, method: 'POST', data: { ...params }
        }).then(res => {
            resolve(res);
        })
    })
}

export const delRecord = (id: string) => {
    return new Promise((resolve) => {
        request({
            url: API_CLOCK_RECORDS + '/' + id, method: 'DELETE', data: {}
        }).then(res => {
            resolve(res);
        })
    })
}