Skip to content
Snippets Groups Projects
Commit 911c18b0 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Follow API documentation for budget

parent bf85bab3
Branches
Tags
No related merge requests found
...@@ -78,8 +78,7 @@ def budget_view() -> Any: ...@@ -78,8 +78,7 @@ def budget_view() -> Any:
entries = sorted([_extract_data(entry) entries = sorted([_extract_data(entry)
for entry in session.query(model.BudgetEntry)], for entry in session.query(model.BudgetEntry)],
key=lambda d: (d['BUDGET_YEAR'], d['NREN'])) key=lambda d: (d['BUDGET_YEAR'], d['NREN']))
dict_obj = {"data": entries} return jsonify(entries)
return jsonify(dict_obj)
@routes.route('/migration', methods=['GET']) @routes.route('/migration', methods=['GET'])
......
...@@ -26,10 +26,6 @@ export interface BudgetMatrix { ...@@ -26,10 +26,6 @@ export interface BudgetMatrix {
title: string title: string
} }
export interface BudgetAPI {
data: [Budget]
}
export interface Budget { export interface Budget {
BUDGET: string, BUDGET: string,
BUDGET_YEAR: number, BUDGET_YEAR: number,
......
import React, { ReactElement, useEffect, useState } from 'react'; import React, { ReactElement, useEffect, useState } from 'react';
import { Accordion, Col, Container, ListGroup, Row } from "react-bootstrap"; import { Accordion, Col, Container, ListGroup, Row } from "react-bootstrap";
import BarGraph from "../components/graphing/BarGraph";
import LineGraph from "../components/graphing/LineGraph"; import LineGraph from "../components/graphing/LineGraph";
import { BudgetMatrix, DataEntrySection, Budget,BudgetAPI } from "../Schema"; import { BudgetMatrix, DataEntrySection, Budget } from "../Schema";
// import {evaluateInteractionItems} from "chart.js/dist/core/core.interaction";
import barGraph from "../components/graphing/BarGraph";
export const options = { export const options = {
...@@ -67,17 +64,17 @@ function DataAnalysis(): ReactElement { ...@@ -67,17 +64,17 @@ function DataAnalysis(): ReactElement {
const loadData = async () => { const loadData = async () => {
console.log("budgetResponse "+ budgetResponse) console.log("budgetResponse "+ budgetResponse)
if (budgetResponse == undefined) { if (budgetResponse == undefined) {
api<BudgetAPI>('/api/budget/', {}) api<Budget[]>('/api/budget/', {})
.then((budget: BudgetAPI) => { .then((budget: Budget[]) => {
console.log('budget.data :', budget.data) console.log('budget.data :', budget)
console.log('budget :', budget) console.log('budget :', budget)
const entry = dataEntrySection?.items.find(i => i.id == selectedDataEntry) const entry = dataEntrySection?.items.find(i => i.id == selectedDataEntry)
console.log(selectedDataEntry, dataEntrySection, entry) console.log(selectedDataEntry, dataEntrySection, entry)
if (entry) if (entry)
options.plugins.title.text = entry.title; options.plugins.title.text = entry.title;
setBudget(budget.data) setBudget(budget)
console.log("budgetResponse after api "+ budgetResponse) console.log("budgetResponse after api "+ budgetResponse)
convertToBudgetPerYearDataResponse(budget.data) convertToBudgetPerYearDataResponse(budget)
}) })
.catch(error => { .catch(error => {
console.log(`Error fetching from API: ${error}`); console.log(`Error fetching from API: ${error}`);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment