
import moment from "moment";
import { User } from "../models/user";
import { del, get, post, put } from "./api_helper";
import { FileService } from "./file.service";
import * as url from "./url_helper";
import { SchoolLogoModel } from "../../pages/settings/site-configuration/model/school-logo";
import { CreateInvoiceModel } from "../../pages/tutor-area/models/AutomatedInvoice";

//Gets the logged in user token from local session
 export const getLoggedInUser = () => {
    if(localStorage.getItem("authUser")|| ""){
        const token:User = JSON.parse(atob(localStorage.getItem("authUser") || ""))
        if(token)
            return token;
        return null;
    }
   
}
 function getLoggedInUserToken(){
    if(localStorage.getItem("authUser") != undefined){
    const token:User = JSON.parse(atob(localStorage.getItem("authUser") || ""))

    if(token.token)
        return 'Bearer '+ token.token.token;
    return null;
    }
}


const fileservice = new FileService()

const isUserAuthenticated = () => {
    return getLoggedInUser() !== null;
}

export {isUserAuthenticated,getLoggedInUserToken}

//AUTHENTICATION
export const loginUser = (userData:any) => post(url.LOGIN_URL,userData)
export const createAdminUser = (userData:any) => post(url.CREATE_ADMIN,userData)
export const inviteAdminUserAPI = (userData:any) => post(url.INVITE_ADMIN,userData)
export const validateLoginTokenAPI = (token:any) => post(`${url.VALIDATE_TOKEN}/${token}`,{})
export const requestPasswordResetAPI = (body:any) => post(`${url.REQUEST_PASSWORD_RESET}`,body)
export const changePasswordAPI = (body:any,token:any) => post(`${url.CHANGE_PASSWORD}/${token}`,body)


//Dashboard
export const getDashboardResourceMetricsAPI = (startDate?:any, endDate?:any) => get(`metrics/resource${startDate ? `?from=${moment(startDate).format('YYYY-MM-DD')}&to=${moment(endDate).format('YYYY-MM-DD')}`: ''}`);
export const getDashboardTutorMetricsAPI = (startDate?:any, endDate?:any) =>get(`metrics/tutor${startDate ? `?from=${moment(startDate).format('YYYY-MM-DD')}&to=${moment(endDate).format('YYYY-MM-DD')}`: ''}`);
export const getDashboardFinanceMetricsAPI = (startDate?:any, endDate?:any) =>get(`metrics/finance${startDate ? `?from=${moment(startDate).format('YYYY-MM-DD')}&to=${moment(endDate).format('YYYY-MM-DD')}`: ''}`);

//Classes
export const getClasses = (page?:any,limit?:any,query?:any) => get(`${url.GET_CLASSES}?page=${page || 1}&limit=${limit}&name=${query}`)
export const createClassApi = (body:any) => post(url.CREATE_CLASS,body);
export const updateClassApi = (body:any) => put(`${url.UPDATE_CLASS}/${body.classId}`,body)
export const deleteClassApi = (id:any) => del(`${url.DELETE_CLASS}/${id}`)


