Skip to content

Commit a12800f

Browse files
authored
[SC-52] Removed logs and fixed donation (#46)
* removed logs and fixed donation * merge main --------- Co-authored-by: whlpatricia <whlpatricia@users.noreply.github.com>
1 parent e4b82ca commit a12800f

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

backend/api/views/donation_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def donation_handler(request):
2626
}
2727
],
2828
mode="payment",
29-
success_url="https://google.com", # this should route to the /success page
30-
cancel_url="https://google.com", # this should route back to the donate page
29+
success_url="http://localhost:3000/success?session_id={CHECKOUT_SESSION_ID}", # this should route to the /success page
30+
cancel_url="http://localhost:3000/donate", # this should route back to the donate page
3131
)
3232
return Response({"url": checkout_session.url}, status=status.HTTP_200_OK)
3333
except Exception as e:

webapp/src/pages/about-us.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const AboutUs = (): JSX.Element => {
2222
fetch("http://127.0.0.1:8000/api/portfolio/")
2323
.then((response) => response.json())
2424
.then((data) => {
25-
console.log("API Data:", data);
2625
setPortfolio(data.portfolio || []);
2726
setTotalInvestment(data.total_investment || 0);
2827
})

webapp/src/pages/donate.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FC, useState, useEffect } from 'react';
22
import axios from 'axios';
3+
import { useCookies } from 'react-cookie';
34
import { fetchDonations, fetchDonationAmount } from '@/util/charity';
45

56
interface DonationData {
@@ -17,6 +18,7 @@ interface CharityData {
1718
const DonatePage: FC = () => {
1819
const [loading, setLoading] = useState(false);
1920
const [donationData, setDonationData] = useState<DonationData | null>(null);
21+
const [cookies] = useCookies(['token']);
2022
const [charities, setCharities] = useState<CharityData[]>([]);
2123

2224
useEffect(() => {
@@ -34,15 +36,17 @@ const DonatePage: FC = () => {
3436
const handleDonate = async (fixed: string, amount: string) => {
3537
setLoading(true);
3638
try {
37-
const response = await axios.post(
38-
'http://localhost:8000/api/donation',
39-
{ fixed, amount },
40-
{
41-
headers: { 'Content-Type': 'application/json' },
42-
responseType: 'text',
43-
validateStatus: () => true,
44-
}
45-
);
39+
const response = await axios.post('http://localhost:8000/api/donation', {
40+
fixed,
41+
amount
42+
}, {
43+
headers: {
44+
'Content-Type': 'application/json',
45+
'Authorization': `Bearer ${cookies.token}`
46+
},
47+
responseType: 'text',
48+
validateStatus: () => true
49+
});
4650

4751
const data = JSON.parse(response.data);
4852
if (data.url) {

webapp/src/pages/home.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export default function HomePage() {
4040
const donationsResponse = await getTotalDonations();
4141
const donations = donationsResponse?.data?.donation_total || -1; // Safely access donation_total and alert that something is wrong by using -1
4242
setDonationStockData({ amount: donations });
43-
console.log(donationsResponse.data);
4443
};
4544
fetchData();
4645
}, []);

webapp/src/pages/register.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const RegisterPage: () => JSX.Element = () => {
6363
}, []);
6464

6565
const handlePhoneChange = (value: string) => {
66-
console.log("PhoneInput Raw Value:", value);
6766
const formattedValue = value.startsWith("+") ? value : `+${value}`;
6867
setPhoneNumber(formattedValue);
6968
setValue("phone_number", formattedValue);

webapp/src/pages/success.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const SuccessPage: FC = () => {
3838
const charity = "Lorem Ipsum";
3939

4040
// making request to backend
41-
await axios.post('http://localhost:8000/api/send-payment-recieved-email/', { receiver: email, charity });
41+
await axios.post('http://localhost:8000/api/send-payment-recieved-email', { receiver: email, charity });
4242
} catch (error) {
4343
console.error("Error sending payment received email:", error);
4444
// TODO: Still need to add the donation record to the DB somehow

0 commit comments

Comments
 (0)