Fix/company team crud (#2614)
* Fixed basePathToShowPage * Fixed company team list * Fixed : create, update, delete and detach people from company.
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import styled from '@emotion/styled';
|
||||
import { autoUpdate, flip, offset, useFloating } from '@floating-ui/react';
|
||||
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { Person } from '@/people/types/Person';
|
||||
import { IconDotsVertical, IconLinkOff, IconTrash } from '@/ui/display/icon';
|
||||
import { FloatingIconButton } from '@/ui/input/button/components/FloatingIconButton';
|
||||
@ -104,29 +107,34 @@ export const PeopleCard = ({
|
||||
setIsOptionsOpen(!isOptionsOpen);
|
||||
};
|
||||
|
||||
const handleDetachPerson = () => {
|
||||
// updatePerson({
|
||||
// variables: {
|
||||
// where: {
|
||||
// id: person.id,
|
||||
// },
|
||||
// data: {
|
||||
// company: {
|
||||
// disconnect: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
// });
|
||||
// TODO: refactor with useObjectMetadataItem V2 with typed hooks
|
||||
const { findManyQuery, updateOneMutation, deleteOneMutation } =
|
||||
useObjectMetadataItem({
|
||||
objectNameSingular: 'person',
|
||||
});
|
||||
|
||||
const [updatePerson] = useMutation(updateOneMutation);
|
||||
const [deletePerson] = useMutation(deleteOneMutation);
|
||||
|
||||
const handleDetachPerson = async () => {
|
||||
await updatePerson({
|
||||
variables: {
|
||||
idToUpdate: person.id,
|
||||
input: {
|
||||
companyId: null,
|
||||
},
|
||||
},
|
||||
refetchQueries: [getOperationName(findManyQuery) ?? ''],
|
||||
});
|
||||
};
|
||||
|
||||
const handleDeletePerson = () => {
|
||||
// deletePerson({
|
||||
// variables: {
|
||||
// ids: person.id,
|
||||
// },
|
||||
// refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
// });
|
||||
deletePerson({
|
||||
variables: {
|
||||
idToDelete: person.id,
|
||||
},
|
||||
refetchQueries: [getOperationName(findManyQuery) ?? ''],
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user