'use client';
import { useEffect, useState } from 'react';
import { PHXClientQueryV3 } from '../../../../..';
import { getQrPrefixCodeQuery } from '../query';
export default function useWarehouse({ warehouseId }) {
    const [warehouseData, setWarehouseData] = useState();
    const getData = async () => {
        var _a;
        try {
            const { data } = await PHXClientQueryV3({
                query: getQrPrefixCodeQuery,
                variables: {
                    id: warehouseId,
                },
            });
            setWarehouseData((_a = data === null || data === void 0 ? void 0 : data.library_warehouse) === null || _a === void 0 ? void 0 : _a[0]);
        }
        catch (error) {
            console.log('error', error);
        }
    };
    useEffect(() => {
        if (warehouseId) {
            getData();
        }
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [warehouseId]);
    return {
        prefixQrCode: warehouseData === null || warehouseData === void 0 ? void 0 : warehouseData.qr_code_prefix,
        tem_name: warehouseData === null || warehouseData === void 0 ? void 0 : warehouseData.tem_name,
    };
}
//# sourceMappingURL=use-warehouse.js.map