qa: Don't fail if no scenario + don't show menu item
This commit is contained in:
parent
7ae1517a59
commit
a630075116
@ -23,6 +23,7 @@
|
||||
} from '@sveltestrap/sveltestrap';
|
||||
|
||||
import { auth, gitlab, version } from '$lib/stores/auth';
|
||||
import { themes } from '$lib/stores/themes';
|
||||
|
||||
export let activemenu = "";
|
||||
$: {
|
||||
@ -50,6 +51,7 @@
|
||||
<span class="d-none d-md-inline">Accueil</span>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
{#if $themes.length}
|
||||
<NavItem>
|
||||
<NavLink
|
||||
href="themes"
|
||||
@ -59,6 +61,7 @@
|
||||
<span class="d-none d-md-inline">Scénarios</span>
|
||||
</NavLink>
|
||||
</NavItem>
|
||||
{/if}
|
||||
<NavItem>
|
||||
<NavLink
|
||||
href="exercices"
|
||||
|
@ -23,7 +23,12 @@ export class Theme {
|
||||
export async function getThemes() {
|
||||
const res = await fetch(`api/themes`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).map((t) => new Theme(t));
|
||||
const data = await res.json();
|
||||
if (data) {
|
||||
return data.map((t) => new Theme(t));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user