-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(notifications): add batch invite for mentors * fix: refactor * fix: update copyright
- Loading branch information
1 parent
677142b
commit e275ebf
Showing
14 changed files
with
521 additions
and
21 deletions.
There are no files selected for viewing
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
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
71 changes: 71 additions & 0 deletions
71
client/src/modules/MentorRegistry/components/InviteMentorsModal.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,71 @@ | ||
import { Alert, Checkbox, Form, message, Select, Space, Spin } from 'antd'; | ||
import { useAsync } from 'react-use'; | ||
import { InviteMentorsDto } from 'api'; | ||
import { ModalForm } from 'components/Forms'; | ||
import { useLoading } from 'components/useLoading'; | ||
import ReactQuill from 'react-quill'; | ||
import { MentorRegistryService } from 'services/mentorRegistry'; | ||
import { DisciplinesApi } from 'api'; | ||
|
||
import 'react-quill/dist/quill.snow.css'; | ||
|
||
type Props = { | ||
onCancel: () => void; | ||
}; | ||
const mentorRegistryService = new MentorRegistryService(); | ||
const disciplinesApi = new DisciplinesApi(); | ||
|
||
function InviteMentorsModal({ onCancel }: Props) { | ||
const [loading, withLoading] = useLoading(false); | ||
const submit = withLoading(async (data: InviteMentorsDto) => { | ||
await mentorRegistryService.inviteMentors(data); | ||
message.success('Invitation successfully send.'); | ||
onCancel(); | ||
}); | ||
|
||
const { loading: disciplinesLoading, value: disciplines = [] } = useAsync(async () => { | ||
const { data } = await disciplinesApi.getDisciplines(); | ||
return data; | ||
}, []); | ||
|
||
return ( | ||
<ModalForm data={{}} title="Invite as a Mentor" submit={submit} cancel={onCancel} loading={loading}> | ||
<Space direction="vertical" style={{ width: '100%' }}> | ||
<Alert showIcon message="Invitation will be send to all mentors meeting the criteria below." type="info" /> | ||
<Form.Item | ||
name="disciplines" | ||
label="Disciplines" | ||
style={formItemStyle} | ||
rules={[{ required: true, message: 'Please select disciplines.' }]} | ||
> | ||
<Select | ||
mode="multiple" | ||
optionFilterProp="children" | ||
notFoundContent={disciplinesLoading ? <Spin size="small" /> : null} | ||
> | ||
{disciplines.map(discipline => ( | ||
<Select.Option key={discipline.id} value={discipline.id}> | ||
{discipline.name} | ||
</Select.Option> | ||
))} | ||
</Select> | ||
</Form.Item> | ||
<Form.Item name="isMentor" style={formItemStyle} valuePropName="checked"> | ||
<Checkbox>Mentor in the Past</Checkbox> | ||
</Form.Item> | ||
<Form.Item | ||
name="text" | ||
label="Invitation Text" | ||
style={formItemStyle} | ||
rules={[{ required: true, message: 'Please add invitation text.' }]} | ||
> | ||
<ReactQuill theme="snow" placeholder="Write an invitation message" /> | ||
</Form.Item> | ||
</Space> | ||
</ModalForm> | ||
); | ||
} | ||
|
||
const formItemStyle = { marginBottom: 0 }; | ||
|
||
export default InviteMentorsModal; |
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
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
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
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
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,17 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsArray, IsBoolean, IsOptional, IsString } from 'class-validator'; | ||
|
||
export class InviteMentorsDto { | ||
@ApiProperty() | ||
@IsArray() | ||
disciplines: string[]; | ||
|
||
@ApiProperty() | ||
@IsBoolean() | ||
@IsOptional() | ||
isMentor?: boolean; | ||
|
||
@ApiProperty() | ||
@IsString() | ||
text: string; | ||
} |
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
Oops, something went wrong.