import { setLoadingStatus } from '../Reducer/Common'
import { clientDropDownList } from '../Reducer/InitialReducer'
import { ErrorMessage } from '../Utils/Notification'
import axios from '../Config/AxiosConfig'
import { type Dispatch } from '@reduxjs/toolkit'

export const GetClientContactInfo = (
    dispatch: Dispatch,
    businessTypeId: string,
    referenceId: string
): void => {
    dispatch(setLoadingStatus({ status: true }))
    axios
        .get(`/api/GetClientContactInfo/${businessTypeId}/${referenceId}`)
        .then((response) => {
            if (response.status === 200) {
                // Assuming response.data contains the required data format
                // You might need to adjust this according to the actual response structure
                dispatch(clientDropDownList(response.data))
            } else {
                ErrorMessage(response.data.operationMsg)
            }
            dispatch(setLoadingStatus({ status: false }))
        })
        .catch((error) => {
            console.error('Error fetching client contact info:', error)
            dispatch(setLoadingStatus({ status: false }))
        })
}

// export const GetEmailTemplateTypeList = (
//     dispatch: Dispatch,
//     businessTypeId: string,
//     referenceId: string,
//     templateId: string
// ): void => {
//     dispatch(setLoadingStatus({ status: true }))
//     axios
//         .get(
//             `/api/Email/GetEmailTemplatePropertyByReferenceId/${businessTypeId}/${referenceId}/${templateId}`
//         )
//         .then((response) => {
//             if (response.status === 200) {
//                 const templateTypeList: ListFrontEndInterface[] =
//                     response?.data?.data.map((data: ListBackendInterface) => {
//                         return {
//                             value: data.stdId,
//                             label: data.stdName,
//                         }
//                     })

//                 dispatch(invoiceEmailTemplateTypeList(templateTypeList))
//             } else {
//                 ErrorMessage(response.data.operationMsg)
//             }
//             dispatch(setLoadingStatus({ status: false }))
//         })
//         .catch((error) => {
//
//             console.error('Error fetching posts:', error)
//             dispatch(setLoadingStatus({ status: false }))
//         })
// }
