This commit is contained in:
Timothy J. Baek
2024-06-10 22:10:53 -07:00
parent c961964647
commit 8464b30485
4 changed files with 40 additions and 6 deletions

View File

@@ -3,8 +3,11 @@
import { createNewTool, getTools } from '$lib/apis/tools';
import ToolkitEditor from '$lib/components/workspace/Tools/ToolkitEditor.svelte';
import { tools } from '$lib/stores';
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
let tool = null;
const saveHandler = async (data) => {
console.log(data);
const res = await createNewTool(localStorage.token, {
@@ -24,9 +27,22 @@
await goto('/workspace/tools');
}
};
onMount(() => {
console.log('mounted');
if (sessionStorage.tool) {
tool = JSON.parse(sessionStorage.tool);
sessionStorage.removeItem('tool');
}
});
</script>
<ToolkitEditor
id={tool?.id ?? ''}
name={tool?.name ?? ''}
meta={tool?.meta ?? { description: '' }}
content={tool?.content ?? ''}
on:save={(e) => {
saveHandler(e.detail);
}}