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';
|
} from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
import { auth, gitlab, version } from '$lib/stores/auth';
|
import { auth, gitlab, version } from '$lib/stores/auth';
|
||||||
|
import { themes } from '$lib/stores/themes';
|
||||||
|
|
||||||
export let activemenu = "";
|
export let activemenu = "";
|
||||||
$: {
|
$: {
|
||||||
@ -50,6 +51,7 @@
|
|||||||
<span class="d-none d-md-inline">Accueil</span>
|
<span class="d-none d-md-inline">Accueil</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</NavItem>
|
</NavItem>
|
||||||
|
{#if $themes.length}
|
||||||
<NavItem>
|
<NavItem>
|
||||||
<NavLink
|
<NavLink
|
||||||
href="themes"
|
href="themes"
|
||||||
@ -59,6 +61,7 @@
|
|||||||
<span class="d-none d-md-inline">Scénarios</span>
|
<span class="d-none d-md-inline">Scénarios</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</NavItem>
|
</NavItem>
|
||||||
|
{/if}
|
||||||
<NavItem>
|
<NavItem>
|
||||||
<NavLink
|
<NavLink
|
||||||
href="exercices"
|
href="exercices"
|
||||||
|
@ -23,7 +23,12 @@ export class Theme {
|
|||||||
export async function getThemes() {
|
export async function getThemes() {
|
||||||
const res = await fetch(`api/themes`, {headers: {'Accept': 'application/json'}})
|
const res = await fetch(`api/themes`, {headers: {'Accept': 'application/json'}})
|
||||||
if (res.status == 200) {
|
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 {
|
} else {
|
||||||
throw new Error((await res.json()).errmsg);
|
throw new Error((await res.json()).errmsg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user