import api from "@/util/api";

export const getMissions = async () => {
    return await api.get("/mission/missions").then((res) => res.data);
};

export const getMissionLogs = async () => {
    return await api.get("/mission/mission-logs/").then((res) => res.data);
}

export const createMissionLog = async (data = {}) => {
    const timestp = new Date().toISOString();
    console.log(data);
    return await api.post('mission/mission-logs',{
        mission: data.mission,
        user_id: data.user_id,
        status: 'completed',
        coin: data.coin,
        point: data.point,
        image_log: data.image_log,
        completed_at: timestp,
        claimed_at: timestp,
    });
}

export const updateMissionLog = async(missionId ,data = {}) =>{
    return await api.patch(`missions/${missionId}/`, data, {
      headers: { "Content-Type": "multipart/form-data" },
    });
}