diff --git a/frontend/src/routes/playground/FileTree.svelte b/frontend/src/routes/playground/FileTree.svelte index cc0138c..43bc918 100644 --- a/frontend/src/routes/playground/FileTree.svelte +++ b/frontend/src/routes/playground/FileTree.svelte @@ -2,10 +2,17 @@ import { playgroundStore } from '$stores/playground'; interface Props { + language?: 'c' | 'python'; onselect?: (id: string) => void; } - let { onselect }: Props = $props(); + let { language = 'c', onselect }: Props = $props(); + + const fileExt = $derived(language === 'python' ? '.py' : '.c'); + const langLabel = $derived(language === 'python' ? 'Python' : 'C'); + const filteredFiles = $derived( + $playgroundStore.files.filter((f) => f.name.toLowerCase().endsWith(fileExt)) + ); let renamingId = $state(null); let renameValue = $state(''); @@ -49,17 +56,21 @@
- File -
- {#if $playgroundStore.files.length === 0} + {#if filteredFiles.length === 0}
Belum ada file. Klik + untuk membuat.
{:else}
- {#each $playgroundStore.files as file (file.id)} + {#each filteredFiles as file (file.id)}