* Refactor icons passed as props with the new way Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Update more files Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Fix according to review * Fix according to review * Fix according to review * Fix chromatic regressions --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { getOperationName } from '@apollo/client/utilities';
|
|
import { useRecoilState } from 'recoil';
|
|
|
|
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
|
import { GET_ACTIVITIES_BY_TARGETS } from '@/activities/graphql/queries/getActivitiesByTarget';
|
|
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
|
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
|
import { LightIconButton } from '@/ui/button/components/LightIconButton';
|
|
import { IconTrash } from '@/ui/icon';
|
|
import { isRightDrawerOpenState } from '@/ui/right-drawer/states/isRightDrawerOpenState';
|
|
import { useDeleteActivityMutation } from '~/generated/graphql';
|
|
|
|
type OwnProps = {
|
|
activityId: string;
|
|
};
|
|
|
|
export function ActivityActionBar({ activityId }: OwnProps) {
|
|
const [deleteActivityMutation] = useDeleteActivityMutation();
|
|
const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
|
|
|
|
function deleteActivity() {
|
|
deleteActivityMutation({
|
|
variables: { activityId },
|
|
refetchQueries: [
|
|
getOperationName(GET_COMPANIES) ?? '',
|
|
getOperationName(GET_PEOPLE) ?? '',
|
|
getOperationName(GET_ACTIVITIES_BY_TARGETS) ?? '',
|
|
getOperationName(GET_ACTIVITIES) ?? '',
|
|
],
|
|
});
|
|
setIsRightDrawerOpen(false);
|
|
}
|
|
|
|
return (
|
|
<LightIconButton
|
|
Icon={IconTrash}
|
|
onClick={deleteActivity}
|
|
accent="tertiary"
|
|
size="medium"
|
|
/>
|
|
);
|
|
}
|