import { type UserMood } from 'src/types/userMood';

import { type MoodFormValues } from '../types';

export const EMPTY_VALUES: MoodFormValues = {
  emoji: '',
  description: '',
  duration: null,
  customDate: null,
  customTime: null,
};

export const getDefaultValues = (
  mood: UserMood | null | undefined,
): MoodFormValues => {
  if (!mood) return EMPTY_VALUES;
  const isCustom = mood.duration === 'custom';
  return {
    emoji: mood.emoji,
    description: mood.description,
    duration: mood.duration,
    // Separate Date instances so a picker mutating one doesn't affect the other.
    customDate: isCustom ? new Date(mood.expiresAt) : null,
    customTime: isCustom ? new Date(mood.expiresAt) : null,
  };
};
