'use client';

import { useReducer, useEffect } from 'react';
import { Card } from '@/components/ui/card';
import { soilDataReducer, initialSoilDataState, SoilDataState } from './components/soilDataReducer';
import SoilDataContent from './components/SoilDataContent';

export default function SoilDataPage() {
  const [state, dispatch] = useReducer(soilDataReducer, initialSoilDataState);

  useEffect(() => {
    // 加载存储的数据
    dispatch({ type: 'LOAD_FROM_STORAGE' });
  }, []);

  // 保存数据到localStorage
  useEffect(() => {
    dispatch({ type: 'SAVE_TO_STORAGE' });
  }, [state.samplePoints]);

  return (
    <div className="space-y-6">
      <SoilDataContent state={state} dispatch={dispatch} />
    </div>
  );
}