Skip to content

Commit

Permalink
feat: finish bug report form creation (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash authored Jan 19, 2024
1 parent d60a777 commit 320bfbc
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 28 deletions.
6 changes: 6 additions & 0 deletions src/locale/allTranslations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ i18n.use(initReactI18next).init({
lng: 'he',
})

declare module 'i18next' {
interface CustomResourcesTypeOptions {
translation: typeof translationsHE
}
}

export default i18n
9 changes: 7 additions & 2 deletions src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"bug_contact_name_message": "Please enter your full name!",
"bug_contact_email": "Email",
"bug_contact_email_message": "Please enter your email!",
"bug_form_description": "This form is designed so that we can receive feedback and improve the application.",
"bug_type": "Type of request",
"bug_type_message": "Please enter the type of request",
"bug_type_bug": "Bug",
Expand Down Expand Up @@ -132,5 +131,11 @@
"group_by_day_tooltip_content": "Group by day",
"order_by_hour": "by hour",
"order_by_severity": "by severity",
"choose_dates": "Dates"
"choose_dates": "Dates",
"reportBug": {
"description": "This form is designed so that we can receive feedback and improve the application. Please be aware that the submitted information will be available to the public.",
"error": "An error occurred while sending the report. Please try again later.",
"success": "The report was sent successfully. Thank you for your help!",
"viewIssue": "View issue"
}
}
9 changes: 7 additions & 2 deletions src/locale/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"bug_contact_name_message": "אנא הזן את שמך!",
"bug_contact_email": "אי-מייל",
"bug_contact_email_message": "אנא הזן כתובת אי-מייל!",
"bug_form_description": "טופס זה נועד על מנת שנוכל לקבל פידבק ולשפר את האפליקציה.",
"bug_type": "סוג הבקשה",
"bug_type_message": "אנא הזן סוג בקשה!",
"bug_type_bug": "באג",
Expand Down Expand Up @@ -146,5 +145,11 @@
"group_by_day_tooltip_content": "קיבוץ לפי יום",
"order_by_hour": "לפי שעה",
"order_by_severity": "לפי חומרה",
"choose_dates": "תאריכים"
"choose_dates": "תאריכים",
"reportBug": {
"description": "טופס זה נועד על מנת שנוכל לקבל פידבק ולשפר את האפליקציה. לתשומת לבך - הטופס נשלח לGitHub, והמידע שיצויין בו יהיה ציבורי.",
"error": "אירעה שגיאה בעת שליחת הדיווח. אנא נסה שוב מאוחר יותר.",
"success": "תודה על הדיווח!",
"viewIssue": "לצפייה בדיווח"
}
}
47 changes: 29 additions & 18 deletions src/pages/BugReportForm .tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Form, Input, Button, Upload, message, Select, FormProps, Card } from 'antd'
import { UploadOutlined } from '@ant-design/icons'
// import axios from 'axios'
import axios from 'axios'
import './BugReportForm.scss'
import { UploadChangeParam, UploadFile } from 'antd/lib/upload'
const { Option } = Select
Expand All @@ -19,33 +19,38 @@ interface BugReportFormData {
contactEmail: string
}

const BugReportForm: React.FC = () => {
const BugReportForm = () => {
const { t } = useTranslation()
const [form] = Form.useForm()
const [fileList, setFileList] = useState<UploadFile[]>([])
const [selectedType, setSelectedType] = useState<string | undefined>(undefined)
const [submittedUrl, setSubmittedUrl] = 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
const response = await axios.post(
'https://open-bus-backend.k8s.hasadna.org.il/create-issue',
{
...values,
attachments: fileList,
},
)

setSubmittedUrl(response.data.url)
if (response.data.state === 'open') {
message.success(t('reportBug.success'))
form.resetFields()
setFileList([])
} else {
message.error(t('reportBug.error'))
}
} catch (error) {
console.error('Error submitting bug report:', error)
message.error('Error submitting bug report. Please try again.')
message.error(t('reportBug.error'))
}
}

Expand All @@ -61,9 +66,15 @@ const BugReportForm: React.FC = () => {
<Card className="bug-report-form-container">
<h1 className="logo">דאטאבוס</h1>

<span> {t('bug_form_description')} </span>
<br />
<br />
<span> {t('reportBug.description')}</span>

<p>
{submittedUrl && (
<a href={submittedUrl} target="_blank" rel="noopener noreferrer">
{t('reportBug.viewIssue')} (Github)
</a>
)}
</p>

<Form
form={form}
Expand Down
12 changes: 6 additions & 6 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export const PAGES = [
icon: <InfoCircleOutlined />,
element: <About />,
},
{
label: 'report_a_bug_title',
path: 'report-a-bug',
icon: <BugOutlined />,
element: <BugReportForm />,
},
{
label: 'donate_title',
path: 'https://www.jgive.com/new/he/ils/donation-targets/3268#donation-modal',
Expand All @@ -89,12 +95,6 @@ const HIDDEN_PAGES = [
icon: <InfoCircleOutlined />,
element: <DataResearch />,
},
{
label: 'report_a_bug_title',
path: 'report-a-bug',
icon: <BugOutlined />,
element: <BugReportForm />,
},
{
label: 'release',
path: '/release',
Expand Down

0 comments on commit 320bfbc

Please sign in to comment.