-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from xoRmalka/Bug-report-form
feat: Bug report form
- Loading branch information
Showing
6 changed files
with
329 additions
and
6 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
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,166 @@ | ||
import React, { useState } from 'react' | ||
import { TEXT_KEYS } from 'src/resources/texts' | ||
import { useTranslation } from 'react-i18next' | ||
import { Form, Input, Button, Upload, message, Select, FormProps } from 'antd' | ||
import { UploadOutlined } from '@ant-design/icons' | ||
// import axios from 'axios' | ||
import './BugReportForm.scss' | ||
import { UploadChangeParam, UploadFile } from 'antd/lib/upload' | ||
const { Option } = Select | ||
|
||
interface BugReportFormData { | ||
title: string | ||
description: string | ||
environment: string | ||
expectedBehavior: string | ||
actualBehavior: string | ||
reproducibility: string | ||
attachments: UploadFile[] | ||
contactName: string | ||
contactEmail: string | ||
} | ||
|
||
const BugReportForm: React.FC = () => { | ||
const { t } = useTranslation() | ||
const [form] = Form.useForm() | ||
const [fileList, setFileList] = useState<UploadFile[]>([]) | ||
const [selectedType, setSelectedType] = useState<string | undefined>(undefined) | ||
|
||
//Not implemented yet | ||
const onFinish = async (values: BugReportFormData) => { | ||
try { | ||
// Send the bug report data to the server | ||
// Include fileList in the values if needed | ||
|
||
// const response = await axios.post('http://localhost:3001/create-issue', { | ||
// ...values, | ||
// attachments: fileList, | ||
// }) | ||
|
||
console.log(values) | ||
|
||
// Handle the server response | ||
// message.success('Bug report submitted successfully!') | ||
message.success('Not implemented!') | ||
form.resetFields() | ||
setFileList([]) // Reset fileList after submission | ||
} catch (error) { | ||
console.error('Error submitting bug report:', error) | ||
message.error('Error submitting bug report. Please try again.') | ||
} | ||
} | ||
|
||
const onFinishFailed: FormProps['onFinishFailed'] = (errorInfo) => { | ||
console.log('Failed:', errorInfo) | ||
} | ||
|
||
const onFileChange = (info: UploadChangeParam) => { | ||
setFileList(info.fileList) | ||
} | ||
|
||
return ( | ||
<div className="bug-report-form-container"> | ||
<h1 className="logo">דאטאבוס</h1> | ||
|
||
<span> {t(TEXT_KEYS.bug_form_description)} </span> | ||
<br /> | ||
<br /> | ||
|
||
<Form | ||
form={form} | ||
name="bug-report" | ||
onFinish={onFinish} | ||
onFinishFailed={onFinishFailed} | ||
labelCol={{ span: 6 }} | ||
wrapperCol={{ span: 18 }}> | ||
<Form.Item | ||
label={t(TEXT_KEYS.bug_type)} | ||
name="type" | ||
initialValue={selectedType} | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_type_message) }]}> | ||
<Select onChange={(value) => setSelectedType(value)}> | ||
<Option value="bug">{t(TEXT_KEYS.bug_type_bug)}</Option> | ||
<Option value="feature">{t(TEXT_KEYS.bug_type_feature)}</Option> | ||
</Select> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_title)} | ||
name="title" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_title_message) }]}> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_contact_name)} | ||
name="contactName" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_contact_name_message) }]}> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_contact_email)} | ||
name="contactEmail" | ||
rules={[ | ||
{ required: true, message: t(TEXT_KEYS.bug_contact_email_message) }, | ||
// { type: 'email', message: t(TEXT_KEYS.bug_contact_email_valid_message) }, | ||
]}> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_description)} | ||
name="description" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_description_message) }]}> | ||
<Input.TextArea rows={4} /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_environment)} | ||
name="environment" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_environment_message) }]}> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_expected_behavior)} | ||
name="expectedBehavior" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_expected_behavior_message) }]}> | ||
<Input.TextArea rows={4} /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_actual_behavior)} | ||
name="actualBehavior" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_actual_behavior_message) }]}> | ||
<Input.TextArea rows={4} /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t(TEXT_KEYS.bug_reproducibility)} | ||
name="reproducibility" | ||
rules={[{ required: true, message: t(TEXT_KEYS.bug_reproducibility_message) }]}> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Form.Item label={t(TEXT_KEYS.bug_attachments)} name="attachments"> | ||
<Upload | ||
beforeUpload={() => false} | ||
listType="picture" | ||
fileList={fileList} | ||
onChange={onFileChange}> | ||
<Button icon={<UploadOutlined />}>{t(TEXT_KEYS.bug_attachments_upload_button)}</Button> | ||
</Upload> | ||
</Form.Item> | ||
|
||
<Form.Item wrapperCol={{ offset: 4, span: 16 }}> | ||
<Button type="primary" htmlType="submit"> | ||
{t(TEXT_KEYS.bug_submit)}{' '} | ||
</Button> | ||
</Form.Item> | ||
</Form> | ||
</div> | ||
) | ||
} | ||
|
||
export default BugReportForm |
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,82 @@ | ||
// BugReportForm.scss | ||
|
||
.bug-report-form-container { | ||
max-width: 800px; | ||
width: 100%; | ||
margin: 0 auto; | ||
padding: 30px; | ||
background-color: #fff; | ||
border: 1px solid #e8e8e8; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); | ||
|
||
@media (max-width: 600px) { | ||
padding: 15px; | ||
|
||
h1.logo { | ||
font-size: 24px; | ||
margin: 10px auto; | ||
border-top: 4px solid gray; | ||
border-bottom: 6px solid gray; | ||
} | ||
|
||
.ant-form-item-label { | ||
text-align: left; | ||
} | ||
|
||
.ant-btn-primary { | ||
max-width: calc(100% - 100px); | ||
margin: 0 auto; | ||
display: block; | ||
} | ||
} | ||
|
||
h1.logo { | ||
position: relative; | ||
margin: 20px auto; | ||
width: 119px; | ||
font-size: 30px; | ||
border-top: 6px solid gray; | ||
border-bottom: 8px solid gray; | ||
padding-bottom: 0; | ||
line-height: 25px; | ||
text-align: center; | ||
} | ||
|
||
.ant-form-item { | ||
margin-bottom: 20px; | ||
|
||
&-label { | ||
font-weight: bold; | ||
text-align: right; | ||
} | ||
} | ||
|
||
.ant-input, | ||
.ant-input-textarea { | ||
width: 100%; | ||
} | ||
|
||
.ant-upload { | ||
width: 100%; | ||
} | ||
|
||
.ant-btn { | ||
margin-right: 8px; | ||
|
||
&-primary { | ||
background-color: #1890ff; | ||
border-color: #1890ff; | ||
width: 100%; | ||
|
||
&:hover { | ||
background-color: #40a9ff; | ||
border-color: #40a9ff; | ||
} | ||
|
||
&:focus { | ||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2); | ||
} | ||
} | ||
} | ||
} |
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