forked from aws-samples/amplify-next-template
-
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.
Merge pull request #175 from cabcookie:improve-person-mention
feat: recommend projects to add to meeting notes
- Loading branch information
Showing
10 changed files
with
173 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { type Schema } from "@/amplify/data/resource"; | ||
import { generateClient } from "aws-amplify/data"; | ||
import { flatMap, flatten, flow, get, uniq } from "lodash/fp"; | ||
import useSWR from "swr"; | ||
import { handleApiErrors } from "./globals"; | ||
import { Meeting } from "./useMeetings"; | ||
const client = generateClient<Schema>(); | ||
|
||
const fetchPerson = async (personId: string) => { | ||
const { data, errors } = await client.models.Person.get( | ||
{ id: personId }, | ||
{ | ||
selectionSet: ["meetings.meeting.activities.forProjects.projectsId"], | ||
} | ||
); | ||
if (errors) { | ||
handleApiErrors(errors, "Error loading meeting project recommendations"); | ||
throw errors; | ||
} | ||
return flow( | ||
get("meetings"), | ||
flatMap(get("meeting.activities")), | ||
flatMap(get("forProjects")), | ||
flatMap(get("projectsId")) | ||
)(data); | ||
}; | ||
|
||
const fetchMeetingProjectRecommendation = (meeting?: Meeting) => async () => { | ||
if (!meeting) return; | ||
const data = await Promise.all(meeting.participantIds.map(fetchPerson)); | ||
return flow(flatten, uniq)(data) as string[] | undefined; | ||
}; | ||
|
||
const useMeetingProjectRecommendation = (meeting?: Meeting) => { | ||
const { | ||
data: projectIds, | ||
isLoading, | ||
error, | ||
} = useSWR( | ||
`/api/meetings/${meeting?.id}/recommendations`, | ||
fetchMeetingProjectRecommendation(meeting) | ||
); | ||
|
||
return { projectIds, isLoading, error }; | ||
}; | ||
|
||
export default useMeetingProjectRecommendation; |
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,53 @@ | ||
import { useAccountsContext } from "@/api/ContextAccounts"; | ||
import { useProjectsContext } from "@/api/ContextProjects"; | ||
import useMeetingProjectRecommendation from "@/api/useMeetingProjectRecommendation"; | ||
import { Meeting } from "@/api/useMeetings"; | ||
import { compact, filter, flatMap, flow, get, map } from "lodash/fp"; | ||
import { FC } from "react"; | ||
|
||
const filterOutProjectIds = (avoidIds: string[] | undefined) => (id: string) => | ||
!avoidIds?.includes(id); | ||
|
||
type MeetingProjectRecommenderProps = { | ||
meeting?: Meeting | undefined; | ||
addProjectToMeeting: (projectId: string) => void; | ||
}; | ||
|
||
const MeetingProjectRecommender: FC<MeetingProjectRecommenderProps> = ({ | ||
meeting, | ||
addProjectToMeeting, | ||
}) => { | ||
const { projectIds } = useMeetingProjectRecommendation(meeting); | ||
const { getProjectById } = useProjectsContext(); | ||
const { getAccountNamesByIds } = useAccountsContext(); | ||
|
||
return ( | ||
<div className="px-1 md:px-2 text-sm text-muted-foreground"> | ||
<span className="font-semibold"> | ||
Add these projects where participants contributed: | ||
</span> | ||
{flow( | ||
filter( | ||
filterOutProjectIds( | ||
flow(get("activities"), flatMap(get("projectIds")))(meeting) | ||
) | ||
), | ||
map(getProjectById), | ||
compact, | ||
filter((p) => !p.done), | ||
map(({ id, project, accountIds }) => ( | ||
<span | ||
key={id} | ||
className="pl-1 md:pl-2 hover:text-primary hover:underline hover:underline-offset-2 hover:cursor-pointer" | ||
onClick={() => addProjectToMeeting(id)} | ||
> | ||
{project} | ||
{accountIds && ` (${getAccountNamesByIds(accountIds)})`} | ||
</span> | ||
)) | ||
)(projectIds)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default MeetingProjectRecommender; |
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# Fehlerbehebungen CRM Projekte und Hauptmenü (Version :VERSION) | ||
# Meetings weiter optimieren (Version :VERSION) | ||
|
||
- Es gab CRM Projekte, bei denen das Abschlussdatum weit in der Zukunft lag und das CRM Projekt bereits geschlossen ist (verloren oder gewonnen). In diesem Fall wäre das Projekt noch sehr lange und immer wieder in der Liste aufgetaucht, obwohl nichts mehr dafür getan werden konnte. Das ist nun behoben. Es wird immer das kleinere Datum für den Import herangezogen, entweder das Abschlussdatum oder das System-Abschlussdatum, das anzeigt, wann das Projekt geschlossen wurde. | ||
- Das Hauptmenü führte häufig zu Abstürzen, wenn der Suchbegriff einmal mehr als 3 Zeichen hatte und dann wieder weniger. Der Grund dafür war, dass die Gruppen als Komponenten immer erst dann erschienen, wenn die Suche mehr als 3 Zeichen hatte. CmdK kann nicht gut damit umgehen, wenn die React Komponente plötzlich wieder ganz verschwindet. Wir verstecken sie nun mit einer CSS Klasse, entfernen sie aber nicht komplett vom DOM. | ||
- In Meetings werden Projekte angezeigt, bei denen die Teilnehmer schon einmal in Meetings involviert gewesen sind. Wenn ein Projekt angeklickt wird, wird es direkt dem Meeting hinzugefügt und man kann anfangen, Notizen zu machen. | ||
- In Meetings können Teilnehmer wieder entfernt werden, wenn man sie versehentlich hinzugefügt hat. | ||
- In der Detailansicht einer Person werden im Untertitel von Notizen nur noch Projekte angezeigt, in die die Person involviert ist, die aber noch nicht abgeschlossen sind. | ||
|
||
## In Arbeit | ||
|
||
## Geplant | ||
|
||
- Blöcke als einzelne Records in der Datenbank speichern. |