import { create } from "zustand";
import { persist } from "zustand/middleware";

interface AuthState {
  token: string | null;
  driverId: number | null;
  setSession: (token: string, driverId: number) => void;
  clear: () => void;
}

export const useAuth = create<AuthState>()(
  persist(
    (set) => ({
      token: null,
      driverId: null,
      setSession: (token, driverId) => set({ token, driverId }),
      clear: () => set({ token: null, driverId: null }),
    }),
    { name: "pp-driver-auth" }
  )
);
