feat: Favorites (#1094)
* Adding the favorite button * favorites services and resolvers * favorites schema * favorite ability handler * favorite module export * front end UI * front end graphql additions * server ability handlers * server resolvers and services * css fix * Adding the favorite button * favorites services and resolvers * favorites schema * favorite ability handler * favorite module export * front end UI * front end graphql additions * server ability handlers * server resolvers and services * css fix * delete favorites handler and resolver * removed favorite from index list * chip avatar size props * index list additions * UI additions for favorites functionality * lint fixes * graphql codegen * UI fixes * favorite hook addition * moved to ~/modules * Favorite mapping to workspaceMember * graphql codegen * cosmetic changes * camel cased methods * graphql codegen
This commit is contained in:
@ -3,6 +3,7 @@ import { getOperationName } from '@apollo/client/utilities';
|
||||
import { useTheme } from '@emotion/react';
|
||||
|
||||
import { Timeline } from '@/activities/timeline/components/Timeline';
|
||||
import { useFavorites } from '@/favorites/hooks/useFavorites';
|
||||
import { PersonPropertyBox } from '@/people/components/PersonPropertyBox';
|
||||
import { GET_PERSON, usePersonQuery } from '@/people/queries';
|
||||
import { IconUser } from '@/ui/icon';
|
||||
@ -20,9 +21,12 @@ import { ShowPageContainer } from '../../modules/ui/layout/components/ShowPageCo
|
||||
|
||||
export function PersonShow() {
|
||||
const personId = useParams().personId ?? '';
|
||||
const { insertPersonFavorite, deletePersonFavorite } = useFavorites();
|
||||
|
||||
const { data } = usePersonQuery(personId);
|
||||
const person = data?.findUniquePerson;
|
||||
const isFavorite =
|
||||
person?.Favorite && person?.Favorite?.length > 0 ? true : false;
|
||||
|
||||
const theme = useTheme();
|
||||
const [uploadPicture] = useUploadPersonPictureMutation();
|
||||
@ -40,11 +44,18 @@ export function PersonShow() {
|
||||
});
|
||||
}
|
||||
|
||||
async function handleFavoriteButtonClick() {
|
||||
if (isFavorite) deletePersonFavorite(personId);
|
||||
else insertPersonFavorite(personId);
|
||||
}
|
||||
|
||||
return (
|
||||
<WithTopBarContainer
|
||||
title={person?.firstName ?? ''}
|
||||
icon={<IconUser size={theme.icon.size.md} />}
|
||||
hasBackButton
|
||||
isFavorite={isFavorite}
|
||||
onFavouriteButtonClick={handleFavoriteButtonClick}
|
||||
>
|
||||
<ShowPageContainer>
|
||||
<ShowPageLeftContainer>
|
||||
|
||||
Reference in New Issue
Block a user