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

const SpecialityFormContext = createContext();

export const useSpecialityForm = () => useContext(SpecialityFormContext);

export const SpecialityFormProvider = ({ children, initialSpeciality }) => {
  const [formData, setFormData] = useState(() => ({
    name: initialSpeciality.name || '',
    color_code: initialSpeciality.color_code || '#FFFFFF',
  }));

  return (
    <SpecialityFormContext.Provider value={{ formData, setFormData }}>
      {children}
    </SpecialityFormContext.Provider>
  );
};
