Clean and re-organize post table refactoring (#1000)
* Clean and re-organize post table refactoring * Fix tests
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
import { formatToHumanReadableDate } from '~/utils';
|
||||
|
||||
type OwnProps = {
|
||||
value: Date | string | null;
|
||||
};
|
||||
|
||||
export function InplaceInputDateDisplayMode({ value }: OwnProps) {
|
||||
return <div>{value && formatToHumanReadableDate(value)}</div>;
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
import { MouseEvent } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { isValidPhoneNumber, parsePhoneNumber } from 'libphonenumber-js';
|
||||
|
||||
import { RawLink } from '@/ui/link/components/RawLink';
|
||||
|
||||
const StyledRawLink = styled(RawLink)`
|
||||
overflow: hidden;
|
||||
|
||||
a {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
`;
|
||||
|
||||
type OwnProps = {
|
||||
value: string | null;
|
||||
};
|
||||
|
||||
export function InplaceInputPhoneDisplayMode({ value }: OwnProps) {
|
||||
return value && isValidPhoneNumber(value) ? (
|
||||
<StyledRawLink
|
||||
href={parsePhoneNumber(value, 'FR')?.getURI()}
|
||||
onClick={(event: MouseEvent<HTMLElement>) => {
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
{parsePhoneNumber(value, 'FR')?.formatInternational() || value}
|
||||
</StyledRawLink>
|
||||
) : (
|
||||
<StyledRawLink href="#">{value}</StyledRawLink>
|
||||
);
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
export const InplaceInputTextDisplayMode = styled.div`
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
`;
|
||||
@ -1,36 +0,0 @@
|
||||
import { MouseEvent } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { RawLink } from '@/ui/link/components/RawLink';
|
||||
|
||||
const StyledRawLink = styled(RawLink)`
|
||||
overflow: hidden;
|
||||
|
||||
a {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
`;
|
||||
|
||||
type OwnProps = {
|
||||
value: string;
|
||||
};
|
||||
|
||||
export function InplaceInputURLDisplayMode({ value }: OwnProps) {
|
||||
function handleClick(event: MouseEvent<HTMLElement>) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
const absoluteUrl = value
|
||||
? value.startsWith('http')
|
||||
? value
|
||||
: 'https://' + value
|
||||
: '';
|
||||
|
||||
return (
|
||||
<StyledRawLink href={absoluteUrl} onClick={handleClick}>
|
||||
{value}
|
||||
</StyledRawLink>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user