-
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.
feat(www): new participant in exchange notification (#1444)
- Loading branch information
1 parent
612f0d1
commit 51f1d3c
Showing
27 changed files
with
505 additions
and
252 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
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
62 changes: 62 additions & 0 deletions
62
apps/www/app/(main)/door/[code]/(private)/notifications/ExchangeNewMessage.tsx
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,62 @@ | ||
// | ||
|
||
import { card } from "@1.ui/react/card/atom"; | ||
import { format } from "date-fns"; | ||
import { fr } from "date-fns/locale"; | ||
import { useSession } from "next-auth/react"; | ||
import Link from "next/link"; | ||
import { select_exchange_message } from "./select_exchange_message"; | ||
import type { Notification } from "./type"; | ||
|
||
// | ||
|
||
export function ExchangeNewMessage({ | ||
notification, | ||
}: { | ||
notification: Notification; | ||
}) { | ||
const session = useSession(); | ||
if (!session.data) return null; | ||
const { | ||
data: { | ||
profile: { id: my_profile_id }, | ||
}, | ||
} = session; | ||
const { base, body } = card(); | ||
const { id, created_at, read_at } = notification; | ||
const exchange_message = select_exchange_message(notification); | ||
|
||
if (!exchange_message) return null; | ||
|
||
const { | ||
exchange_id, | ||
exchange: { | ||
owner: { profile_id }, | ||
title, | ||
}, | ||
message: { | ||
author: { name }, | ||
thread_id, | ||
}, | ||
} = exchange_message; | ||
return ( | ||
<Link id={id} href={`/@~/exchanges/inbox/${exchange_id}/${thread_id}`}> | ||
<div | ||
className={base({ className: read_at ? "bg-transparent" : "bg-white" })} | ||
> | ||
<div className={body()}> | ||
<time | ||
className="float-right text-xs text-gray-500" | ||
dateTime={created_at.toUTCString()} | ||
title={created_at.toUTCString()} | ||
> | ||
{format(created_at, "Pp", { locale: fr })} | ||
</time> | ||
<b>{name}</b> vous a envoyé un nouveau message sur{" "} | ||
{my_profile_id === profile_id ? "votre " : "l'"}échange{" "} | ||
<i>“{title}”</i> | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
} |
49 changes: 49 additions & 0 deletions
49
apps/www/app/(main)/door/[code]/(private)/notifications/ExchangeNewParticipant.tsx
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 { card } from "@1.ui/react/card/atom"; | ||
import { format } from "date-fns"; | ||
import { fr } from "date-fns/locale"; | ||
import Link from "next/link"; | ||
import { select_exchange_message } from "./select_exchange_message"; | ||
import type { Notification } from "./type"; | ||
|
||
// | ||
|
||
export function ExchangeNewParticipant({ | ||
notification, | ||
}: { | ||
notification: Notification; | ||
}) { | ||
const { base, body } = card(); | ||
const { id, created_at, read_at } = notification; | ||
const exchange_message = select_exchange_message(notification); | ||
if (!exchange_message) return null; | ||
|
||
const { | ||
exchange_id, | ||
exchange: { title }, | ||
message: { | ||
author: { name }, | ||
thread_id, | ||
}, | ||
} = exchange_message; | ||
return ( | ||
<Link id={id} href={`/@~/exchanges/inbox/${exchange_id}/${thread_id}`}> | ||
<div | ||
className={base({ className: read_at ? "bg-transparent" : "bg-white" })} | ||
> | ||
<div className={body()}> | ||
<time | ||
className="float-right text-xs text-gray-500" | ||
dateTime={created_at.toUTCString()} | ||
title={created_at.toUTCString()} | ||
> | ||
{format(created_at, "Pp", { locale: fr })} | ||
</time> | ||
<b>{name}</b> vous a envoyé une nouvelle demade à votre échange{" "} | ||
<i>“{title}”</i> | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
} |
46 changes: 46 additions & 0 deletions
46
apps/www/app/(main)/door/[code]/(private)/notifications/InboxNewMessage.tsx
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,46 @@ | ||
// | ||
|
||
import { card } from "@1.ui/react/card/atom"; | ||
import { format } from "date-fns"; | ||
import { fr } from "date-fns/locale"; | ||
import Link from "next/link"; | ||
import type { Notification } from "./type"; | ||
|
||
// | ||
|
||
export function InboxNewMessage({ | ||
notification, | ||
}: { | ||
notification: Notification; | ||
}) { | ||
const { base, body } = card(); | ||
const { id, created_at, read_at, inbox_message } = notification; | ||
|
||
if (!inbox_message) return null; | ||
if (!inbox_message.message) return null; | ||
|
||
const { | ||
message: { | ||
author: { name }, | ||
thread_id, | ||
}, | ||
} = inbox_message; | ||
return ( | ||
<Link id={id} href={`/@~/inbox/${thread_id}`}> | ||
<div | ||
className={base({ className: read_at ? "bg-transparent" : "bg-white" })} | ||
> | ||
<div className={body()}> | ||
<time | ||
className="float-right text-xs text-gray-500" | ||
dateTime={created_at.toUTCString()} | ||
title={created_at.toUTCString()} | ||
> | ||
{format(created_at, "Pp", { locale: fr })} | ||
</time> | ||
<b>{name}</b> vous a envoyé un nouveau message | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
} |
Oops, something went wrong.