-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
175 additions
and
105 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,20 @@ | ||
import axios from 'axios' | ||
import Cookies from 'js-cookie' | ||
|
||
const api = axios.create({ | ||
// baseURL: 'http://jaydenl.pythonanywhere.com/api/', // Replace with the URL of your Django API | ||
baseURL: 'http://127.0.0.1:8000/api/', | ||
headers: { | ||
"Content-Type": "multipart/form-data", | ||
"Authorization": "Token 043ac7dda62905f56ca9d0029ccf9dff922dd54d" | ||
}, | ||
}) | ||
api.interceptors.request.use((config) => { | ||
const token = Cookies.get('token') | ||
if (token) { | ||
config.headers['Authorization'] = `Token ${token}` | ||
} | ||
return config | ||
}) | ||
|
||
export default api |
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 |
---|---|---|
@@ -1,15 +1,35 @@ | ||
import Head from 'next/head'; | ||
import Login from '@/components/OpportunityForm'; | ||
import Opportunities from '../opportunities/page'; | ||
"use client" | ||
import React, { useState, useEffect } from 'react'; | ||
import PetCard from '@/components/PetCard'; | ||
import Image from "next/image"; | ||
import api from "@/api"; | ||
import Cookies from 'js-cookie' | ||
import { PetCardProps, ShelterProp } from "@/components/Props"; | ||
import Form from '@/components/OpportunityForm'; | ||
|
||
async function fetchData(): Promise<ShelterProp[]> { | ||
try { | ||
const response = await api.get('shelters/'); | ||
const data = response.data; | ||
console.log(data) | ||
console.log(response) | ||
return data.results; | ||
} catch (error) { | ||
console.error(error); | ||
return []; | ||
} | ||
} | ||
|
||
export default function Opportunities() { | ||
const [shelters, setShelters] = useState<ShelterProp[]>([]); | ||
|
||
useEffect(() => { | ||
fetchData().then((data) => setShelters(data)); | ||
}, []); | ||
|
||
export default function LoginPage() { | ||
return ( | ||
<> | ||
<Head> | ||
<title>Create Opportunity</title> | ||
</Head> | ||
<h1>Create Opportunity</h1> | ||
<Opportunities /> | ||
</> | ||
); | ||
<div className="bg-gray-50 rounded shadow p-4 w-full max-w-lg mx-auto"> | ||
<Form shelters={shelters} /> | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.