import { request } from '@vtx/utils';

import { useRequest } from 'ahooks';
const BaseData = {
    useBaseInfo: id => {
        const { data: baseInfoRes } = useRequest(
            () =>
                request.get('/cloud/jcss-reborn/facility/get', {
                    data: { id, coordType: 'bd09' },
                }),
            { refreshDeps: [id] },
        );
        const baseInfo = baseInfoRes?.data;
        // 基础信息
        let info = [
            { label: '名称', key: 'name', value: baseInfo?.name },
            { label: '编码', key: 'code', value: baseInfo?.code },
            { label: '管理单位', key: 'manageUnitName', value: baseInfo?.manageUnitName },
            { label: '行政区划', key: 'divisionName', value: baseInfo?.divisionName },
            { label: '收运单位', key: 'collectUnitName', value: baseInfo?.collectUnitName },
            { label: '地址', key: 'address', value: baseInfo?.address },
        ];

        // 图片
        const photos = JSON.parse(baseInfo?.photoIds || '[]');
        return { info, photos };
    },
};

export { BaseData };
