import { Head } from '@inertiajs/react';
import PostController from '@/actions/App/Http/Controllers/Admin/PostController';
import { PageHeader } from '@/components/admin/page-header';
import { PostForm } from '@/components/admin/post-form';
import type { PostFormOptions, PostValues } from '@/components/admin/post-form';
import { useEditingLocale } from '@/hooks/use-editing-locale';

type Props = PostFormOptions & {
    values: PostValues;
};

export default function PostCreate({ values, ...options }: Props) {
    const editing = useEditingLocale();

    return (
        <>
            <Head title="Yeni yazı" />

            <PostForm
                {...options}
                values={values}
                action={PostController.store()}
                editing={editing}
                saveLabel="Yazıyı oluştur"
                header={
                    <PageHeader
                        title="Yeni yazı"
                        description="Yazı taslak olarak oluşturulur; içerik tamamlandığında “Yayında” seçeneğini açarak siteye alabilirsiniz."
                    />
                }
            />
        </>
    );
}

PostCreate.layout = {
    breadcrumbs: [
        { title: 'Blog', href: PostController.index() },
        { title: 'Yeni yazı', href: PostController.create() },
    ],
};
