import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
const BaseService = {
    useBaseInfo: (id: string) => {
        const { data: baseInfoRes } = useRequest(
            () =>
                request.get(
                    '/cloud/gps-reborn/sdk/car/getCarInfoByProductType',
                    {
                        data: { carId: id },
                    },
                ),
            { refreshDeps: [id] },
        );
        const info = baseInfoRes?.data;
        const baseInfo = [
            {
                label: '所属单位',
                key: 'deptName',
                value: info?.deptName,
            },
            {
                label: '使用单位',
                key: 'useUnitName',
                value: info?.useUnitName,
            },
            {
                label: '所属标段',
                key: 'bidSectionName',
                value: info?.bidSectionName,
            },
            {
                label: '行政区划',
                key: 'divisionName',
                value: info?.divisionName,
            },
            {
                label: '责任人',
                key: 'manageStaffName',
                value: info?.manageStaffName,
            },
            {
                label: '联系人',
                key: 'contact',
                value: info?.contact,
            },
            {
                label: '联系电话',
                key: 'contactWay',
                value: info?.contactWay,
            },
        ];
        // 报警类型汇总
        const { data: alarmTypesRes } = useRequest(
            () =>
                request.get('/cloud/gps-reborn/alarm/level/queryAllAlarmTypes'),
            { refreshDeps: [] },
        );

        return {
            baseInfo,
            info,
            alarmTypes: alarmTypesRes?.data || []
        };
    },
};

export { BaseService };
