mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
add better group creation ui
This commit is contained in:
parent
7f26931962
commit
25fb67a9dd
|
@ -14,13 +14,17 @@ export default function EventCreatorLink({ group }: { group: IGroup }) {
|
||||||
style={{
|
style={{
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
marginBottom: '1rem',
|
|
||||||
}}
|
}}
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
>
|
>
|
||||||
Create Event
|
Create Event
|
||||||
</div>
|
</div>
|
||||||
{open && <EventCreator group={group} />}
|
{open && (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
<EventCreator group={group} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { IEvent } from './Event';
|
||||||
import EventCreatorLink from './EventCreatorLink';
|
import EventCreatorLink from './EventCreatorLink';
|
||||||
import EventStream from './EventStream';
|
import EventStream from './EventStream';
|
||||||
import GroupSettingsLink from './GroupSettingsLink';
|
import GroupSettingsLink from './GroupSettingsLink';
|
||||||
|
import UILink from './UILink';
|
||||||
|
|
||||||
export type IGroup = {
|
export type IGroup = {
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -57,8 +58,13 @@ export default function Group() {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h1>{name}</h1>
|
<h1>{name}</h1>
|
||||||
|
<UILink href="/">Home</UILink>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
<GroupSettingsLink group={group} />
|
<GroupSettingsLink group={group} />
|
||||||
|
<br />
|
||||||
<EventCreatorLink group={group} />
|
<EventCreatorLink group={group} />
|
||||||
|
<br />
|
||||||
<EventStream events={events} />
|
<EventStream events={events} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
import React, { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { post } from './api';
|
import { post } from './api';
|
||||||
import UIButton from './UIButton';
|
import UIButton from './UIButton';
|
||||||
|
import UILink from './UILink';
|
||||||
import UISecondaryBox from './UISecondaryBox';
|
import UISecondaryBox from './UISecondaryBox';
|
||||||
import UITextInput from './UITextInput';
|
import UITextInput from './UITextInput';
|
||||||
|
|
||||||
export default function GroupCreator() {
|
export default function GroupCreator() {
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
|
const [creationSuccessful, setCreationSuccessful] =
|
||||||
|
useState<boolean | null>(null);
|
||||||
|
const [createdGroupId, setCreatedGroupId] = useState(0);
|
||||||
const createGroup = useCallback(() => {
|
const createGroup = useCallback(() => {
|
||||||
post('/groups', {
|
post('/groups', {
|
||||||
name,
|
name,
|
||||||
|
})
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then(({ id }) => {
|
||||||
|
setCreationSuccessful(true);
|
||||||
|
setCreatedGroupId(id);
|
||||||
});
|
});
|
||||||
}, [name]);
|
}, [name]);
|
||||||
|
|
||||||
|
@ -18,6 +27,19 @@ export default function GroupCreator() {
|
||||||
Name
|
Name
|
||||||
<UITextInput onChangeText={setName} value={name} />
|
<UITextInput onChangeText={setName} value={name} />
|
||||||
<UIButton onClick={createGroup}>Create group</UIButton>
|
<UIButton onClick={createGroup}>Create group</UIButton>
|
||||||
|
{creationSuccessful !== null &&
|
||||||
|
(creationSuccessful ? (
|
||||||
|
<span>
|
||||||
|
<UILink href={`/groups/${createdGroupId}`}>
|
||||||
|
<b>{name}</b>
|
||||||
|
</UILink>{' '}
|
||||||
|
has been created.
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span>
|
||||||
|
For some reason, <b>{name}</b> could not be created.
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
</UISecondaryBox>
|
</UISecondaryBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,17 @@ export default function GroupSettingsLink({ group }: { group: IGroup }) {
|
||||||
style={{
|
style={{
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
marginBottom: '1rem',
|
|
||||||
}}
|
}}
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
>
|
>
|
||||||
Settings
|
Settings
|
||||||
</div>
|
</div>
|
||||||
{open && <GroupSettings group={group} />}
|
{open && (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
<GroupSettings group={group} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ export default function UIButton({
|
||||||
}
|
}
|
||||||
return { ...baseStyle, ...style };
|
return { ...baseStyle, ...style };
|
||||||
}, [style]);
|
}, [style]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={computedStyle} onClick={onClick}>
|
<div style={computedStyle} onClick={onClick}>
|
||||||
{children}
|
{children}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user