-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
967e702
commit adcc429
Showing
18 changed files
with
518 additions
and
61 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import useMessage from "../../hooks/useMessages"; | ||
import DiscussionListItem from "./DiscussionListItem"; | ||
|
||
type Props = { | ||
selectedDiscussionId?: number; | ||
onSelectDiscussion: (id: number) => void; | ||
}; | ||
|
||
const DiscussionList: React.FC<Props> = ({ | ||
selectedDiscussionId, | ||
onSelectDiscussion, | ||
}) => { | ||
const { discussions, loading } = useMessage(); | ||
|
||
return ( | ||
<div className="hidden h-full w-full divide-y overflow-y-auto border bg-white shadow lg:block"> | ||
{loading && | ||
!discussions && | ||
[1, 2, 3, 4, 5, 6, 7, 8, 9].map((_) => ( | ||
<div | ||
key={_} | ||
className="flex h-20 w-full animate-pulse cursor-pointer items-center gap-x-2 bg-blue-light px-2 py-3 transition hover:bg-opacity-50" | ||
> | ||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-blue-hover text-sm font-medium text-white" /> | ||
<div className="flex flex-col gap-y-2"> | ||
<div className="h-1.5 w-40 bg-gray-300" /> | ||
<div className="h-2 w-32 bg-gray-300" /> | ||
<div className="h-1.5 w-24 bg-gray-300" /> | ||
</div> | ||
</div> | ||
))} | ||
{!loading && | ||
discussions && | ||
discussions.map(({ annonce, annonceur, demandeur, id, messages }) => ( | ||
<DiscussionListItem | ||
key={id} | ||
annonce={annonce} | ||
annonceur={annonceur} | ||
demandeur={demandeur} | ||
lastMessage={messages[messages.length - 1].contenu} | ||
onClick={() => onSelectDiscussion(id)} | ||
selected={selectedDiscussionId === id} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DiscussionList; |
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,69 @@ | ||
import React from "react"; | ||
import useAuth from "../../hooks/useAuth"; | ||
import { Announcement } from "../../typings/announcement"; | ||
import { Auth } from "../../typings/user"; | ||
|
||
type Props = { | ||
onClick: () => void; | ||
selected: boolean; | ||
annonceur: Auth.User; | ||
demandeur: Auth.User; | ||
lastMessage: string; | ||
annonce: Omit< | ||
Announcement.Announcement, | ||
"auteur" | "fans" | "photos" | "localisation" | ||
>; | ||
}; | ||
|
||
const DiscussionListItem: React.FC<Props> = ({ | ||
onClick, | ||
selected, | ||
annonceur, | ||
demandeur, | ||
lastMessage, | ||
annonce, | ||
}) => { | ||
const { currentUser } = useAuth(); | ||
return ( | ||
<div | ||
onClick={onClick} | ||
className={`flex cursor-pointer ${ | ||
selected ? "bg-blue-light" : "" | ||
} items-center gap-2 px-2 py-3 transition duration-300 last:!border-b hover:bg-blue-light`} | ||
> | ||
<div> | ||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-blue-hover p-1 text-sm font-medium text-white"> | ||
<img | ||
src={`https://api.dicebear.com/5.x/bottts/svg?seed=${ | ||
annonceur.email === currentUser?.email | ||
? demandeur.nom + demandeur.prenom + demandeur.email | ||
: annonceur.nom + annonceur.prenom + annonceur.email | ||
}`} | ||
alt="avatar" | ||
className="h-full w-full rounded-full" | ||
/> | ||
</div> | ||
</div> | ||
<div className="flex w-full flex-col gap-y-1"> | ||
<p className="w-fit text-sm font-medium text-blue-primary"> | ||
<span className="underline"> | ||
{annonceur.email === currentUser?.email && "Mon "} | ||
Annonce: | ||
</span>{" "} | ||
{annonce.titre.substring(0, 40)} {annonce.titre.length > 40 && "..."}{" "} | ||
</p> | ||
<p className="text-sm font-medium text-slate-800"> | ||
<span className="underline">Avec:</span>{" "} | ||
{annonceur.email === currentUser?.email | ||
? demandeur.nom + " " + demandeur.prenom | ||
: annonceur.nom + " " + annonceur.prenom} | ||
</p> | ||
<p className="text-xs text-slate-600"> | ||
{lastMessage.substring(0, 40)} {lastMessage.length > 40 && "..."} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DiscussionListItem; |
Oops, something went wrong.