Add linkedinUrl and job titles to table views (#809)
* Add linedinUrl and job titles to table views * Keep address in the end * Add mock data
This commit is contained in:
@ -0,0 +1,43 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { peopleJobTitleFamilyState } from '@/people/states/peopleJobTitleFamilyState';
|
||||
import { EditableCellText } from '@/ui/table/editable-cell/types/EditableCellText';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdateOnePersonMutation } from '~/generated/graphql';
|
||||
|
||||
export function EditablePeopleJobTitleCell() {
|
||||
const currentRowEntityId = useCurrentRowEntityId();
|
||||
|
||||
const [updatePerson] = useUpdateOnePersonMutation();
|
||||
|
||||
const jobTitle = useRecoilValue(
|
||||
peopleJobTitleFamilyState(currentRowEntityId ?? ''),
|
||||
);
|
||||
|
||||
const [internalValue, setInternalValue] = useState(jobTitle ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
setInternalValue(jobTitle ?? '');
|
||||
}, [jobTitle]);
|
||||
|
||||
return (
|
||||
<EditableCellText
|
||||
value={internalValue}
|
||||
onChange={setInternalValue}
|
||||
onSubmit={() =>
|
||||
updatePerson({
|
||||
variables: {
|
||||
where: {
|
||||
id: currentRowEntityId,
|
||||
},
|
||||
data: {
|
||||
jobTitle: internalValue,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
onCancel={() => setInternalValue(jobTitle ?? '')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { peopleLinkedinUrlFamilyState } from '@/people/states/peopleLinkedinUrlFamilyState';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdateOnePersonMutation } from '~/generated/graphql';
|
||||
|
||||
import { EditableCellURL } from '../../../ui/table/editable-cell/types/EditableCellURL';
|
||||
|
||||
export function EditablePeopleLinkedinUrlCell() {
|
||||
const currentRowEntityId = useCurrentRowEntityId();
|
||||
|
||||
const [updatePerson] = useUpdateOnePersonMutation();
|
||||
|
||||
const linkedinUrl = useRecoilValue(
|
||||
peopleLinkedinUrlFamilyState(currentRowEntityId ?? ''),
|
||||
);
|
||||
|
||||
const [internalValue, setInternalValue] = useState(linkedinUrl ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
setInternalValue(linkedinUrl ?? '');
|
||||
}, [linkedinUrl]);
|
||||
|
||||
return (
|
||||
<EditableCellURL
|
||||
url={internalValue}
|
||||
onChange={setInternalValue}
|
||||
onSubmit={() =>
|
||||
updatePerson({
|
||||
variables: {
|
||||
where: {
|
||||
id: currentRowEntityId,
|
||||
},
|
||||
data: {
|
||||
linkedinUrl: internalValue,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
onCancel={() => setInternalValue(linkedinUrl ?? '')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
import {
|
||||
IconBrandLinkedin,
|
||||
IconBriefcase,
|
||||
IconBuildingSkyscraper,
|
||||
IconCalendarEvent,
|
||||
IconMail,
|
||||
@ -12,6 +14,8 @@ import { EditablePeopleCompanyCell } from './EditablePeopleCompanyCell';
|
||||
import { EditablePeopleCreatedAtCell } from './EditablePeopleCreatedAtCell';
|
||||
import { EditablePeopleEmailCell } from './EditablePeopleEmailCell';
|
||||
import { EditablePeopleFullNameCell } from './EditablePeopleFullNameCell';
|
||||
import { EditablePeopleJobTitleCell } from './EditablePeopleJobTitleCell';
|
||||
import { EditablePeopleLinkedinUrlCell } from './EditablePeopleLinkedinUrlCell';
|
||||
import { EditablePeoplePhoneCell } from './EditablePeoplePhoneCell';
|
||||
|
||||
export type TableColumn = {
|
||||
@ -65,4 +69,18 @@ export const peopleColumns: TableColumn[] = [
|
||||
size: 150,
|
||||
cellComponent: <EditablePeopleCityCell />,
|
||||
},
|
||||
{
|
||||
id: 'jobTitle',
|
||||
title: 'Job title',
|
||||
icon: <IconBriefcase size={16} />,
|
||||
size: 150,
|
||||
cellComponent: <EditablePeopleJobTitleCell />,
|
||||
},
|
||||
{
|
||||
id: 'linkedinUrl',
|
||||
title: 'Linkedin',
|
||||
icon: <IconBrandLinkedin size={16} />,
|
||||
size: 150,
|
||||
cellComponent: <EditablePeopleLinkedinUrlCell />,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user