-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Nine-Minds/flashing_contact_avatars
flashy contact avatars
- Loading branch information
Showing
2 changed files
with
25 additions
and
9 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 |
---|---|---|
@@ -1,33 +1,42 @@ | ||
// server/src/app/msp/contacts/page.tsx | ||
import React from 'react'; | ||
import dynamic from 'next/dynamic'; | ||
import Contacts from '@/components/contacts/Contacts'; | ||
import ContactModel from '@/lib/models/contact'; | ||
import UserModel from '@/lib/models/user'; | ||
import { User } from 'next-auth'; | ||
|
||
// Import Contacts component with ssr disabled | ||
const Contacts = dynamic(() => import('@/components/contacts/Contacts'), { ssr: false }); | ||
const OverallInteractionsFeed = dynamic( | ||
() => import('@/components/interactions/OverallInteractionsFeed'), | ||
{ ssr: false } | ||
); | ||
|
||
type IdName = { id: string; name: string }; | ||
|
||
export default async function ContactsPage() { | ||
const contacts = await ContactModel.getAll(true); | ||
const users = await UserModel.getAll(); | ||
|
||
const OverallInteractionsFeed = dynamic( | ||
() => import('@/components/interactions/OverallInteractionsFeed'), | ||
{ ssr: false } | ||
// Filter out any duplicate contacts based on contact_name_id | ||
const uniqueContacts = Array.from( | ||
new Map(contacts.map(contact => [contact.contact_name_id, contact])).values() | ||
); | ||
|
||
return ( | ||
<div className="flex flex-col md:flex-row md:space-x-6"> | ||
<div className="w-full md:w-2/3 mb-6 md:mb-0"> | ||
<Contacts initialContacts={contacts} /> | ||
<Contacts initialContacts={uniqueContacts} /> | ||
</div> | ||
<div className="w-full md:w-1/3"> | ||
<OverallInteractionsFeed | ||
users={users.map((user):IdName => ({ id: user.user_id, name: user.username }))} | ||
contacts={contacts.map((contact):IdName => ({ id: contact.contact_name_id, name: contact.full_name }))} | ||
contacts={uniqueContacts.map((contact):IdName => ({ | ||
id: contact.contact_name_id, | ||
name: contact.full_name | ||
}))} | ||
/> | ||
</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