(
+ genericEntityFieldFamilySelector({
+ entityId: currentEditableFieldEntityId ?? '',
+ fieldName: currentEditableFieldDefinition
+ ? currentEditableFieldDefinition.metadata.fieldName
+ : '',
+ }),
+ );
+
+ const [internalValue, setInternalValue] = useState(fieldValue);
+
+ const updateField = useUpdateGenericEntityField();
+
+ const wrapperRef = useRef(null);
+
+ useRegisterCloseFieldHandlers(wrapperRef, handleSubmit, onCancel);
+
+ function handleSubmit() {
+ if (internalValue === fieldValue) return;
+
+ setFieldValue(internalValue);
+
+ if (currentEditableFieldEntityId && updateField) {
+ updateField(
+ currentEditableFieldEntityId,
+ currentEditableFieldDefinition,
+ internalValue,
+ );
+ }
+ }
+
+ function onCancel() {
+ setFieldValue(fieldValue);
+ }
+
+ function handleChange(newValue: string) {
+ setInternalValue(newValue);
+ }
+
+ return (
+
+ {
+ handleChange(newValue);
+ }}
+ />
+
+ );
+}
diff --git a/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldDisplayMode.tsx b/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldDisplayMode.tsx
index 990a106247..d369ed8389 100644
--- a/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldDisplayMode.tsx
+++ b/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldDisplayMode.tsx
@@ -1,9 +1,11 @@
import { useContext } from 'react';
import { useRecoilValue } from 'recoil';
+import { CompanyChip } from '@/companies/components/CompanyChip';
import { PersonChip } from '@/people/components/PersonChip';
import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
import { UserChip } from '@/users/components/UserChip';
+import { getLogoUrlFromDomainName } from '~/utils';
import { EditableFieldDefinitionContext } from '../states/EditableFieldDefinitionContext';
import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext';
@@ -45,6 +47,19 @@ export function GenericEditableRelationFieldDisplayMode() {
/>
);
}
+ case Entity.Company: {
+ return (
+
+ );
+ }
default:
console.warn(
`Unknown relation type: "${currentEditableFieldDefinition.metadata.relationType}"
diff --git a/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx b/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx
index 18d9d2ab97..dc3650e5dd 100644
--- a/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx
+++ b/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx
@@ -2,6 +2,7 @@ import { useContext } from 'react';
import styled from '@emotion/styled';
import { useRecoilState } from 'recoil';
+import { CompanyPicker } from '@/companies/components/CompanyPicker';
import { PeoplePicker } from '@/people/components/PeoplePicker';
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
@@ -54,6 +55,15 @@ function RelationPicker({
/>
);
}
+ case Entity.Company: {
+ return (
+
+ );
+ }
default:
console.warn(
`Unknown relation type: "${fieldDefinition.metadata.relationType}" in GenericEditableRelationField`,
diff --git a/front/src/pages/companies/CompanyShow.tsx b/front/src/pages/companies/CompanyShow.tsx
index b914e9a1e6..b20826e35f 100644
--- a/front/src/pages/companies/CompanyShow.tsx
+++ b/front/src/pages/companies/CompanyShow.tsx
@@ -24,7 +24,7 @@ import { getLogoUrlFromDomainName } from '~/utils';
import { CompanyNameEditableField } from '../../modules/companies/editable-field/components/CompanyNameEditableField';
import { ShowPageContainer } from '../../modules/ui/layout/components/ShowPageContainer';
-import { companyShowFieldsDefinition } from './constants/companyShowFieldsDefinition';
+import { companyShowFieldDefinition } from './constants/companyShowFieldDefinition';
export function CompanyShow() {
const companyId = useParams().companyId ?? '';
@@ -33,11 +33,12 @@ export function CompanyShow() {
const theme = useTheme();
const { data } = useCompanyQuery(companyId);
const company = data?.findUniqueCompany;
- const isFavorite =
- company?.Favorite && company?.Favorite?.length > 0 ? true : false;
if (!company) return <>>;
+ const isFavorite =
+ company.Favorite && company.Favorite?.length > 0 ? true : false;
+
async function handleFavoriteButtonClick() {
if (isFavorite) deleteCompanyFavorite(companyId);
else insertCompanyFavorite(companyId);
@@ -45,7 +46,7 @@ export function CompanyShow() {
return (
}
@@ -54,10 +55,10 @@ export function CompanyShow() {
(
)}
@@ -67,7 +68,7 @@ export function CompanyShow() {
value={useUpdateOneCompanyMutation}
>
- {companyShowFieldsDefinition.map((fieldDefinition) => {
+ {companyShowFieldDefinition.map((fieldDefinition) => {
return (
diff --git a/front/src/pages/companies/constants/companyShowFieldsDefinition.tsx b/front/src/pages/companies/constants/companyShowFieldDefinition.tsx
similarity index 95%
rename from front/src/pages/companies/constants/companyShowFieldsDefinition.tsx
rename to front/src/pages/companies/constants/companyShowFieldDefinition.tsx
index a834b4237e..dc9cd4b477 100644
--- a/front/src/pages/companies/constants/companyShowFieldsDefinition.tsx
+++ b/front/src/pages/companies/constants/companyShowFieldDefinition.tsx
@@ -16,7 +16,7 @@ import {
} from '@/ui/icon';
import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
-export const companyShowFieldsDefinition: FieldDefinition[] = [
+export const companyShowFieldDefinition: FieldDefinition[] = [
{
id: 'domainName',
label: 'Domain name',
diff --git a/front/src/pages/people/PersonShow.tsx b/front/src/pages/people/PersonShow.tsx
index c78029cb28..9eebe92c2d 100644
--- a/front/src/pages/people/PersonShow.tsx
+++ b/front/src/pages/people/PersonShow.tsx
@@ -4,8 +4,12 @@ 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 { GenericEditableField } from '@/ui/editable-field/components/GenericEditableField';
+import { PropertyBox } from '@/ui/editable-field/property-box/components/PropertyBox';
+import { EditableFieldDefinitionContext } from '@/ui/editable-field/states/EditableFieldDefinitionContext';
+import { EditableFieldEntityIdContext } from '@/ui/editable-field/states/EditableFieldEntityIdContext';
+import { EditableFieldMutationContext } from '@/ui/editable-field/states/EditableFieldMutationContext';
import { IconUser } from '@/ui/icon';
import { WithTopBarContainer } from '@/ui/layout/components/WithTopBarContainer';
import { ShowPageLeftContainer } from '@/ui/layout/show-page/components/ShowPageLeftContainer';
@@ -13,25 +17,30 @@ import { ShowPageRightContainer } from '@/ui/layout/show-page/components/ShowPag
import { ShowPageSummaryCard } from '@/ui/layout/show-page/components/ShowPageSummaryCard';
import {
CommentableType,
+ useUpdateOnePersonMutation,
useUploadPersonPictureMutation,
} from '~/generated/graphql';
import { PeopleFullNameEditableField } from '../../modules/people/editable-field/components/PeopleFullNameEditableField';
import { ShowPageContainer } from '../../modules/ui/layout/components/ShowPageContainer';
+import { personShowFieldDefinition } from './constants/personShowFieldDefinition';
+
export function PersonShow() {
const personId = useParams().personId ?? '';
-
const { insertPersonFavorite, deletePersonFavorite } = useFavorites();
+ const theme = useTheme();
const { data } = usePersonQuery(personId);
const person = data?.findUniquePerson;
- const isFavorite =
- person?.Favorite && person?.Favorite?.length > 0 ? true : false;
- const theme = useTheme();
const [uploadPicture] = useUploadPersonPictureMutation();
+ if (!person) return <>>;
+
+ const isFavorite =
+ person.Favorite && person.Favorite?.length > 0 ? true : false;
+
async function onUploadPicture(file: File) {
if (!file || !person?.id) {
return;
@@ -39,7 +48,7 @@ export function PersonShow() {
await uploadPicture({
variables: {
file,
- id: person?.id,
+ id: person.id,
},
refetchQueries: [getOperationName(GET_PERSON) ?? ''],
});
@@ -52,7 +61,7 @@ export function PersonShow() {
return (
}
hasBackButton
isFavorite={isFavorite}
@@ -61,20 +70,37 @@ export function PersonShow() {
person ? : <>>
}
onUploadPicture={onUploadPicture}
/>
- {person && }
+
+
+
+ {personShowFieldDefinition.map((fieldDefinition) => {
+ return (
+
+
+
+ );
+ })}
+
+
+
diff --git a/front/src/pages/people/constants/personShowFieldDefinition.tsx b/front/src/pages/people/constants/personShowFieldDefinition.tsx
new file mode 100644
index 0000000000..912569323b
--- /dev/null
+++ b/front/src/pages/people/constants/personShowFieldDefinition.tsx
@@ -0,0 +1,69 @@
+import { FieldDefinition } from '@/ui/editable-field/types/FieldDefinition';
+import {
+ FieldDateMetadata,
+ FieldMetadata,
+ FieldPhoneMetadata,
+ FieldRelationMetadata,
+ FieldTextMetadata,
+} from '@/ui/editable-field/types/FieldMetadata';
+import {
+ IconBuildingSkyscraper,
+ IconCalendar,
+ IconMail,
+ IconMap,
+ IconPhone,
+} from '@/ui/icon';
+import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
+
+export const personShowFieldDefinition: FieldDefinition[] = [
+ {
+ id: 'email',
+ label: 'Email',
+ icon: ,
+ type: 'text',
+ metadata: {
+ fieldName: 'email',
+ placeHolder: 'Email',
+ },
+ } satisfies FieldDefinition,
+ {
+ id: 'phone',
+ label: 'Phone',
+ icon: ,
+ type: 'phone',
+ metadata: {
+ fieldName: 'phone',
+ placeHolder: 'Phone',
+ },
+ } satisfies FieldDefinition,
+ {
+ id: 'createdAt',
+ label: 'Created at',
+ icon: ,
+ type: 'date',
+ metadata: {
+ fieldName: 'createdAt',
+ },
+ } satisfies FieldDefinition,
+ {
+ id: 'company',
+ label: 'Company',
+ icon: ,
+ type: 'relation',
+ metadata: {
+ fieldName: 'company',
+ relationType: Entity.Company,
+ useEditButton: true,
+ },
+ } satisfies FieldDefinition,
+ {
+ id: 'city',
+ label: 'City',
+ icon: ,
+ type: 'text',
+ metadata: {
+ fieldName: 'city',
+ placeHolder: 'City',
+ },
+ } satisfies FieldDefinition,
+];