Skip to content

Commit

Permalink
feat:export CSV file with all event data
Browse files Browse the repository at this point in the history
  • Loading branch information
KatyH820 committed Apr 14, 2024
1 parent f848cf6 commit 2a2a597
Show file tree
Hide file tree
Showing 2 changed files with 4,807 additions and 7,301 deletions.
30 changes: 29 additions & 1 deletion src/components/Events/ImpactSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { IoDocumentText } from 'react-icons/io5';
import { MdPeopleAlt } from 'react-icons/md';
import Backend from '../../utils/utils';
import DataCard from './DataCard';
import { CSVLink } from 'react-csv';

const ImpactSummary = () => {
const [registered, setRegistered] = useState(0);
const [checkedIn, setCheckedIn] = useState(0);
const [total, setTotal] = useState(0);
const [eventIdData, setEventIdData] = useState([]);

useEffect(() => {
getData();
Expand All @@ -30,6 +32,30 @@ const ImpactSummary = () => {
}
};

const header = [
{ key: 'event_id', label: 'EVENT_ID' },
{ key: 'id', label: 'ID' },
{ key: 'is_checked_in', label: 'IS_CHECKED_IN' },
{ key: 'number_in_party', label: 'NUMBER_IN_PARTY' },
{ key: 'ounces', label: 'OUNCES' },
{ key: 'pounds', label: 'POUNDS' },
{ key: 'unusual_items', label: 'UNUSUAL_ITEMS' },
{ key: 'volunteer_id', label: 'VOLUNTEER_ID' },
];

useEffect(() => {
const getEventId = async () => {
try {
const eventIdData = await Backend.get(`/data/`);
setEventIdData(eventIdData.data);
} catch (err) {
console.log(err.message);
}
};

getEventId();
}, []);

return (
<Box
mb="5"
Expand Down Expand Up @@ -72,7 +98,9 @@ const ImpactSummary = () => {
<VStack gap={120}>
<Box></Box>
<Button colorScheme={'messenger'} leftIcon={<AiOutlineExport></AiOutlineExport>} size="md">
Export Data
<CSVLink data={eventIdData} filename="./data.csv" headers={header}>
Export Data
</CSVLink>
</Button>
</VStack>
</Box>
Expand Down
Loading

0 comments on commit 2a2a597

Please sign in to comment.