Commit f16f02b2 authored by Aron Fiechter's avatar Aron Fiechter
Browse files

Move LastQuery into QueryResult

parent 147254e4
import React from 'react';
import { selectResult } from '../navbar/querySlice';
import { selectQuery, selectResult } from '../navbar/querySlice';
import Container from 'react-bootstrap/Container';
import { useSelector } from 'react-redux';
import Card from 'react-bootstrap/Card';
export default function QueryResult() {
const nResults = useSelector(selectResult)?.nResults;
const displayText = <h5 className="card-title text-sm-right">{nResults} results</h5>;
const lastQuery = useSelector(selectQuery);
const isLastQueryAdvanced = lastQuery?.advanced || false;
const lastSimpleQueryText = lastQuery?.fields?.find((f) => f.key === 'allData')?.value;
const lastAdvancedQuery = lastQuery?.fields
?.filter((f) => f.value)
?.map((f) => `${f.key}=${f.value}`)
?.join(', ');
const text = (
<span className="text-info">
{isLastQueryAdvanced ? lastAdvancedQuery : lastSimpleQueryText}
</span>
);
return (
<div className="pt-sm-2 pb-sm-1">
<Container>{displayText}</Container>
</div>
<Container>
<div className="pt-sm-2 pb-sm-2 text-sm-right">
{nResults} results for {text}
</div>
</Container>
);
}
......@@ -2,7 +2,6 @@ import React from 'react';
import Card from 'react-bootstrap/Card';
import ListGroup from 'react-bootstrap/ListGroup';
import LastQuery from './LastQuery';
export default function Empty() {
return (
......@@ -37,7 +36,6 @@ export default function Empty() {
.
</Card.Text>
</Card.Body>
<LastQuery />
<Card.Header as={'h6'}>Instructions</Card.Header>
<ListGroup variant="flush">
<ListGroup.Item>
......
import React from 'react';
import { useSelector } from 'react-redux';
import { selectQuery } from '../../navbar/querySlice';
import Card from 'react-bootstrap/Card';
export default function LastQuery() {
const lastQuery = useSelector(selectQuery);
const isLastQueryAdvanced = lastQuery?.advanced || false;
const lastSimpleQueryText = lastQuery?.fields?.find((f) => f.key === 'allData')?.value;
const lastAdvancedQuery = lastQuery?.fields
?.filter((f) => f.value)
?.map((f) => `${f.key}=${f.value}`)
?.join(', ');
const text = (
<span className="text-info">
{isLastQueryAdvanced ? lastAdvancedQuery : lastSimpleQueryText}
</span>
);
return lastQuery ? (
<Card.Body className="border-top">
<Card.Text>
Showing results for {isLastQueryAdvanced ? <em>advanced</em> : ''} query {text}
</Card.Text>
</Card.Body>
) : (
''
);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment