import React, { createContext, useContext, useState } from 'react';

export type ViewType = 'bridge' | 'road' | 'location';

interface BridgeManageContextType {
  viewType: ViewType;
  setViewType: (type: ViewType) => void;
  isUsingValue: boolean;
  setIsUsingValue: (value: boolean) => void;
}

const BridgeManageContext = createContext<BridgeManageContextType>({
  viewType: 'bridge',
  setViewType: () => {},
  isUsingValue: false,
  setIsUsingValue: () => {}
});

interface BridgeManageProviderProps {
  children: React.ReactNode;
  initialViewType?: ViewType;
}

export const BridgeManageProvider: React.FC<BridgeManageProviderProps> = ({ 
  children, 
  initialViewType = 'bridge' 
}) => {
  const [viewType, setViewType] = useState<ViewType>(initialViewType);
  const [isUsingValue, setIsUsingValue] = useState(false);

  return (
    <BridgeManageContext.Provider value={{ viewType, setViewType, isUsingValue, setIsUsingValue }}>
      {children}
    </BridgeManageContext.Provider>
  );
};

export const useBridgeManage = () => useContext(BridgeManageContext); 