'use client';

import WorldBuilder from '@/components/WorldBuilder';
import { useProjectContext } from '@/providers/ProjectProvider';

export default function WorldPage() {
    const { project, updateProject, createEntity, updateEntity, deleteEntity } = useProjectContext();

    return (
        <WorldBuilder
            entities={project.entities || []}
            onCreate={async (entityData) => {
                return await createEntity(entityData.type, entityData);
            }}
            onUpdate={(entityId, updates) => updateEntity(entityId, updates)}
            onDelete={(entityId) => deleteEntity(entityId)}
            templates={project.templates || []}
            onUpdateTemplates={(t) => updateProject({ templates: t })}
            initialSelectedId={null}
        />
    );
}
