import { h } from 'preact'; import Heading from '../components/Heading'; import { useState } from 'preact/hooks'; import useSWR from 'swr'; import Button from '../components/Button'; import axios from 'axios'; export default function Export() { const { data: config } = useSWR('config'); const [camera, setCamera] = useState('select'); const [playback, setPlayback] = useState('select'); const [message, setMessage] = useState({ text: '', error: false }); const onHandleExport = () => { if (camera == 'select') { setMessage({ text: 'A camera needs to be selected.', error: true }); return; } if (playback == 'select') { setMessage({ text: 'A playback factor needs to be selected.', error: true }); return; } const start = new Date(document.getElementById('start').value).getTime() / 1000; const end = new Date(document.getElementById('end').value).getTime() / 1000; if (!start || !end) { setMessage({ text: 'A start and end time needs to be selected', error: true }); return; } setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false }); axios.post(`export/${camera}/start/${start}/end/${end}`, { playback }); }; return (
Export {message.text && (
{message.text}
)}
From: To:
); }