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

Add component to show last query

parent f7ac935a
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