Change to using arrow functions (#1603)
* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -6,7 +6,7 @@ import { useViewBarContext } from '@/ui/view-bar/hooks/useViewBarContext';
|
||||
import { filterDropdownSearchInputScopedState } from '@/ui/view-bar/states/filterDropdownSearchInputScopedState';
|
||||
import { filterDropdownSelectedEntityIdScopedState } from '@/ui/view-bar/states/filterDropdownSelectedEntityIdScopedState';
|
||||
|
||||
export function FilterDropdownPeopleSearchSelect() {
|
||||
export const FilterDropdownPeopleSearchSelect = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const filterDropdownSearchInput = useRecoilScopedValue(
|
||||
@ -29,4 +29,4 @@ export function FilterDropdownPeopleSearchSelect() {
|
||||
return (
|
||||
<FilterDropdownEntitySearchSelect entitiesForSelect={peopleForSelect} />
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -71,10 +71,10 @@ const StyledJobTitle = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
export function PeopleCard({
|
||||
export const PeopleCard = ({
|
||||
person,
|
||||
hasBottomBorder = true,
|
||||
}: PeopleCardProps) {
|
||||
}: PeopleCardProps) => {
|
||||
const navigate = useNavigate();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [isOptionsOpen, setIsOptionsOpen] = useState(false);
|
||||
@ -98,22 +98,22 @@ export function PeopleCard({
|
||||
},
|
||||
});
|
||||
|
||||
function handleMouseEnter() {
|
||||
const handleMouseEnter = () => {
|
||||
setIsHovered(true);
|
||||
}
|
||||
};
|
||||
|
||||
function handleMouseLeave() {
|
||||
const handleMouseLeave = () => {
|
||||
if (!isOptionsOpen) {
|
||||
setIsHovered(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleToggleOptions(e: React.MouseEvent<HTMLButtonElement>) {
|
||||
const handleToggleOptions = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.stopPropagation();
|
||||
setIsOptionsOpen(!isOptionsOpen);
|
||||
}
|
||||
};
|
||||
|
||||
function handleDetachPerson() {
|
||||
const handleDetachPerson = () => {
|
||||
updatePerson({
|
||||
variables: {
|
||||
where: {
|
||||
@ -127,16 +127,16 @@ export function PeopleCard({
|
||||
},
|
||||
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function handleDeletePerson() {
|
||||
const handleDeletePerson = () => {
|
||||
deletePerson({
|
||||
variables: {
|
||||
ids: person.id,
|
||||
},
|
||||
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledCard
|
||||
@ -186,4 +186,4 @@ export function PeopleCard({
|
||||
)}
|
||||
</StyledCard>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
|
||||
import { useSetPeopleEntityTable } from '../hooks/useSetPeopleEntityTable';
|
||||
|
||||
export function PeopleEntityTableDataEffect({
|
||||
export const PeopleEntityTableData = ({
|
||||
orderBy = [
|
||||
{
|
||||
createdAt: SortOrder.Desc,
|
||||
@ -16,7 +16,7 @@ export function PeopleEntityTableDataEffect({
|
||||
}: {
|
||||
orderBy?: PersonOrderByWithRelationInput[];
|
||||
whereFilters?: any;
|
||||
}) {
|
||||
}) => {
|
||||
const setPeopleEntityTable = useSetPeopleEntityTable();
|
||||
|
||||
useGetPeopleQuery({
|
||||
@ -29,4 +29,4 @@ export function PeopleEntityTableDataEffect({
|
||||
});
|
||||
|
||||
return <></>;
|
||||
}
|
||||
};
|
||||
|
||||
@ -19,14 +19,14 @@ export type PersonForSelect = EntityForSelect & {
|
||||
entityType: Entity.Person;
|
||||
};
|
||||
|
||||
export function PeoplePicker({
|
||||
export const PeoplePicker = ({
|
||||
personId,
|
||||
companyId,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
onCreate,
|
||||
excludePersonIds,
|
||||
}: OwnProps) {
|
||||
}: OwnProps) => {
|
||||
const [relationPickerSearchFilter] = useRecoilScopedState(
|
||||
relationPickerSearchFilterScopedState,
|
||||
);
|
||||
@ -60,11 +60,11 @@ export function PeoplePicker({
|
||||
excludeEntityIds: excludePersonIds,
|
||||
});
|
||||
|
||||
async function handleEntitySelected(
|
||||
const handleEntitySelected = async (
|
||||
selectedPerson: PersonForSelect | null | undefined,
|
||||
) {
|
||||
) => {
|
||||
onSubmit(selectedPerson ?? null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SingleEntitySelect
|
||||
@ -76,4 +76,4 @@ export function PeoplePicker({
|
||||
selectedEntity={people.selectedEntities[0]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,20 +7,18 @@ export type PersonChipPropsType = {
|
||||
variant?: EntityChipVariant;
|
||||
};
|
||||
|
||||
export function PersonChip({
|
||||
export const PersonChip = ({
|
||||
id,
|
||||
name,
|
||||
pictureUrl,
|
||||
variant,
|
||||
}: PersonChipPropsType) {
|
||||
return (
|
||||
<EntityChip
|
||||
entityId={id}
|
||||
linkToEntity={`/person/${id}`}
|
||||
name={name}
|
||||
avatarType="rounded"
|
||||
pictureUrl={pictureUrl}
|
||||
variant={variant}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}: PersonChipPropsType) => (
|
||||
<EntityChip
|
||||
entityId={id}
|
||||
linkToEntity={`/person/${id}`}
|
||||
name={name}
|
||||
avatarType="rounded"
|
||||
pictureUrl={pictureUrl}
|
||||
variant={variant}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -9,7 +9,7 @@ type OwnProps = {
|
||||
people: Pick<Person, 'id' | 'firstName' | 'lastName'>;
|
||||
};
|
||||
|
||||
export function PeopleFullNameEditableField({ people }: OwnProps) {
|
||||
export const PeopleFullNameEditableField = ({ people }: OwnProps) => {
|
||||
const [internalValueFirstName, setInternalValueFirstName] = useState(
|
||||
people.firstName,
|
||||
);
|
||||
@ -19,19 +19,19 @@ export function PeopleFullNameEditableField({ people }: OwnProps) {
|
||||
|
||||
const [updatePeople] = useUpdateOnePersonMutation();
|
||||
|
||||
async function handleChange(
|
||||
const handleChange = async (
|
||||
newValueFirstName: string,
|
||||
newValueLastName: string,
|
||||
) {
|
||||
) => {
|
||||
setInternalValueFirstName(newValueFirstName);
|
||||
setInternalValueLastName(newValueLastName);
|
||||
handleSubmit(newValueFirstName, newValueLastName);
|
||||
}
|
||||
};
|
||||
|
||||
async function handleSubmit(
|
||||
const handleSubmit = async (
|
||||
newValueFirstName: string,
|
||||
newValueLastName: string,
|
||||
) {
|
||||
) => {
|
||||
await updatePeople({
|
||||
variables: {
|
||||
where: {
|
||||
@ -43,7 +43,7 @@ export function PeopleFullNameEditableField({ people }: OwnProps) {
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<RecoilScope CustomRecoilScopeContext={FieldRecoilScopeContext}>
|
||||
@ -56,4 +56,4 @@ export function PeopleFullNameEditableField({ people }: OwnProps) {
|
||||
/>
|
||||
</RecoilScope>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@ import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTa
|
||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { useSearchPeopleQuery } from '~/generated/graphql';
|
||||
|
||||
export function useFilteredSearchPeopleQuery({
|
||||
export const useFilteredSearchPeopleQuery = ({
|
||||
searchFilter,
|
||||
selectedIds = [],
|
||||
limit,
|
||||
@ -11,8 +11,8 @@ export function useFilteredSearchPeopleQuery({
|
||||
searchFilter: string;
|
||||
selectedIds?: string[];
|
||||
limit?: number;
|
||||
}) {
|
||||
return useFilteredSearchEntityQuery({
|
||||
}) =>
|
||||
useFilteredSearchEntityQuery({
|
||||
queryHook: useSearchPeopleQuery,
|
||||
filters: [
|
||||
{
|
||||
@ -32,4 +32,3 @@ export function useFilteredSearchPeopleQuery({
|
||||
} as ActivityTargetableEntityForSelect),
|
||||
limit,
|
||||
});
|
||||
}
|
||||
|
||||
@ -12,15 +12,15 @@ import { ActivityType, useDeleteManyPersonMutation } from '~/generated/graphql';
|
||||
|
||||
import { GET_PEOPLE } from '../graphql/queries/getPeople';
|
||||
|
||||
export function usePersonTableContextMenuEntries() {
|
||||
export const usePersonTableContextMenuEntries = () => {
|
||||
const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState);
|
||||
|
||||
const openCreateActivityRightDrawer =
|
||||
useOpenCreateActivityDrawerForSelectedRowIds();
|
||||
|
||||
async function handleActivityClick(type: ActivityType) {
|
||||
const handleActivityClick = async (type: ActivityType) => {
|
||||
openCreateActivityRightDrawer(type, ActivityTargetableEntityType.Person);
|
||||
}
|
||||
};
|
||||
|
||||
const selectedRowIds = useRecoilValue(selectedRowIdsSelector);
|
||||
const [tableRowIds, setTableRowIds] = useRecoilState(tableRowIdsState);
|
||||
@ -31,7 +31,7 @@ export function usePersonTableContextMenuEntries() {
|
||||
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
});
|
||||
|
||||
async function handleDeleteClick() {
|
||||
const handleDeleteClick = async () => {
|
||||
const rowIdsToDelete = selectedRowIds;
|
||||
|
||||
resetRowSelection();
|
||||
@ -52,7 +52,7 @@ export function usePersonTableContextMenuEntries() {
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
setContextMenuEntries: () =>
|
||||
@ -75,4 +75,4 @@ export function usePersonTableContextMenuEntries() {
|
||||
},
|
||||
]),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@ import { useSetRecoilState } from 'recoil';
|
||||
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
|
||||
import { useGetPersonQuery } from '~/generated/graphql';
|
||||
|
||||
export function usePersonQuery(id: string) {
|
||||
export const usePersonQuery = (id: string) => {
|
||||
const updatePersonShowPage = useSetRecoilState(
|
||||
genericEntitiesFamilyState(id),
|
||||
);
|
||||
@ -13,4 +13,4 @@ export function usePersonQuery(id: string) {
|
||||
updatePersonShowPage(data?.findUniquePerson);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -12,15 +12,15 @@ import { ActivityType, useDeleteManyPersonMutation } from '~/generated/graphql';
|
||||
|
||||
import { GET_PEOPLE } from '../graphql/queries/getPeople';
|
||||
|
||||
export function usePersonTableActionBarEntries() {
|
||||
export const usePersonTableActionBarEntries = () => {
|
||||
const setActionBarEntries = useSetRecoilState(actionBarEntriesState);
|
||||
|
||||
const openCreateActivityRightDrawer =
|
||||
useOpenCreateActivityDrawerForSelectedRowIds();
|
||||
|
||||
async function handleActivityClick(type: ActivityType) {
|
||||
const handleActivityClick = async (type: ActivityType) => {
|
||||
openCreateActivityRightDrawer(type, ActivityTargetableEntityType.Person);
|
||||
}
|
||||
};
|
||||
|
||||
const selectedRowIds = useRecoilValue(selectedRowIdsSelector);
|
||||
const [tableRowIds, setTableRowIds] = useRecoilState(tableRowIdsState);
|
||||
@ -31,7 +31,7 @@ export function usePersonTableActionBarEntries() {
|
||||
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
});
|
||||
|
||||
async function handleDeleteClick() {
|
||||
const handleDeleteClick = async () => {
|
||||
const rowIdsToDelete = selectedRowIds;
|
||||
|
||||
resetRowSelection();
|
||||
@ -56,7 +56,7 @@ export function usePersonTableActionBarEntries() {
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
setActionBarEntries: () =>
|
||||
@ -79,4 +79,4 @@ export function usePersonTableActionBarEntries() {
|
||||
},
|
||||
]),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -21,7 +21,7 @@ import { peopleLinkedinUrlFamilyState } from '../states/peopleLinkedinUrlFamilyS
|
||||
import { peopleNameCellFamilyState } from '../states/peopleNamesFamilyState';
|
||||
import { peoplePhoneFamilyState } from '../states/peoplePhoneFamilyState';
|
||||
|
||||
export function useSetPeopleEntityTable() {
|
||||
export const useSetPeopleEntityTable = () => {
|
||||
const resetTableRowSelection = useResetTableRowSelection();
|
||||
|
||||
const tableContextScopeId = useRecoilScopeId(TableRecoilScopeContext);
|
||||
@ -134,4 +134,4 @@ export function useSetPeopleEntityTable() {
|
||||
},
|
||||
[currentLocation, resetTableRowSelection, tableContextScopeId],
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ import { fieldsForPerson } from '../utils/fieldsForPerson';
|
||||
|
||||
export type FieldPersonMapping = (typeof fieldsForPerson)[number]['key'];
|
||||
|
||||
export function useSpreadsheetPersonImport() {
|
||||
export const useSpreadsheetPersonImport = () => {
|
||||
const { openSpreadsheetImport } = useSpreadsheetImport<FieldPersonMapping>();
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
@ -23,7 +23,7 @@ export function useSpreadsheetPersonImport() {
|
||||
) => {
|
||||
openSpreadsheetImport({
|
||||
...options,
|
||||
async onSubmit(data) {
|
||||
onSubmit: async (data) => {
|
||||
// TODO: Add better type checking in spreadsheet import later
|
||||
const createInputs = data.validData.map((person) => ({
|
||||
id: uuidv4(),
|
||||
@ -59,4 +59,4 @@ export function useSpreadsheetPersonImport() {
|
||||
};
|
||||
|
||||
return { openPersonSpreadsheetImport };
|
||||
}
|
||||
};
|
||||
|
||||
@ -20,7 +20,7 @@ import {
|
||||
import { peopleFilters } from '~/pages/people/people-filters';
|
||||
import { peopleAvailableSorts } from '~/pages/people/people-sorts';
|
||||
|
||||
export function PeopleTable() {
|
||||
export const PeopleTable = () => {
|
||||
const sortsOrderBy = useRecoilScopedValue(
|
||||
sortsOrderByScopedSelector,
|
||||
TableRecoilScopeContext,
|
||||
@ -43,9 +43,9 @@ export function PeopleTable() {
|
||||
const { setContextMenuEntries } = usePersonTableContextMenuEntries();
|
||||
const { setActionBarEntries } = usePersonTableActionBarEntries();
|
||||
|
||||
function handleImport() {
|
||||
const handleImport = () => {
|
||||
openPersonSpreadsheetImport();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -93,4 +93,4 @@ export function PeopleTable() {
|
||||
</ViewBarContext.Provider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user