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:
gitstart-twenty
2023-09-16 02:41:10 +01:00
committed by GitHub
parent 549335054a
commit 00a3c8ca2b
575 changed files with 2848 additions and 3063 deletions

View File

@ -4,6 +4,6 @@ type OwnProps = {
value: Date | string | null | undefined;
};
export function DateDisplay({ value }: OwnProps) {
return <div>{value && formatToHumanReadableDate(value)}</div>;
}
export const DateDisplay = ({ value }: OwnProps) => (
<div>{value && formatToHumanReadableDate(value)}</div>
);

View File

@ -2,17 +2,17 @@ import { MouseEvent } from 'react';
import { ContactLink } from '@/ui/link/components/ContactLink';
function validateEmail(email: string) {
const validateEmail = (email: string) => {
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailPattern.test(email.trim());
}
};
type OwnProps = {
value: string | null;
};
export function EmailDisplay({ value }: OwnProps) {
return value && validateEmail(value) ? (
export const EmailDisplay = ({ value }: OwnProps) =>
value && validateEmail(value) ? (
<ContactLink
href={`mailto:${value}`}
onClick={(event: MouseEvent<HTMLElement>) => {
@ -24,4 +24,3 @@ export function EmailDisplay({ value }: OwnProps) {
) : (
<ContactLink href="#">{value}</ContactLink>
);
}

View File

@ -13,10 +13,8 @@ type OwnProps = {
value: number | null;
};
export function MoneyDisplay({ value }: OwnProps) {
return (
<StyledTextInputDisplay>
{value ? `$${formatNumber(value)}` : ''}
</StyledTextInputDisplay>
);
}
export const MoneyDisplay = ({ value }: OwnProps) => (
<StyledTextInputDisplay>
{value ? `$${formatNumber(value)}` : ''}
</StyledTextInputDisplay>
);

View File

@ -13,10 +13,8 @@ type OwnProps = {
value: string;
};
export function NumberDisplay({ value }: OwnProps) {
return (
<StyledNumberDisplay>
{value && formatNumber(Number(value))}
</StyledNumberDisplay>
);
}
export const NumberDisplay = ({ value }: OwnProps) => (
<StyledNumberDisplay>
{value && formatNumber(Number(value))}
</StyledNumberDisplay>
);

View File

@ -7,8 +7,8 @@ type OwnProps = {
value: string | null;
};
export function PhoneDisplay({ value }: OwnProps) {
return value && isValidPhoneNumber(value) ? (
export const PhoneDisplay = ({ value }: OwnProps) =>
value && isValidPhoneNumber(value) ? (
<ContactLink
href={parsePhoneNumber(value, 'FR')?.getURI()}
onClick={(event: MouseEvent<HTMLElement>) => {
@ -20,4 +20,3 @@ export function PhoneDisplay({ value }: OwnProps) {
) : (
<ContactLink href="#">{value}</ContactLink>
);
}

View File

@ -11,6 +11,6 @@ type OwnProps = {
text: string;
};
export function TextDisplay({ text }: OwnProps) {
return <StyledTextInputDisplay>{text}</StyledTextInputDisplay>;
}
export const TextDisplay = ({ text }: OwnProps) => (
<StyledTextInputDisplay>{text}</StyledTextInputDisplay>
);

View File

@ -33,10 +33,10 @@ const checkUrlType = (url: string) => {
return LinkType.Url;
};
export function URLDisplay({ value }: OwnProps) {
function handleClick(event: MouseEvent<HTMLElement>) {
export const URLDisplay = ({ value }: OwnProps) => {
const handleClick = (event: MouseEvent<HTMLElement>) => {
event.stopPropagation();
}
};
const absoluteUrl = value
? value.startsWith('http')
? value
@ -57,4 +57,4 @@ export function URLDisplay({ value }: OwnProps) {
{value}
</StyledRawLink>
);
}
};