fix global state (still massively wip)
This commit is contained in:
parent
71dc064ab6
commit
dc98b0bf37
2 changed files with 22 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Paper, Search, Filter } from '@/types'
|
import type { Paper, Search, Filter } from '@/types'
|
||||||
import { papers, topics, papersfetch } from '@/store'
|
import { state, papersFetch } from '@/store'
|
||||||
import MainMenu from '@/components/MainMenu.vue'
|
import MainMenu from '@/components/MainMenu.vue'
|
||||||
import SearchBar from '@/components/SearchBar.vue'
|
import SearchBar from '@/components/SearchBar.vue'
|
||||||
import FilterView from './components/papers/FilterView.vue'
|
import FilterView from './components/papers/FilterView.vue'
|
||||||
|
@ -20,8 +20,7 @@ let filter: Filter = {
|
||||||
},
|
},
|
||||||
originator: '',
|
originator: '',
|
||||||
}
|
}
|
||||||
onMounted (() => papersfetch() )
|
onMounted (() => papersFetch() )
|
||||||
/* onMounted(() => topics.process() ) */
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -42,7 +41,7 @@ onMounted (() => papersfetch() )
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="flex flex-row max-w-5xl m-auto">
|
<main class="flex flex-row max-w-5xl m-auto">
|
||||||
{{ papers }}
|
{{ state.topics }}
|
||||||
<RouterView
|
<RouterView
|
||||||
:search="search"
|
:search="search"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
|
|
|
@ -1,34 +1,25 @@
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import type { Paper, Topic } from '@/types'
|
import type { Paper, Topic } from '@/types'
|
||||||
|
|
||||||
const apiUrl: URL = new URL('https://raw.githubusercontent.com/CodeforLeipzig/stadtratmonitor/master/input.json')
|
const apiUrl: URL = new URL(
|
||||||
|
'https://raw.githubusercontent.com/CodeforLeipzig/stadtratmonitor/master/input.json'
|
||||||
|
)
|
||||||
|
|
||||||
export let papers: Array<Paper> = reactive([])
|
interface State {
|
||||||
export let topics: Array<Topic> = reactive([])
|
papers: Paper[]
|
||||||
|
topics: Topic[]
|
||||||
export async function papersfetch() {
|
|
||||||
papers = await (await fetch(apiUrl)).json()
|
|
||||||
/* const topicReferences = await [...new Set(papers?.map((paper: Paper) => paper.reference))]
|
|
||||||
topics = await topicReferences.map( (reference: string) => {
|
|
||||||
return {
|
|
||||||
'reference': reference,
|
|
||||||
'papers': papers?.filter( (paper: Paper) => paper.reference === reference),
|
|
||||||
}
|
|
||||||
}) */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* export function paperprocess() */
|
export const state: State = reactive({ papers: [], topics: [] })
|
||||||
|
|
||||||
/* export const test = reactive({
|
export async function papersFetch() {
|
||||||
testi: papers.papers,
|
const papersData: Paper[] = await (await fetch(apiUrl)).json()
|
||||||
funk() {
|
const topicReferences = await [...new Set(papersData?.map((paper) => paper.reference))]
|
||||||
return [...new Set(papers.papers?.map((paper: Paper) => paper.reference))]
|
state.papers = papersData
|
||||||
}
|
state.topics = await topicReferences.map((reference) => {
|
||||||
}) */
|
return {
|
||||||
|
reference: reference,
|
||||||
/* export const = reactive({
|
papers: papersData?.filter((paper: Paper) => paper.reference === reference)
|
||||||
topics: Array<Topic>,
|
}
|
||||||
topicReferences: Set<String>,
|
})
|
||||||
async process() {
|
}
|
||||||
},
|
|
||||||
}) */
|
|
Loading…
Reference in a new issue