Simplified the querying
This commit is contained in:
Родитель
ad6e7e6b96
Коммит
671fae249b
|
@ -8,16 +8,13 @@ import ElectionPage from './pages/ElectionPage';
|
|||
import HomePage from './pages/HomePage';
|
||||
|
||||
import './App.css';
|
||||
import { useElections } from './data/queries';
|
||||
|
||||
function App() {
|
||||
const electionsQuery = useElections();
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Switch>
|
||||
<Route path="/" exact render={() => <HomePage electionsQuery={electionsQuery} />} />
|
||||
<Route path="/:electionId" render={() => <ElectionPage electionsQuery={electionsQuery} />} />
|
||||
<Route path="/" exact component={HomePage} />
|
||||
<Route path="/:electionId" component={ElectionPage} />
|
||||
<Route component={NotFoundPage} />
|
||||
</Switch>
|
||||
</Layout>
|
||||
|
|
|
@ -5,19 +5,17 @@ import AsyncContent from '../components/AsyncContent';
|
|||
import ElectionTitle from '../components/ElectionTitle';
|
||||
import TrackerSearch from '../components/TrackerSearch';
|
||||
import ElectionResults from '../components/ElectionResults';
|
||||
import { ElectionDescription } from '../models/election';
|
||||
import { QueryResult } from '../data/queries';
|
||||
import { useElections } from '../data/queries';
|
||||
import { useLocalization } from '../localization/LocalizationProvider';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import Title from '../components/Title';
|
||||
|
||||
export interface ElectionPageProps {
|
||||
electionsQuery: QueryResult<ElectionDescription[]>;
|
||||
}
|
||||
export interface ElectionPageProps {}
|
||||
|
||||
const ElectionPage: React.FunctionComponent<ElectionPageProps> = ({ electionsQuery }) => {
|
||||
const ElectionPage: React.FunctionComponent<ElectionPageProps> = () => {
|
||||
const { electionId } = useParams<{ electionId: string }>();
|
||||
const { translate } = useLocalization();
|
||||
const electionsQuery = useElections();
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
|
|
|
@ -2,15 +2,14 @@ import React from 'react';
|
|||
import { Stack } from '@fluentui/react';
|
||||
|
||||
import AsyncContent from '../components/AsyncContent';
|
||||
import { QueryResult } from '../data/queries';
|
||||
import { useElections } from '../data/queries';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { ElectionDescription } from '../models/election';
|
||||
|
||||
export interface HomePageProps {
|
||||
electionsQuery: QueryResult<ElectionDescription[]>;
|
||||
}
|
||||
export interface HomePageProps {}
|
||||
|
||||
const ElectionPage: React.FunctionComponent<HomePageProps> = () => {
|
||||
const electionsQuery = useElections();
|
||||
|
||||
const ElectionPage: React.FunctionComponent<HomePageProps> = ({ electionsQuery }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<AsyncContent query={electionsQuery} errorMessage="Unable to load any elections at this time.">
|
||||
|
|
Загрузка…
Ссылка в новой задаче