import { isSuggestion } from '../guards/api/isApiSuggestion';
import { Suggestion } from '../api/suggestion';

export const validateSuggestion = (data: unknown): Suggestion | undefined => {
  if (!isSuggestion(data)) {
    return undefined;
  }

  return {
    id: data.id,
    category: data.category,
    content: data.content,
    createdAt: data.created_at,
    isAnswer: data.is_answer,
  };
};
