Skip to content

Commit

Permalink
✨(frontend) add register meeting component
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
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({});
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default, RegisterMeetingFormProps } from './RegisterMeetingForm';

0 comments on commit 2caec79

Please sign in to comment.