Skip to content

Commit

Permalink
Added changes for status and location (#117)
Browse files Browse the repository at this point in the history
1. Backend allow application status to have a null value in which case
frontend will display "no decision yet".
<img width="715" alt="image"
src="https://github.com/gcivil-nyu-org/INET-Monday-Fall2023-Team-1/assets/57152208/7280a070-1e29-4606-b0f4-b78953651868">

2. This PR also contains changes to display the full line of locations
i.e address, city, zipcode
<img width="678" alt="image"
src="https://github.com/gcivil-nyu-org/INET-Monday-Fall2023-Team-1/assets/57152208/53881e1e-cb96-45f8-9ede-421e8bfe70b5">

---------

Co-authored-by: Sameer Kolhar <[email protected]>
  • Loading branch information
ManaliTanna and kolharsam authored Dec 6, 2023
1 parent 2c1e776 commit a0373c3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
33 changes: 23 additions & 10 deletions frontend/src/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface Location {
address: string;
city: string;
country: string;
zipcode: string;
}

interface Application {
Expand Down Expand Up @@ -111,12 +112,13 @@ const Dashboard = () => {
const jobDetailsResponse = await axios.get(API_ROUTES.JOBS, {
params: { id: myApplications.job },
});
const locationDetailsResponse = await axios.get(`${API_ROUTES.USER.LOCATION}`);
const locationDetail = locationDetailsResponse.data;

//console.log("job details response", jobDetailsResponse.data);
const jobDetail = jobDetailsResponse.data;

const locationDetailsResponse = await axios.get(
`${API_ROUTES.USER.LOCATION}?location_id=${jobDetail.location}`
);
const locationDetail = locationDetailsResponse.data;

const petDetailsResponse = await axios.get(`${API_ROUTES.PETS}${jobDetail.pet}`);
const petDetail = petDetailsResponse.data;

Expand Down Expand Up @@ -208,7 +210,10 @@ const Dashboard = () => {
<div>
<p className="font-bold mb-2">Pet Name: {job.pet.name}</p>
<p>Job Status: {job.status}</p>
<p>Location: {job?.location?.address ?? ""}</p>
<p>
Location: {job?.location?.address ?? ""}, {job?.location?.city ?? ""},{" "}
{job?.location?.zipcode ?? ""}
</p>
<p>Pay: ${job.pay}</p>
<p>Start: {job.start}</p>
<p>End: {job.end}</p>
Expand Down Expand Up @@ -240,11 +245,19 @@ const Dashboard = () => {
className="border border-gray-300 mb-4 p-4 rounded-md"
>
<div>
<p>Application Status: {myApplications.status}</p>
<p>Pet:{myApplications.pet.name}</p>
<p>Start:{myApplications.job.start}</p>
<p>End:{myApplications.job.end}</p>
<p>Pay:{myApplications.job.pay}</p>
<p className="font-bold mb-2">Pet Name : {myApplications.pet.name}</p>
<p>
Location: {myApplications?.location?.address ?? ""},{" "}
{myApplications?.location?.city ?? ""},{" "}
{myApplications?.location?.zipcode ?? ""}
</p>
<p>Pay: ${myApplications.job.pay}</p>
<p>Start: {myApplications.job.start}</p>
<p>End: {myApplications.job.end}</p>
<p className="font-bold mb-2">
Application Status:{" "}
{!myApplications.status ? "No Decision" : myApplications.status}
</p>
</div>
</li>
))}
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/Jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface Location {
address: string;
city: string;
country: string;
zipcode: string;
}

interface Pet {
Expand Down Expand Up @@ -207,15 +208,18 @@ const Jobs: React.FC = () => {
<div>
<p className="font-bold mb-2">Pet Name: {job.pet.name}</p>
<p>Status: {job.status}</p>
<p>Location: {job?.location?.address ?? ""}</p>
<p>
Location: {job?.location?.address ?? ""}, {job?.location?.city ?? ""},{" "}
{job?.location?.zipcode ?? ""}
</p>
<p>Pay: {job.pay}</p>
<p>Start: {job.start}</p>
<p>End: {job.end}</p>
</div>
<div className="mt-4 flex">
<button
onClick={() => handleDelete(job.id)}
className="bg-red-500 text-white px-4 py-2 rounded-md"
className="bg-red-500 text-white px-4 py-2 rounded-md mr-2"
>
Delete
</button>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/auth/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const AuthProvider = ({ children }: React.PropsWithChildren<unknown>) => {
.then((response) => {
if (response.status === 201) {
toast.success(
`An account has been created for ${response.data?.data?.email ?? ""
`An account has been created for ${
response.data?.data?.email ?? ""
}. Redirecting to login page...`
);
navigate("/login");
Expand Down
7 changes: 3 additions & 4 deletions furbaby/api/migrations/0015_alter_applications_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@


class Migration(migrations.Migration):

dependencies = [
('api', '0014_merge_20231127_1811'),
("api", "0014_merge_20231127_1811"),
]

operations = [
migrations.AlterField(
model_name='applications',
name='status',
model_name="applications",
name="status",
field=models.TextField(null=True),
),
]
2 changes: 1 addition & 1 deletion furbaby/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def post(self, request, *args, **kwargs):
application_data = {
"user": request.user.id,
"job": job_id,
"status": "rejected", # You can set an initial status here
"status": None, # You can set an initial status here
"details": {}, # You can add more details if needed
}
application_serializer = ApplicationSerializer(
Expand Down

0 comments on commit a0373c3

Please sign in to comment.