//Lesson Plan
export const getLessonPlan = (page?:any,limit?:any,subject?:any) => get(`${url.GET_LESSONPLAN}/?page=${page || 1}&limit=${limit}${subject ? `&subject=${subject}`:""}`)
export const searchLessonPlan = (subject?:any,page?:any) => get(`${url.GET_LESSONPLAN}?${subject ? `search=${subject}`:""}&page=${page || 1}`)
export const searchLessonPlanByClassSubjectQuery = (subject?:any,className?:any,query?:any) => get(`${url.GET_LESSONPLAN}?subject=${subject}&className=${className}&search=${query}&limit=100`)
export const searchLessonPlanByClassSubject = (subject?:any,className?:any) => get(`${url.GET_LESSONPLAN}?subject=${subject}&className=${className}&limit=100`)
export const updateLessonPlan = (lessonplan?:any,id?:any) => put(`${url.GET_LESSONPLAN}/${id}`,fileservice.uploadLessonPlan(lessonplan))
export const deleteLessonPlan = (id:any) => del(`${url.GET_LESSONPLAN}/${id}`)
export const downloadLessonPlanDoc = (docname?:any,body?:any) => get(`${url.DOWNLOAD_LESSONPLAN}/${docname}/doc`,{responseType: "blob"}).then((res)=>{
    fileservice.downloadFile(res,docname)
})
export const downloadLessonPlanPDF = (docname?:any,body?:any) => get(`${url.DOWNLOAD_LESSONPLAN}/${docname}/pdf`,{responseType: "blob"}).then((res)=>{
    fileservice.downloadFile(res,docname)
})
export const getLessonPicture = (id?:any) => get(`${url.GET_LESSONPICTURE}/${id}`)
export const deleteLessonPicture = (id:any) => del(`${url.GET_LESSONPICTURE}/${id}`)
export const addLessonPicture =(body:any) => post(url.GET_LESSONPICTURE,body);
export const uploadLessonPlan = async (lessonplan?:any) => {
    let body =  fileservice.uploadLessonPlan(lessonplan)
    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(url.GET_LESSONPLAN,body,config)
}
export const uploadBulkLessonPlan = async (lessonplan?:any) => {
    let excelupload = new FormData();
    excelupload.append('excel',lessonplan.excel)
    excelupload.append('classId',lessonplan.classId)
    excelupload.append('subjectId', lessonplan.subjectId)

    let zipUpload = new FormData();
    zipUpload.append('zip',lessonplan.zip)

    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(url.BULK_UPLOAD_LESSONPLAN_EXCEL,excelupload,config).then(()=>{
    post(url.BULK_UPLOAD_LESSONPLAN_ZIP,zipUpload,config)
   })
}
export const getLessonPlanImages = (lessonId:any) => get(`${url.GET_LESSONPLAN_IMG}/${lessonId}`)
export const addLessonPlanImage = async (lessonplanid:any,file:File[]) => {

    let body =  fileservice.singleUpload(lessonplanid, file[0])
    file.map((img) => {
        body.append('lesson_img',img)
    })

    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(url.ADD_LESSONPLAN_IMG,body,config)
}
export const bulkdeleteLessonPlan = (items:any) => del(`${url.GET_LESSONPLAN}`,{data:{ids:[...items]}})



//Subjects
export const getSubjectsAPI = (page?:any,limit?:any,query?:any) => get(`${url.GET_SUBJECTS}?page=${page || 1}&limit=${limit}&name=${query}`)
export const createSubjectpi = (body:any) => post(url.CREATE_SUBJECT,body);
export const updateSubjectApi = (body:any) => put(`${url.UPDATE_SUBJECT}/${body.subjectId}`,body)
export const deleteSubjectApi = (id:any) => del(`${url.DELETE_SUBJECT}/${id}`)

//AssignSubject
export const getAssignedSubjectsAPI = (page?:any,limit?:any,query?:any| "") => get(`${url.GET_ASSIGNSUBJECTS}?page=${page || 1}&limit=${limit}&subject=${query}&className=${query}`)
export const assignSubjectClassAPI = (body:any) => post(url.CREATE_ASSIGNSUBJECT,body);
export const deleteSubjectClassApi = (id:any) => del(`${url.DELETE_ASSIGNSUBJECT}/${id}`)
export const filterSubjectByClass = (page?:any,limit?:any,className?:any| "",subject?:any| "") => get(`${url.GET_ASSIGNSUBJECTS}?page=${page || 1}&limit=${limit}&class=${className}&subject=${subject}`)
export const getSubjectsByClassAPI = (classname?:string,subject?:string) => get(`${url.GET_ASSIGNSUBJECTS}?className=${classname}${subject ? `&subject=${subject}`:""}`)

//Packages
export const getPackagesApi = (page?:any,limit?:any,query?:any,free?:any) => get(`${url.GET_PACKAGES}?page=${page || 1}&limit=${limit}&search=${query}&free=${free}`)
export const createPackageApi = (body:any) => post(url.CREATE_PACKAGE,body);
export const updatePackageApi = (body:any) => put(`${url.UPDATE_PACKAGE}/${body.id}`,body)
export const deletePackageApi = (id:any) => del(`${url.DELETE_PACKAGE}/${id}`)

export const bulkdeletePackageAPI = (items:any) => del(`${url.DELETE_PACKAGE}`,{data:{ids:[...items]}})


