hook together bits

This commit is contained in:
Kent Brockman 2022-07-10 11:07:30 -06:00
parent 52addc7703
commit 26f35a5aa9

View File

@ -453,28 +453,29 @@ export function ICalButtons(props) {
const addToGoogleCalendar = (e) => { const addToGoogleCalendar = (e) => {
e.preventDefault(); e.preventDefault();
// TODO: fill in URL from clazz properties // TODO: fill in URL from clazz properties
window.location = 'https://www.google.com/calendar/render?action=TEMPLATE&text=Title&dates=20190227/20190228' window.open('https://www.google.com/calendar/render?action=TEMPLATE&text=Title&dates=20190227/20190228', '_blank');
}; };
const options = [ const options = [
{ key: 'email', icon: 'mail outline', text: 'Email ICS Event', value: 'email' }, { key: 'email', icon: 'mail outline', text: 'Email ICS Event', value: 'email', action: handleEmail },
{ key: 'download', icon: 'download', text: 'Download ICS Event', value: 'download' }, { key: 'download', icon: 'download', text: 'Download ICS Event', value: 'download', action: handleDownload },
{ key: 'google', icon: 'google', text: 'Add to Google Calendar', value: 'google' }, { key: 'google', icon: 'google', text: 'Add to Google Calendar', value: 'google', action: addToGoogleCalendar },
]; ];
// TODO: get default option from local storage or default to 0
let selectedOption = options[0]; const [selectedOption, setOption] = useState(options[0]);
const onClick = (e, data) => { const onClick = (e, data) => {
selectedOption = options.filter(x => x.value === data.value)[0]; let newOption = options.filter(x => x.value === data.value)[0];
console.log(selectedOption); setOption(newOption);
// TODO set state here
// setState({selectedOption: selectedOption});
// TODO: change the Button onClick handler...based on selected option?
}; };
return ( return (
<Button.Group> <Button.Group>
<Button onClick={handleDownload}><Icon name={selectedOption.icon} />{selectedOption.text}</Button> <Button
loading={loading}
onClick={selectedOption.action}>
<Icon name={selectedOption.icon} />{selectedOption.text}
</Button>
<Dropdown <Dropdown
className='button icon' className='button icon'
floating floating
@ -483,6 +484,7 @@ export function ICalButtons(props) {
trigger={<></>} trigger={<></>}
/> />
</Button.Group> </Button.Group>
// TODO: reimplement success prompt
/*<> /*<>
<Button compact onClick={handleDownload}> <Button compact onClick={handleDownload}>
Download Download