import React from "react"; import { Save } from "lucide-react"; import { useFlowStore } from "../store/flowStore"; import { TranslationService } from "../services/TranslationService"; export function SettingsForm() { const { settings, updateSettings, routes } = useFlowStore(); const handleChange = ( e: React.ChangeEvent ) => { updateSettings({ ...settings, [e.target.name]: e.target.value, }); }; const handleSave = () => { updateSettings(settings); }; const handleExportConfiguration = () => { const models = useFlowStore.getState().models; const roles = useFlowStore.getState().roles; const routes = useFlowStore.getState().routes; const configuration = { models: models.map((model) => TranslationService.translateModel(model)), roles: roles.map((role) => ({ name: role.name, slug: role.slug, permissions: { ...role.permissions, routes: role.permissions.routes .map((routeId) => { const route = routes.find((r) => r.id === routeId); return route ? { method: route.method, url: route.url, } : null; }) .filter(Boolean), }, })), }; const blob = new Blob([JSON.stringify(configuration, null, 2)], { type: "application/json", }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "configuration.json"; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }; return (
); }