diff --git a/api/index.ts b/api/index.ts index 2208d18..255deca 100644 --- a/api/index.ts +++ b/api/index.ts @@ -58,8 +58,8 @@ app.use( "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-type", + "Authorization", "Origin", - "Access-Control-Allow-Origin", "Accept", "Options", "X-Requested-With", diff --git a/web/src/api/apiRequests.ts b/web/src/api/apiRequests.ts index 669a8ac..76e7890 100644 --- a/web/src/api/apiRequests.ts +++ b/web/src/api/apiRequests.ts @@ -31,6 +31,18 @@ export const updateUserInfo = async (data: object): Promise => { return response; }; +export const updateUserTicketInfo = async ( + data: object +): Promise => { + const response = await axios.post("/api/user/user-ticket-info", data, { + headers: { + "Content-Type": "application/json", + }, + }); + + return response; +}; + // User membership expiry export const fetchUserMembershipExpiry = async (): Promise => { diff --git a/web/src/components/forms/CheckoutInformation.tsx b/web/src/components/forms/CheckoutInformation.tsx index f9495f2..dd8f816 100644 --- a/web/src/components/forms/CheckoutInformation.tsx +++ b/web/src/components/forms/CheckoutInformation.tsx @@ -1,4 +1,3 @@ -import axios from "axios"; import { QuestionAnswer, TicketAndQuestion } from "../../types/types"; import { useEffect, useState } from "react"; import { useQuery } from "@apollo/client"; @@ -7,6 +6,7 @@ import { Mapper } from "@utils/Mapper"; import LoadingSpinner from "@components/navigation/LoadingSpinner"; import { useNavigate } from "react-router"; import CheckoutInformationForm from "./CheckoutInformationForm"; +import { updateUserTicketInfo } from "../../api/apiRequests"; interface CheckoutInformationProps { ticketId: number; @@ -68,11 +68,7 @@ export default function CheckoutInformation({ // Submit ticket information to backend const onSubmit = async (data: any) => { try { - const response = await axios.post("/api/user/user-ticket-info", data, { - headers: { - "Content-Type": "application/json", - }, - }); + const response = await updateUserTicketInfo(data); if (response.status === 200) { // Form Submission Successful setSubmitLoading(false);