//Techbased Resources
export const getTechBasedResourcessAPI = (page?:any,limit?:any,query?:any) => get(`${url.GET_TECHBASEDRESOURCE}?page=${page || 1}&limit=${limit}`)
export const searchTechBasedResourcessAPI = (query?:any,page?:any,limit?:any) => get(`${url.GET_TECHBASEDRESOURCE}?${query ? `search=${query}`:""}&page=${page || 1}&limit=${limit}`)
export const deleteTechBasedResourcesApi = (id:any) => del(`${url.DELETE_TECHBASEDRESOURCE}/${id}`)
export const createTechBasedAPI = async (techresource:any,file:File[])=> {
    let body =  fileservice.postFormData(techresource)
    if(file){
        file.map(f => {
            body.append('tbr_img',f)
        })
    }

    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(url.CREATE_TECHBASEDRESOURCE,body,config)
}
export const bulkdeleteTBR = (items:any) => del(`${url.DELETE_TECHBASEDRESOURCE}`,{data:{ids:[...items]}})


//Component 
export const getTechBasedComponentAPI = (page?:any,limit?:any,query?:any) => get(`${url.GET_COMPONENTS}?page=${page || 1}&limit=${limit}&name=${query}&shortName${query}`)


//Media Options
export const getMediaFormatAPI = () => get(`${url.GET_MEDIA_FORMART}`)
export const getMediaCategoryAPI = () => get(`${url.GET_MEDIA_CAT}`)
export const getMediaAppsAPI = () => get(`${url.GET_MEDIA_APPS}`)


//Analytics and Reporting
export const getUserAnalyticsAPI = (page?:any,limit?:any) => get(`${url.GET_USER_SEARCH_ANALYTICS}?page=${page || 1}&limit=${limit}`)
export const searchUserAnalyticsAPI = (query?:any,page?:any,params?:any) => get(`${url.GET_USER_SEARCH_ANALYTICS}?page=${page || 1}&${params}`)
export const deleteUserAnalyticsAPI = (id:any) => del(`${url.DELETE_USER_SEARCH_ANALYTICS}/${id}`)
export const bulkdeleteUserAnalyticsAPI = (items:any) => del(`${url.DELETE_USER_SEARCH_ANALYTICS}`,{data:{ids:[...items]}})
export const getLessonSatisfactionAPI = () => get(`${url.GET_LESSON_SATISFACTION}`)
export const getTBTSatisfactionAPI = () => get(`${url.GET_TBT_SATISFACTION}`)
export const generateCSVReport = (from?:any,to?:any,type?:any) => get(`${url.GENERATE_EXCEL_REPORT}?from=${from}&to=${to}&type=${type}`,{responseType: "blob"}).then((res)=>{
    fileservice.downloadFile(res,`report.${type}`)
})
export const generateLessonReportAPI = (params:any) => get(`${url.GENERATE_LESSON_REPORT}?${params}`)
export const generateTBTReportAPI = (params:any) => get(`${url.GENERATE_TBT_REPORT}?${params}`)

//subscriptions
export const getSubscriptionsAPI = (page?:any,limit?:any,status?:any) => get(`${url.GET_SUBSCRIPTIONS}?page=${page || 1}&limit=${limit}&status=${status}`)
export const searchSubscriptionsAPI = (query?:any,page?:any,status?:any) => get(`${url.GET_SUBSCRIPTIONS}?page=${page || 1}&search=${query}&status=${status}`)
export const bulkdeleteSubscriptions = (items:any) => del(`${url.DELETE_SUBSCRIPTIONS}`,{data:{ids:[...items]}})

//Tutor Areas
export const getTutorsAPI = (page?:any,limit?:any,status?:any) => get(`${url.GET_TUTORS}?page=${page || 1}&limit=${limit}&type=${status}`)
export const searchTutorsAPI = (query?:any,page?:any,status?:any) => get(`${url.GET_TUTORS}?page=${page || 1}&search=${query}&type=${status}`)
export const getTutorDetailsAPI = (tutorid?:any) => get(`${url.GET_TUTORS}/${tutorid}`)
export const getTutorActivityLogAPI = (page?:any,limit?:any,tutorid?:any) => get(`${url.GET_TUTORS}/${tutorid}/activities?page=${page || 1}&limit=${limit}`)
export const deactivateTutorAPI = (tutorid?:any) => del(`${url.GET_TUTORS}/${tutorid}`,{})
export const bulkdeleteTutorAPI = (items:any) => del(`${url.GET_TUTORS}`,{data:{ids:[...items]}})



