Update company logo fetch api (#161)
This commit is contained in:
@ -26,11 +26,9 @@ const StyledInplaceInput = styled.input`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledInplaceShow = styled.div`
|
const StyledInplaceShow = styled.div`
|
||||||
width: 100%;
|
display: flex;
|
||||||
border: none;
|
padding-left: ${(props) => props.theme.spacing(1)};
|
||||||
outline: none;
|
padding-right: ${(props) => props.theme.spacing(1)};
|
||||||
padding-left: ${(props) => props.theme.spacing(2)};
|
|
||||||
padding-right: ${(props) => props.theme.spacing(2)};
|
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
font-weight: 'bold';
|
font-weight: 'bold';
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import { SearchConfigType } from '../../interfaces/search/interface';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { PeopleCompanyCreateCell } from './PeopleCompanyCreateCell';
|
import { PeopleCompanyCreateCell } from './PeopleCompanyCreateCell';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
import { getLogoUrlFromDomainName } from '../../services/utils';
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
people: Person;
|
people: Person;
|
||||||
@ -79,7 +80,7 @@ export function PeopleCompanyCell({ people }: OwnProps) {
|
|||||||
chipComponentPropsMapper={(company): CompanyChipPropsType => {
|
chipComponentPropsMapper={(company): CompanyChipPropsType => {
|
||||||
return {
|
return {
|
||||||
name: company.name || '',
|
name: company.name || '',
|
||||||
picture: `https://www.google.com/s2/favicons?domain=${company.domainName}&sz=256`,
|
picture: getLogoUrlFromDomainName(company.domainName),
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
onChange={async (relation) => {
|
onChange={async (relation) => {
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import {
|
|||||||
TbUser,
|
TbUser,
|
||||||
} from 'react-icons/tb';
|
} from 'react-icons/tb';
|
||||||
import { QueryMode } from '../../generated/graphql';
|
import { QueryMode } from '../../generated/graphql';
|
||||||
|
import { getLogoUrlFromDomainName } from '../../services/utils';
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<Company>();
|
const columnHelper = createColumnHelper<Company>();
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ export const useCompaniesColumns = () => {
|
|||||||
<EditableChip
|
<EditableChip
|
||||||
value={props.row.original.name || ''}
|
value={props.row.original.name || ''}
|
||||||
placeholder="Name"
|
placeholder="Name"
|
||||||
picture={`https://www.google.com/s2/favicons?domain=${props.row.original.domainName}&sz=256`}
|
picture={getLogoUrlFromDomainName(props.row.original.domainName)}
|
||||||
changeHandler={(value: string) => {
|
changeHandler={(value: string) => {
|
||||||
const company = props.row.original;
|
const company = props.row.original;
|
||||||
company.name = value;
|
company.name = value;
|
||||||
|
|||||||
21
front/src/services/__tests__/utils.test.ts
Normal file
21
front/src/services/__tests__/utils.test.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { getLogoUrlFromDomainName } from '../utils';
|
||||||
|
|
||||||
|
describe('getLogoUrlFromDomainName', () => {
|
||||||
|
it(`should generate logo url if undefined `, () => {
|
||||||
|
expect(getLogoUrlFromDomainName(undefined)).toBe(
|
||||||
|
'https://api.faviconkit.com/undefined/144',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should generate logo url if defined `, () => {
|
||||||
|
expect(getLogoUrlFromDomainName('test.com')).toBe(
|
||||||
|
'https://api.faviconkit.com/test.com/144',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should generate logo url if empty `, () => {
|
||||||
|
expect(getLogoUrlFromDomainName('')).toBe(
|
||||||
|
'https://api.faviconkit.com//144',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -5,3 +5,7 @@ export const humanReadableDate = (date: Date) => {
|
|||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
}).format(date);
|
}).format(date);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getLogoUrlFromDomainName = (domainName?: string): string => {
|
||||||
|
return `https://api.faviconkit.com/${domainName}/144`;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user