#
vincentlu
2025-12-16 17924fac6b08fb267a2d3622e5743fd0002775a6
zy-acs-flow/src/map/areaSettings/index.jsx
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useMemo } from 'react';
import React, { useState, useEffect } from 'react';
import { useTranslate } from "react-admin";
import {
    Drawer,
@@ -17,7 +17,7 @@
import { PAGE_DRAWER_WIDTH } from '@/config/setting';
import AreaBasicTab from './AreaBasicTab';
import AreaAdvancedTab from './AreaAdvancedTab';
import { getAreaInfo, fetchAgvListAll } from '../http';
import { getAreaInfo, fetchAgvListAll, updateAreaData, removeArea } from '../http';
const getAgvOptionId = (option) => {
    if (typeof option === 'string') {
@@ -120,16 +120,35 @@
        setActiveTab(newValue);
    };
    const handleSaveBasic = () => {
        // console.log({
        //     name,
        //     agvIds: agvList.map(getAgvOptionId),
        // });
        // placeholder for save logic
        setInitialBasic({
    const handleSaveBasic = async () => {
        const areaId = sprite?.data?.id;
        if (!areaId) {
            return;
        }
        const payload = {
            areaId,
            name,
            agvIds: agvList.map(getAgvOptionId),
        });
        };
        const success = await updateAreaData(payload);
        if (success) {
            setInitialBasic({
                name,
                agvIds: payload.agvIds,
            });
            fetchAreaInfo(areaId);
        }
    };
    const handleDeleteArea = async () => {
        const areaId = sprite?.data?.id;
        if (!areaId) {
            return;
        }
        const success = await removeArea(areaId);
        if (success) {
            onCancel?.();
        }
    };
    const handleSaveAdvanced = () => {
@@ -141,7 +160,6 @@
            agvList.map(getAgvOptionId),
            initialBasic.agvIds
        );
    return (
        <>
            <Drawer
@@ -204,6 +222,8 @@
                                                codeList={codeList}
                                                onSave={handleSaveBasic}
                                                disableSave={!basicDirty}
                                                onDelete={handleDeleteArea}
                                                canDelete={Boolean(sprite?.data?.id)}
                                            />
                                        )}
                                        {activeTab === 1 && (