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:
@ -38,13 +38,13 @@ const StyledInputContainer = styled.div`
|
||||
|
||||
const defaultUsername = { firstName: '', lastName: '' };
|
||||
|
||||
export function AddPersonToCompany({
|
||||
export const AddPersonToCompany = ({
|
||||
companyId,
|
||||
peopleIds,
|
||||
}: {
|
||||
companyId: string;
|
||||
peopleIds?: string[];
|
||||
}) {
|
||||
}) => {
|
||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||
const [isCreationDropdownOpen, setIsCreationDropdownOpen] = useState(false);
|
||||
const [username, setUsername] = useState(defaultUsername);
|
||||
@ -60,8 +60,8 @@ export function AddPersonToCompany({
|
||||
goBackToPreviousHotkeyScope,
|
||||
} = usePreviousHotkeyScope();
|
||||
|
||||
function handlePersonSelected(companyId: string) {
|
||||
return async (newPerson: PersonForSelect | null) => {
|
||||
const handlePersonSelected =
|
||||
(companyId: string) => async (newPerson: PersonForSelect | null) => {
|
||||
if (newPerson) {
|
||||
await updatePerson({
|
||||
variables: {
|
||||
@ -77,30 +77,31 @@ export function AddPersonToCompany({
|
||||
handleClosePicker();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function handleClosePicker() {
|
||||
const handleClosePicker = () => {
|
||||
if (isDropdownOpen) {
|
||||
setIsDropdownOpen(false);
|
||||
goBackToPreviousHotkeyScope();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleOpenPicker() {
|
||||
const handleOpenPicker = () => {
|
||||
if (!isDropdownOpen) {
|
||||
setIsDropdownOpen(true);
|
||||
setHotkeyScopeAndMemorizePreviousScope(
|
||||
RelationPickerHotkeyScope.RelationPicker,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleUsernameChange(type: 'firstName' | 'lastName') {
|
||||
return (name: string): void =>
|
||||
const handleUsernameChange =
|
||||
(type: 'firstName' | 'lastName') =>
|
||||
(name: string): void =>
|
||||
setUsername((prevUserName) => ({ ...prevUserName, [type]: name }));
|
||||
}
|
||||
|
||||
async function handleInputKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
|
||||
const handleInputKeyDown = async (
|
||||
e: React.KeyboardEvent<HTMLInputElement>,
|
||||
) => {
|
||||
if (e.key !== 'Enter' || (!username.firstName && !username.lastName))
|
||||
return;
|
||||
const newPersonId = v4();
|
||||
@ -116,7 +117,7 @@ export function AddPersonToCompany({
|
||||
});
|
||||
setIsCreationDropdownOpen(false);
|
||||
setUsername(defaultUsername);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<RecoilScope>
|
||||
@ -161,4 +162,4 @@ export function AddPersonToCompany({
|
||||
</StyledContainer>
|
||||
</RecoilScope>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -100,7 +100,7 @@ const StyledFieldContainer = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export function CompanyBoardCard() {
|
||||
export const CompanyBoardCard = () => {
|
||||
const { BoardRecoilScopeContext } = useBoardContext();
|
||||
|
||||
const { currentCardSelected, setCurrentCardSelected } =
|
||||
@ -122,21 +122,19 @@ export function CompanyBoardCard() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function PreventSelectOnClickContainer({
|
||||
const PreventSelectOnClickContainer = ({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<StyledFieldContainer
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</StyledFieldContainer>
|
||||
);
|
||||
}
|
||||
}) => (
|
||||
<StyledFieldContainer
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</StyledFieldContainer>
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledBoardCardWrapper>
|
||||
@ -185,4 +183,4 @@ export function CompanyBoardCard() {
|
||||
</StyledBoardCard>
|
||||
</StyledBoardCardWrapper>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,20 +7,18 @@ type OwnProps = {
|
||||
variant?: EntityChipVariant;
|
||||
};
|
||||
|
||||
export function CompanyChip({
|
||||
export const CompanyChip = ({
|
||||
id,
|
||||
name,
|
||||
pictureUrl,
|
||||
variant = EntityChipVariant.Regular,
|
||||
}: OwnProps) {
|
||||
return (
|
||||
<EntityChip
|
||||
entityId={id}
|
||||
linkToEntity={`/companies/${id}`}
|
||||
name={name}
|
||||
avatarType="squared"
|
||||
pictureUrl={pictureUrl}
|
||||
variant={variant}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}: OwnProps) => (
|
||||
<EntityChip
|
||||
entityId={id}
|
||||
linkToEntity={`/companies/${id}`}
|
||||
name={name}
|
||||
avatarType="squared"
|
||||
pictureUrl={pictureUrl}
|
||||
variant={variant}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -13,7 +13,7 @@ export type OwnProps = {
|
||||
onCancel?: () => void;
|
||||
};
|
||||
|
||||
export function CompanyPicker({ companyId, onSubmit, onCancel }: OwnProps) {
|
||||
export const CompanyPicker = ({ companyId, onSubmit, onCancel }: OwnProps) => {
|
||||
const [relationPickerSearchFilter, setRelationPickerSearchFilter] =
|
||||
useRecoilScopedState(relationPickerSearchFilterScopedState);
|
||||
|
||||
@ -22,11 +22,11 @@ export function CompanyPicker({ companyId, onSubmit, onCancel }: OwnProps) {
|
||||
selectedIds: companyId ? [companyId] : [],
|
||||
});
|
||||
|
||||
async function handleEntitySelected(
|
||||
const handleEntitySelected = async (
|
||||
selectedCompany: EntityForSelect | null | undefined,
|
||||
) {
|
||||
) => {
|
||||
onSubmit(selectedCompany ?? null);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setRelationPickerSearchFilter('');
|
||||
@ -41,4 +41,4 @@ export function CompanyPicker({ companyId, onSubmit, onCancel }: OwnProps) {
|
||||
selectedEntity={companies.selectedEntities[0]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -23,13 +23,13 @@ export type CompanyPickerSelectedCompany = EntityForSelect & {
|
||||
domainName: string;
|
||||
};
|
||||
|
||||
export function CompanyPickerCell({
|
||||
export const CompanyPickerCell = ({
|
||||
companyId,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
createModeEnabled,
|
||||
width,
|
||||
}: OwnProps) {
|
||||
}: OwnProps) => {
|
||||
const [isCreateMode, setIsCreateMode] = useRecoilScopedState(
|
||||
isCreateModeScopedState,
|
||||
);
|
||||
@ -47,18 +47,18 @@ export function CompanyPickerCell({
|
||||
selectedIds: [companyId ?? ''],
|
||||
});
|
||||
|
||||
async function handleCompanySelected(
|
||||
const handleCompanySelected = async (
|
||||
company: CompanyPickerSelectedCompany | null | undefined,
|
||||
) {
|
||||
) => {
|
||||
onSubmit(company ?? null);
|
||||
}
|
||||
};
|
||||
|
||||
function handleStartCreation() {
|
||||
const handleStartCreation = () => {
|
||||
setIsCreateMode(true);
|
||||
setHotkeyScope(TableHotkeyScope.CellDoubleTextInput);
|
||||
}
|
||||
};
|
||||
|
||||
async function handleCreate(firstValue: string, secondValue: string) {
|
||||
const handleCreate = async (firstValue: string, secondValue: string) => {
|
||||
const insertCompanyRequest = await insertCompany({
|
||||
variables: {
|
||||
data: {
|
||||
@ -77,7 +77,7 @@ export function CompanyPickerCell({
|
||||
domainName: companyCreated.domainName,
|
||||
});
|
||||
setIsCreateMode(false);
|
||||
}
|
||||
};
|
||||
return isCreateMode ? (
|
||||
<DoubleTextCellEdit
|
||||
firstValue={relationPickerSearchFilter}
|
||||
@ -99,4 +99,4 @@ export function CompanyPickerCell({
|
||||
width={width}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -25,11 +25,11 @@ export type OwnProps = {
|
||||
onCancel?: () => void;
|
||||
};
|
||||
|
||||
export function CompanyProgressPicker({
|
||||
export const CompanyProgressPicker = ({
|
||||
companyId,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
}: OwnProps) {
|
||||
}: OwnProps) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const { searchFilter, handleSearchFilterChange } = useEntitySelectSearch();
|
||||
@ -53,16 +53,16 @@ export function CompanyProgressPicker({
|
||||
[currentPipeline],
|
||||
);
|
||||
|
||||
function handlePipelineStageChange(newPipelineStageId: string) {
|
||||
const handlePipelineStageChange = (newPipelineStageId: string) => {
|
||||
setSelectedPipelineStageId(newPipelineStageId);
|
||||
setIsProgressSelectionUnfolded(false);
|
||||
}
|
||||
};
|
||||
|
||||
async function handleEntitySelected(
|
||||
const handleEntitySelected = async (
|
||||
selectedCompany: EntityForSelect | null | undefined,
|
||||
) {
|
||||
) => {
|
||||
onSubmit(selectedCompany ?? null, selectedPipelineStageId);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (currentPipelineStages?.[0]?.id) {
|
||||
@ -125,4 +125,4 @@ export function CompanyProgressPicker({
|
||||
)}
|
||||
</StyledDropdownMenu>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -42,7 +42,7 @@ const StyledTitle = styled.div`
|
||||
line-height: ${({ theme }) => theme.text.lineHeight.lg};
|
||||
`;
|
||||
|
||||
export function CompanyTeam({ company }: CompanyTeamPropsType) {
|
||||
export const CompanyTeam = ({ company }: CompanyTeamPropsType) => {
|
||||
const { data } = useGetPeopleQuery({
|
||||
variables: {
|
||||
orderBy: [],
|
||||
@ -77,4 +77,4 @@ export function CompanyTeam({ company }: CompanyTeamPropsType) {
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@ import { filterDropdownSelectedEntityIdScopedState } from '@/ui/view-bar/states/
|
||||
|
||||
import { useFilteredSearchCompanyQuery } from '../hooks/useFilteredSearchCompanyQuery';
|
||||
|
||||
export function FilterDropdownCompanySearchSelect() {
|
||||
export const FilterDropdownCompanySearchSelect = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const filterDropdownSearchInput = useRecoilScopedValue(
|
||||
@ -30,4 +30,4 @@ export function FilterDropdownCompanySearchSelect() {
|
||||
return (
|
||||
<FilterDropdownEntitySearchSelect entitiesForSelect={usersForSelect} />
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -24,7 +24,7 @@ import { useUpdateCompanyBoardCardIds } from '../hooks/useUpdateBoardCardIds';
|
||||
import { useUpdateCompanyBoard } from '../hooks/useUpdateCompanyBoardColumns';
|
||||
import { CompanyBoardRecoilScopeContext } from '../states/recoil-scope-contexts/CompanyBoardRecoilScopeContext';
|
||||
|
||||
export function HooksCompanyBoardEffect() {
|
||||
export const HooksCompanyBoardEffect = () => {
|
||||
const [, setAvailableFilters] = useRecoilScopedState(
|
||||
availableFiltersScopedState,
|
||||
CompanyBoardRecoilScopeContext,
|
||||
@ -134,4 +134,4 @@ export function HooksCompanyBoardEffect() {
|
||||
]);
|
||||
|
||||
return <></>;
|
||||
}
|
||||
};
|
||||
|
||||
@ -12,7 +12,7 @@ import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoi
|
||||
import { useCreateCompanyProgress } from '../hooks/useCreateCompanyProgress';
|
||||
import { useFilteredSearchCompanyQuery } from '../hooks/useFilteredSearchCompanyQuery';
|
||||
|
||||
export function NewCompanyProgressButton() {
|
||||
export const NewCompanyProgressButton = () => {
|
||||
const [isCreatingCard, setIsCreatingCard] = useState(false);
|
||||
const pipelineStageId = useContext(BoardColumnIdContext);
|
||||
|
||||
@ -25,7 +25,7 @@ export function NewCompanyProgressButton() {
|
||||
|
||||
const createCompanyProgress = useCreateCompanyProgress();
|
||||
|
||||
function handleEntitySelect(company: any) {
|
||||
const handleEntitySelect = (company: any) => {
|
||||
setIsCreatingCard(false);
|
||||
goBackToPreviousHotkeyScope();
|
||||
|
||||
@ -38,7 +38,7 @@ export function NewCompanyProgressButton() {
|
||||
}
|
||||
|
||||
createCompanyProgress(company.id, pipelineStageId);
|
||||
}
|
||||
};
|
||||
|
||||
const handleNewClick = useCallback(() => {
|
||||
setIsCreatingCard(true);
|
||||
@ -47,10 +47,10 @@ export function NewCompanyProgressButton() {
|
||||
);
|
||||
}, [setIsCreatingCard, setHotkeyScopeAndMemorizePreviousScope]);
|
||||
|
||||
function handleCancel() {
|
||||
const handleCancel = () => {
|
||||
goBackToPreviousHotkeyScope();
|
||||
setIsCreatingCard(false);
|
||||
}
|
||||
};
|
||||
|
||||
const [relationPickerSearchFilter] = useRecoilScopedState(
|
||||
relationPickerSearchFilterScopedState,
|
||||
@ -76,4 +76,4 @@ export function NewCompanyProgressButton() {
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user