Update favorites query and state to work with new backend (#2520)
* wip * wip * adding favorite works in the database * favorites are showing in the left drawer * update favoorite NavItem link * wip * adding favorite works * everything seems to work * fix delete bug * fix update favorite position * update Favorite type * Fix --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -32,7 +32,7 @@ import { companyShowFieldDefinitions } from './constants/companyShowFieldDefinit
|
||||
|
||||
export const CompanyShow = () => {
|
||||
const companyId = useParams().companyId ?? '';
|
||||
const { insertCompanyFavorite, deleteCompanyFavorite } = useFavorites();
|
||||
const { createFavorite, deleteFavorite } = useFavorites();
|
||||
const navigate = useNavigate();
|
||||
const { data, loading } = useCompanyQuery(companyId);
|
||||
const company = data?.findUniqueCompany;
|
||||
@ -49,8 +49,8 @@ export const CompanyShow = () => {
|
||||
company.Favorite && company.Favorite?.length > 0 ? true : false;
|
||||
|
||||
const handleFavoriteButtonClick = async () => {
|
||||
if (isFavorite) deleteCompanyFavorite(companyId);
|
||||
else insertCompanyFavorite(companyId);
|
||||
if (isFavorite) deleteFavorite(companyId);
|
||||
else createFavorite('company', companyId);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -35,7 +35,7 @@ import { personShowFieldDefinition } from './constants/personShowFieldDefinition
|
||||
|
||||
export const PersonShow = () => {
|
||||
const personId = useParams().personId ?? '';
|
||||
const { insertPersonFavorite, deletePersonFavorite } = useFavorites();
|
||||
const { createFavorite, deleteFavorite } = useFavorites();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { data, loading } = usePersonQuery(personId);
|
||||
@ -68,8 +68,8 @@ export const PersonShow = () => {
|
||||
};
|
||||
|
||||
const handleFavoriteButtonClick = async () => {
|
||||
if (isFavorite) deletePersonFavorite(personId);
|
||||
else insertPersonFavorite(personId);
|
||||
if (isFavorite) deleteFavorite(person.id);
|
||||
else createFavorite('person', person.id);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user