Skip to content

Commit

Permalink
fix: only show error of error ref has value (#3080)
Browse files Browse the repository at this point in the history
plus run code format
  • Loading branch information
connoratrug authored Dec 4, 2023
1 parent 71a7b09 commit a615607
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const router = useRouter();
const config = useRuntimeConfig();
const pageSize = 10;
const titlePrefix = route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
const titlePrefix =
route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + "Cohorts" });
const currentPage = ref(1);
Expand Down Expand Up @@ -128,8 +129,8 @@ const { data, pending, error, refresh } = await useFetch(graphqlURL.value, {
variables: { orderby, filter },
},
});
if (error) {
console.log(error);
if (error.value) {
console.log(error.value);
console.log(query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const router = useRouter();
const config = useRuntimeConfig();
const pageSize = 10;
const titlePrefix = route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
const titlePrefix =
route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + "Data sources" });
const currentPage = ref(1);
Expand Down Expand Up @@ -99,8 +100,8 @@ const { data, pending, error, refresh } = await useFetch(graphqlURL.value, {
variables: { orderby, filter },
},
});
if (error) {
console.log(error);
if (error.value) {
console.log(error.value);
console.log(query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const config = useRuntimeConfig();
const catalogueRouteParam = route.params.catalogue;
const titlePrefix = route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + ' catalogue' });
const titlePrefix =
route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + " catalogue" });
const cohortOnly = computed(() => {
const routeSetting = route.query["cohort-only"] as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const router = useRouter();
const config = useRuntimeConfig();
const pageSize = 10;
const titlePrefix = route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
const titlePrefix =
route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + "Networks" });
const currentPage = ref(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ if (cohortsWithMapping.value.length > 0) {
});
}
const titlePrefix = route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
const titlePrefix =
route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + variable?.name });
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const router = useRouter();
const config = useRuntimeConfig();
const pageSize = 30;
const titlePrefix = route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
const titlePrefix =
route.params.catalogue === "all" ? "" : route.params.catalogue + " ";
useHead({ title: titlePrefix + "Variables" });
type view = "list" | "harmonization";
Expand Down
25 changes: 17 additions & 8 deletions apps/nuxt3-ssr/pages/[schema]/ssr-catalogue/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const filter = computed(() => buildQueryFilter(filters, search.value));
let graphqlURL = computed(() => `/${route.params.schema}/api/graphql`);
const { data, pending, error, refresh } = await useFetch(graphqlURL.value, {
key: 'catalogues',
key: "catalogues",
baseURL: config.public.apiBase,
method: "POST",
body: {
Expand All @@ -76,13 +76,17 @@ const { data, pending, error, refresh } = await useFetch(graphqlURL.value, {
let activeName = ref("compact");
const thematicCatalogues = computed(() => {
let result = data?.value?.data?.Catalogues ? data.value?.data?.Catalogues?.filter((c) => c.type?.name === "theme") : [];
result.sort((a,b) => a.network.id.localeCompare(b.network.id))
let result = data?.value?.data?.Catalogues
? data.value?.data?.Catalogues?.filter((c) => c.type?.name === "theme")
: [];
result.sort((a, b) => a.network.id.localeCompare(b.network.id));
return result;
});
const projectCatalogues = computed(() => {
let result = data?.value?.data?.Catalogues ? data.value?.data?.Catalogues?.filter((c) => c.type?.name === "project") : [];
result.sort((a,b) => a.network.id.localeCompare(b.network.id))
let result = data?.value?.data?.Catalogues
? data.value?.data?.Catalogues?.filter((c) => c.type?.name === "project")
: [];
result.sort((a, b) => a.network.id.localeCompare(b.network.id));
return result;
});
</script>
Expand All @@ -102,21 +106,26 @@ const projectCatalogues = computed(() => {
<NuxtLink :to="`/${route.params.schema}/ssr-catalogue/all`">
<Button label="Search all" />
</NuxtLink>
<p class="mt-1 mb-0 text-center lg:mt-10 text-body-lg" v-if="thematicCatalogues.length > 0 || projectCatalogues.length > 0 ">
<p
class="mt-1 mb-0 text-center lg:mt-10 text-body-lg"
v-if="
thematicCatalogues.length > 0 || projectCatalogues.length > 0
"
>
or select a specific catalogue below:
</p>
</div>
</div>
</template>
</PageHeader>
<ContentBlockCatalogues
v-if="thematicCatalogues.length > 0"
v-if="thematicCatalogues.length > 0"
title="Thematic catalogues"
description="Catalogues focused on a particular theme, developed by a collaboration of projects, networks and/or organisations:"
:catalogues="thematicCatalogues"
/>
<ContentBlockCatalogues
v-if="projectCatalogues.length > 0"
v-if="projectCatalogues.length > 0"
title="Project catalogues"
description="Catalogues maintained by individual research projects or consortia, such as EC RIA."
:catalogues="projectCatalogues"
Expand Down

0 comments on commit a615607

Please sign in to comment.