30 lines
816 B
TypeScript
30 lines
816 B
TypeScript
import { useState } from 'react';
|
|
import { PhotoFormData, formHasTextContent } from '.';
|
|
import useAiImageQueries from '../ai/useAiImageQueries';
|
|
import { AiAutoGeneratedField } from '../ai';
|
|
|
|
export default function usePhotoFormParent({
|
|
photoForm,
|
|
textFieldsToAutoGenerate,
|
|
}: {
|
|
photoForm?: Partial<PhotoFormData>,
|
|
textFieldsToAutoGenerate?: AiAutoGeneratedField[],
|
|
} = {}) {
|
|
const [pending, setIsPending] = useState(false);
|
|
const [updatedTitle, setUpdatedTitle] = useState('');
|
|
const [hasTextContent, setHasTextContent] =
|
|
useState(photoForm ? formHasTextContent(photoForm) : false);
|
|
|
|
const aiContent = useAiImageQueries(textFieldsToAutoGenerate);
|
|
|
|
return {
|
|
pending,
|
|
setIsPending,
|
|
updatedTitle,
|
|
setUpdatedTitle,
|
|
hasTextContent,
|
|
setHasTextContent,
|
|
aiContent,
|
|
};
|
|
}
|