-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(frontend) add register meeting component
add a register meeting button and form, the same as for rooms
- Loading branch information
karabij
committed
Dec 9, 2022
1 parent
15a7732
commit 2caec79
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/frontend/magnify/src/components/meetings/RegisterMeeting/RegisterMeeting.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import React from 'react'; | ||
import RegisterMeeting from './RegisterMeeting'; | ||
|
||
export default { | ||
title: 'Meetings/RegisterMeeting', | ||
component: RegisterMeeting, | ||
} as ComponentMeta<typeof RegisterMeeting>; | ||
|
||
const Template: ComponentStory<typeof RegisterMeeting> = () => <RegisterMeeting />; | ||
|
||
// create the template and stories | ||
export const basicRegisterMeeting = Template.bind({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Box, Button, Layer } from 'grommet'; | ||
import { Add } from 'grommet-icons'; | ||
import React, { useState } from 'react'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
|
||
import { Meeting } from '../../../types/entities/meeting'; | ||
import RegisterMeetingForm from '../RegisterMeetingForm'; | ||
|
||
const messages = defineMessages({ | ||
registerNewMeetingLabel: { | ||
id: 'components.meetings.registerMeeting.registerNewMeetingLabel', | ||
defaultMessage: 'Register new meeting', | ||
description: 'Label for the button to register a new meeting', | ||
}, | ||
addNewMeetingLabel: { | ||
id: 'components.meetings.registerMeeting.addNewMeetingLabel', | ||
defaultMessage: 'Meeting', | ||
description: 'Label for the button to register a new meeting', | ||
}, | ||
}); | ||
|
||
export interface RegisterMeetingProps { | ||
onAddMeeting?: (meeting: Meeting) => void; | ||
} | ||
|
||
const RegisterMeeting = ({ ...props }: RegisterMeetingProps) => { | ||
const intl = useIntl(); | ||
const [open, setOpen] = useState(false); | ||
|
||
const handleOpen = (event: React.MouseEvent) => { | ||
event.preventDefault(); | ||
setOpen(true); | ||
}; | ||
|
||
const handleClose = (event?: React.MouseEvent | React.KeyboardEvent) => { | ||
event?.preventDefault(); | ||
setOpen(false); | ||
}; | ||
|
||
const onAddSuccess = (meeting?: Meeting): void => { | ||
handleClose(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button | ||
primary | ||
icon={<Add size="15px" />} | ||
label={intl.formatMessage(messages.addNewMeetingLabel)} | ||
onClick={handleOpen} | ||
/> | ||
{open && ( | ||
<Layer | ||
id="confirmDelete" | ||
onClickOutside={handleClose} | ||
onEsc={handleClose} | ||
position="center" | ||
role="dialog" | ||
> | ||
<Box pad="medium" width={'medium'}> | ||
<RegisterMeetingForm onSuccess={onAddSuccess} /> | ||
</Box> | ||
</Layer> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default RegisterMeeting; |
1 change: 1 addition & 0 deletions
1
src/frontend/magnify/src/components/meetings/RegisterMeetingForm/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, RegisterMeetingFormProps } from './RegisterMeetingForm'; |