add grouip creator

This commit is contained in:
Michael Fatemi 2021-06-23 14:35:30 -04:00
parent 09fa99e89c
commit 776d93acb3
3 changed files with 31 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import EventCreator from './EventCreator';
import Group from './Group';
import GroupCreator from './GroupCreator';
import UIPrimaryTitle from './UIPrimaryTitle';
export default function App() {
@ -16,6 +17,7 @@ export default function App() {
}}
>
<UIPrimaryTitle>WheelShare</UIPrimaryTitle>
<GroupCreator />
<EventCreator />
<Group
events={[

View File

@ -30,6 +30,7 @@ export default function EventCreator() {
return (
<UISecondaryBox style={{ width: '100%', boxSizing: 'border-box' }}>
<h1 style={{ textAlign: 'center' }}>Create Event</h1>
Name
<UITextInput value={name} onChangeText={setName} />
<br />

View File

@ -0,0 +1,28 @@
import React, { useCallback, useState } from 'react';
import UIButton from './UIButton';
import UISecondaryBox from './UISecondaryBox';
import UITextInput from './UITextInput';
export default function GroupCreator() {
const [name, setName] = useState('');
const createGroup = useCallback(() => {
fetch('http://localhost:5000/api/groups', {
method: 'post',
body: JSON.stringify({
name,
}),
headers: {
'Content-Type': 'application/json',
},
});
}, [name]);
return (
<UISecondaryBox style={{ width: '100%', boxSizing: 'border-box' }}>
<h1 style={{ textAlign: 'center' }}>Create Group</h1>
Name
<UITextInput onChangeText={setName} value={name} />
<UIButton onClick={createGroup}>Create group</UIButton>
</UISecondaryBox>
);
}