//Home Tutor Order
export const getHomeTutorOrderAPI = (page?:any,limit?:any,status?:any) => get(`${url.GET_HOME_TUTORS_ORDER}?page=${page || 1}&limit=${limit}&status=${status}`)
export const searchHomeTutorOrdeAPI = (page?:any,params?:any) => get(`${url.GET_HOME_TUTORS_ORDER}?page=${page || 1}&${params}`)
export const getSingleHomeTutorOrderAPI = (tutorid?:any) => get(`${url.GET_HOME_TUTORS_ORDER}/${tutorid}`)
export const recordOrderPaymentAPI = (orderid:any,body:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${orderid}/record-payment`,body)
export const bulkdeleteHomeTutorOrderAPI = (items:any) => del(`${url.GET_HOME_TUTORS_ORDER}`,{data:{ids:[...items]}})
export const singledeleteHomeTutorOrderAPI = (id:any) => del(`${url.GET_HOME_TUTORS_ORDER}/${id}`)
export const getPaidOrderOverviewAPI = () => get(`${url.GET_HOME_TUTOR_OVERVIEW}`)
export const updateHomeTutorOrderAPI = (orderid:any,order:any) => put(`${url.GET_HOME_TUTORS_ORDER}/${orderid}`,order)
export const getAutomatedTutorMatchingAPI = (orderid:any,page?:any,limit?:any) => get(`${url.GET_HOME_TUTORS_ORDER}/${orderid}/match?page=${page || 1}&limit=${limit}`)
export const assignTutorToOrderAPI = (requestId:any,body:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${requestId}/assign`,body)
export const sendAssignmentEmailAPI = (requestId:any,body:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${requestId}/send-assignment-email`,body)

export const sendEmailAPI = (id:any,email:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${id}/send-offer-email`,{"emails":email})
export const sendTutorOfferViaWhatsappAPI = (id:any,phones:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${id}/send-offer-whatsapp`,{"phoneNumbers":phones})
export const sendReportLinkAPI = (id:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${id}/send-report`,{})
export const recordTutorPayoutAPI = (requestId:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${requestId}/record-tutor-payout`,{})
export const closeTutoringAPI = (requestId:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${requestId}/close`,{})
export const sendTutoringReceiptAPI = (id:any,email:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${id}/send-receipt`,{"email":email})
export const generateTutorOfferAPI = (requestId?:any) => get(`${url.GET_HOME_TUTORS_ORDER}/${requestId}/generate-offer`)
export const duplicateOrderAPI = (id:any) => post(`${url.GET_HOME_TUTORS_ORDER}/${id}/duplicate`,{})


//TutorLearningReport
export const getTutorLearningReportAPI = (page?:any,limit?:any) => get(`${url.GET_TUTOR_LEARNING_REPORT}?page=${page || 1}&limit=${limit}`)
export const searchTutorLearningReportAPI = (query?:any,page?:any) => get(`${url.GET_TUTOR_LEARNING_REPORT}?page=${page || 1}&search=${query}`)
export const getSingleTutorLearningReportAPI = (id?:any) => get(`${url.GET_TUTOR_LEARNING_REPORT}/${id}`)
export const approveReportAPI = (id?:any) => post(`${url.GET_TUTOR_LEARNING_REPORT}/${id}/approve`,{})
export const submitReportAPI = (body:any) => post(`${url.GET_TUTOR_LEARNING_REPORT}`,body)
export const updateReportAPI = (body:any,id:any) => put(`${url.GET_TUTOR_LEARNING_REPORT}/${id}`,body)
export const sendParentReportAPI = (id:any) => post(`${url.GET_TUTOR_LEARNING_REPORT}/${id}/send`,{})
export const sendParentReporWhatsapptAPI = (id:any,number:any) => post(`${url.GET_TUTOR_LEARNING_REPORT}/${id}/send-whatsapp`,number)


//Automated Tutor Invoice
export const getAutomatedTutorInvoiceAPI = (page?:any,limit?:any,status?:any) => get(`${url.GET_AUTOMATED_TUTORS_INVOICE}?page=${page || 1}&limit=${limit}&status=${status}`)
export const searchAutomatedTutorInvoiceAPI = (page?:any,query?:any,status?:any) => get(`${url.GET_AUTOMATED_TUTORS_INVOICE}?page=${page || 1}&search=${query}&status=${status}`)
export const duplicateInvoiceAPI = (invoiceId:any) => post(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${invoiceId}/duplicate`,{})
export const createInvoiceAPI = (body:CreateInvoiceModel) =>{
    let formData = new FormData();
    formData = fileservice.postFormData(body);
    body.tutorCvs.map(e=>{
        formData.append('tutor_cvs',e)
    })
    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return post(`${url.GET_AUTOMATED_TUTORS_INVOICE}`,formData,config)
} 
export const updateInvoiceAPI = (invoiceId:any,body:any) =>{
    // let formData = new FormData();
    // formData = fileservice.postFormData(body);
    // // body.tutorCvs.map((e:any)=>{
    // //     formData.append('tutor_cvs',e)
    // // })
    // let config = {headers: {
    //     'content-Type': 'multipart/form-data'
    //   }}
  return  put(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${invoiceId}`,body)
} 
export const getSingleAutomatedTutorInvoiceAPI = (id?:any) => get(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${id}`)
export const sendReceiptAPI = (id:any,email:any) => post(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${id}/send-receipt`,{"email":email})
export const sendInvoiceAPI = (id:any) => post(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${id}/send`,{})
export const sendInvoiceWhatsAppAPI = (id:any,number:any) => post(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${id}/send-whatsapp`,number)
export const deleteInvoiceAPI = (id:any) => del(`${url.GET_AUTOMATED_TUTORS_INVOICE}/${id}`)


//Tutor Gallery
export const getTutorGalleryAPI = (page?:any,limit?:any) => get(`${url.GET_TUTORS_GALLERY}?page=${page || 1}&limit=${limit}`)
export const getSingleTutorProfileAPI = (id?:any) => get(`${url.GET_TUTORS_GALLERY}/${id}`)
export const searchTutorGalleryAPI = (query?:any,page?:any) => get(`${url.GET_TUTORS_GALLERY}?page=${page || 1}&search=${query}`)
export const createTutorAPI = async (tutorInfo:any,image:File) => {
    const formData = new FormData();
       
     Object.keys(tutorInfo).forEach((e)=>{
        formData.append(e, JSON.stringify(tutorInfo[e]).replace(/^"(.+(?="$))"$/, '$1'));
    })
    formData.append('tutor_photo',image)
    let body = formData
    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(url.CREATE_TUTOR,body,config)
}
export const deleteTutorAPI = (id:any) => del(`${url.GET_TUTORS_GALLERY}/${id}`)

export const updateTutorAPI = async (tutorInfo:any,image:File,id:number) => {
    const formData = new FormData();
       
     Object.keys(tutorInfo).forEach((e)=>{
        formData.append(e, JSON.stringify(tutorInfo[e]).replace(/^"(.+(?="$))"$/, '$1'));
    })
    formData.append('tutor_photo',image)
    let body = formData
    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await put(`${url.CREATE_TUTOR}/${id}`,body,config)
}


//Admin
export const getAdminUserAPI = (page?:any,limit?:any) => get(`${url.GET_ADMIN}?page=${page || 1}&limit=${limit}`)
export const searchAdminUserAPI = (page?:any,limit?:any,query?:any) => get(`${url.GET_ADMIN}?page=${page || 1}&limit=${limit}&search=${query}`)

export const updateAdminUserAPI = (id:any,body:any) => put(`${url.GET_ADMIN}/${id}`,body)
export const changeAdminPasswordUser = (id:any,body:any) => post(url.CREATE_ADMIN,body)
export const deleteAdminUsersAPI = (id:any) => del(`${url.GET_ADMIN}/${id}`)
export const getInvitesAPI = (page?:any,limit?:any) => get(`${url.GET_INVITES_ADMIN}?page=${page || 1}&limit=${limit}`)
export const resendInviteAPI = (body:any) => post(url.RESEND_INVITE_ADMIN,body)
export const deleteInviteAPI = (id:any) => del(`${url.GET_INVITES_ADMIN}/${id}`)


//User 
export const getUsersAPI = (page?:any,limit?:any,type?:any) => get(`${url.GET_USERS}?page=${page || 1}&limit=${limit}${type ? `&type=${type}`: ''} `)
export const getUserByIdAPI = (id:any) => get(`${url.GET_USERS}/${id}`)
export const searchUsersAPI = (query?:any,page?:any,type?:any) => get(`${url.GET_USERS}?page=${page || 1}&search=${query}${type ? `&type=${type}`: ''} `)
export const deleteUserAPI = (id:any) => del(`${url.GET_USERS}/${id}`)
export const suspendUserAPI = (id:any) => post(`${url.GET_USERS}/${id}/suspend`,{})
export const approveUserAPI = (id:any) => post(`${url.GET_USERS}/${id}/approve`,{})
export const unsuspendUserAPI = (id:any) => post(`${url.GET_USERS}/${id}/unsuspend`,{})

export const changeUserPaasswordAPI = (id:any,body:any) => put(`${url.GET_USERS}/${id}`,body)


//Notification
export const getNotificationsAPI = (query?:any,startDate?:any,endDate?:any) => get(`${url.GET_NOTIFICATIONS}?page=${1}&limit=${20}${query ? `&search=${query}`: ''}${startDate ? `&from=${moment(startDate).format('YYYY-MM-DD')}&to=${moment(endDate).format('YYYY-MM-DD')}`: ''}`)
export const getNitificationByIdAPI = (id:any) => get(`${url.GET_NOTIFICATIONS}/${id}`)


//Site Config
export const getSiteConfigAPI = () => get(`${url.GET_SITE_CONFIG}`)
export const updateSiteConfigAPI = (body:any) => put(`${url.UPDATE_SITE_CONFIG}`,body)


//School Logo
export const getSchLogosAPI = (page?:any,limit?:any) => get(`${url.GET_SCH_LOGOS}?page=${page || 1}&limit=${limit}`)
export const updateSchLogoAPI = async (schLogo:SchoolLogoModel) => {
    const formData = new FormData();
   formData.append('name',schLogo.name)
   formData.append('logo',schLogo.logo)

   let body = formData
   let config = {headers: {
       'content-Type': 'multipart/form-data'
     }}
     return await put(`${url.GET_SCH_LOGOS}/${schLogo.id}`,body,config)
}
export const addSchLogoAPI = async (schLogo:SchoolLogoModel) => {
    const formData = new FormData();
   formData.append('name',schLogo.name)
   formData.append('logo',schLogo.logo)

   let body = formData
   let config = {headers: {
       'content-Type': 'multipart/form-data'
     }}
     return await post(`${url.GET_SCH_LOGOS}`,body,config)
}

//Web statistics
export const getwebStatsAPI = () => get(`${url.GET_WEB_STATS}`)
export const updatewebStatsAPI = (body:any) => put(`${url.GET_WEB_STATS}`,body)


//Coding&Robotics Logo
export const getCodingRoboticsLogoAPI = (page?:any,limit?:any) => get(`${url.GET_CR_LOGO}?page=${page || 1}&limit=${limit}`)
export const deleteCodingRoboticsLogoAPI = (id?:any) => del(`${url.GET_CR_LOGO}/${id}`)
export const addCodingRoboticsLogoAPI = async (schLogo:any) => {
    const formData = new FormData();
    schLogo.map((e:any) => {

        formData.append('logo',e)
    })


   let body = formData
   let config = {headers: {
       'content-Type': 'multipart/form-data'
     }}
     return await post(`${url.GET_CR_LOGO}`,body,config)
}

//Feedback Summary
export const getFeedbackSummaryAPI = (page?:any,limit?:any,search?:any) => get(`${url.GET_FEEDBACKS}?page=${page || 1}&limit=${limit}${search ? `&search=${search}`: ''} `)
export const submitFeedbackSummaryAPI = (body:any) => post(`${url.GET_FEEDBACKS}`,body)
export const getFeedbackIdAPI = (id:any) => get(`${url.GET_FEEDBACKS}/${id}`)
export const bulkdeleteFeedbackAPI = (items:any) => del(`${url.GET_FEEDBACKS}`,{data:{ids:[...items]}})


//Data Migration
export const dataMigrationStage1API = async (file:any) => {
    const formData = new FormData();
    
    formData.append('excel',file)
    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(`${url.DATA_MIGRATION_STAGE1}`,formData,config)
}
export const dataMigrationStage2API = async (file:any) => {
    const formData = new FormData();
    
    formData.append('excel',file)
    let config = {headers: {
        'content-Type': 'multipart/form-data'
      }}
   return await post(`${url.DATA_MIGRATION_STAGE2}`,formData,config)
}
