-
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
8 changed files
with
154 additions
and
64 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
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,5 +1,5 @@ | ||
import axios from 'axios'; | ||
import axios from 'axios' | ||
|
||
export const api = axios.create({ | ||
baseURL: 'https//:localhost:3333' | ||
baseURL: 'http://localhost:3333' | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,59 @@ | ||
import { CircleCheck } from "lucide-react"; | ||
import { useEffect, useState } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import { api } from "../../lib/axios"; | ||
import { format } from "date-fns"; | ||
import { ptBR } from "date-fns/locale"; | ||
|
||
interface Activity{ | ||
date: string | ||
activities: { | ||
id: string | ||
title: string | ||
occurs_at: string | ||
}[] | ||
} | ||
|
||
export function Activities(){ | ||
return( | ||
<div className="space-y-8"> | ||
<div className="space-y-2.5"> | ||
<div className="flex gap-2 items-baseline"> | ||
<span className="text-xl text-zinc-300 font-semibold">Dia 17</span> | ||
<span className="text-xs text-zinc-500">Sabádo</span> | ||
</div> | ||
<p className="text-sm text-zinc-500">Nenhuma atividade cadastrada nessa data.</p> | ||
</div> | ||
const { tripId } = useParams() | ||
const [activities, setActivities] = useState<Activity[]>([]) | ||
|
||
<div className="space-y-2.5"> | ||
useEffect(() => { | ||
api.get(`/trips/${tripId}/activities`).then(response => setActivities(response.data.activities)) | ||
}, [tripId]) | ||
|
||
|
||
return ( | ||
<div className="space-y-8"> | ||
{activities.map(category => { | ||
return ( | ||
<div key={category.date} className="space-y-2.5"> | ||
<div className="flex gap-2 items-baseline"> | ||
<span className="text-xl text-zinc-300 font-semibold">Dia 18</span> | ||
<span className="text-xs text-zinc-500">Domingo</span> | ||
</div> | ||
<div className="space=y=2.5"> | ||
<div className="px-4 py-2.5 bg-zinc-900 rounded-xl shadow-shape flex items-center gap-3"> | ||
<CircleCheck className="size-5 text-lime-300"/> | ||
<span className="text-zinc-100">Academia em Grupo</span> | ||
<span className="text-zinc-400 text-sm ml-auto">08:00h</span> | ||
</div> | ||
</div> | ||
<div className="space=y=2.5"> | ||
<div className="px-4 py-2.5 bg-zinc-900 rounded-xl shadow-shape flex items-center gap-3"> | ||
<CircleCheck className="size-5 text-lime-300"/> | ||
<span className="text-zinc-100">Estudar</span> | ||
<span className="text-zinc-400 text-sm ml-auto">10:00h</span> | ||
</div> | ||
<span className="text-xl text-zinc-300 font-semibold">Dia {format(category.date, 'd')}</span> | ||
<span className="text-xs text-zinc-500">{format(category.date, 'EEEE', { locale: ptBR })}</span> | ||
</div> | ||
</div> | ||
{category.activities.length > 0 ? ( | ||
<div className="space-y-2.5"> | ||
{category.activities.map(activity => { | ||
return ( | ||
<div key={activity.id} className="space-y-2.5"> | ||
<div className="px-4 py-2.5 bg-zinc-900 rounded-xl shadow-shape flex items-center gap-3"> | ||
<CircleCheck className="size-5 text-lime-300" /> | ||
<span className="text-zinc-100">{activity.title}</span> | ||
<span className="text-zinc-400 text-sm ml-auto"> | ||
{format(activity.occurs_at, "HH:mm'h'")} | ||
</span> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
) : ( | ||
<p className="text-zinc-500 text-sm">Nenhuma atividade cadastrada nessa data.</p> | ||
)} | ||
</div> | ||
) | ||
})} | ||
</div> | ||
) | ||
) | ||
} |
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 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