-
Notifications
You must be signed in to change notification settings - Fork 7
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 #153 from snaeem3/151-feedback-form
Feedback Form changes and bug fixes
- Loading branch information
Showing
8 changed files
with
289 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from "axios"; | ||
import { FormValues } from "./pages/Feedback/FeedbackForm"; | ||
const baseURL = import.meta.env.VITE_API_BASE_URL; | ||
|
||
const api = axios.create({ | ||
baseURL, | ||
headers: { | ||
Authorization: `JWT ${localStorage.getItem("access")}`, | ||
}, | ||
}); | ||
|
||
// Request interceptor to set the Authorization header | ||
api.interceptors.request.use( | ||
(configuration) => { | ||
const token = localStorage.getItem("access"); | ||
if (token) { | ||
configuration.headers.Authorization = `JWT ${token}`; | ||
} | ||
return configuration; | ||
}, | ||
(error) => Promise.reject(error) | ||
); | ||
|
||
const handleSubmitFeedback = async ( | ||
feedbackType: FormValues["feedbackType"], | ||
name: FormValues["name"], | ||
email: FormValues["email"], | ||
message: FormValues["message"] | ||
) => { | ||
try { | ||
const response = await api.post(`/jira/feedback/`, { | ||
feedbacktype: feedbackType, | ||
name, | ||
email, | ||
message, | ||
}); | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error(s) during handleSubmitFeeedback: ", error); | ||
throw error; | ||
} | ||
}; | ||
|
||
export { handleSubmitFeedback }; |
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.