import { create } from 'zustand';

interface UserState {
  firstName: string;
  lastName: string;
  phoneNumber: string;
  expireTime: number;
  setExpireTime: (time: number) => void;
  setUser: (user: Partial<UserState>) => void;
  clearUser: () => void;
}

export const useUserStore = create<UserState>(set => ({
  firstName: '',
  lastName: '',
  phoneNumber: '',
  expireTime: 0,
  setExpireTime: time => set({ expireTime: time }),

  setUser: user =>
    set(state => ({
      ...state,
      ...user,
    })),

  clearUser: () =>
    set({
      firstName: '',
      lastName: '',
      phoneNumber: '',
    }),
}));
