Reorganize frontend and install Craco to alias modules (#190)
This commit is contained in:
21
front/src/modules/utils/__tests__/utils.test.ts
Normal file
21
front/src/modules/utils/__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',
|
||||
);
|
||||
});
|
||||
});
|
||||
37
front/src/modules/utils/interfaces/generic.interface.ts
Normal file
37
front/src/modules/utils/interfaces/generic.interface.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import {
|
||||
Company,
|
||||
GraphqlQueryCompany,
|
||||
} from '@/companies/interfaces/company.interface';
|
||||
import {
|
||||
GraphqlQueryPerson,
|
||||
Person,
|
||||
} from '@/people/interfaces/person.interface';
|
||||
import { GraphqlQueryUser, User } from '@/users/interfaces/user.interface';
|
||||
import {
|
||||
CompanyWhereInput as Companies_Bool_Exp,
|
||||
PersonWhereInput as People_Bool_Exp,
|
||||
UserWhereInput as Users_Bool_Exp,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export type AnyEntity = {
|
||||
id: string;
|
||||
__typename: string;
|
||||
} & Record<string, any>;
|
||||
|
||||
export type UnknownType = void;
|
||||
|
||||
export type GqlType<T> = T extends Company
|
||||
? GraphqlQueryCompany
|
||||
: T extends Person
|
||||
? GraphqlQueryPerson
|
||||
: T extends User
|
||||
? GraphqlQueryUser
|
||||
: never;
|
||||
|
||||
export type BoolExpType<T> = T extends Company
|
||||
? Companies_Bool_Exp
|
||||
: T extends Person
|
||||
? People_Bool_Exp
|
||||
: T extends User
|
||||
? Users_Bool_Exp
|
||||
: never;
|
||||
11
front/src/modules/utils/utils.ts
Normal file
11
front/src/modules/utils/utils.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export const humanReadableDate = (date: Date) => {
|
||||
return new Intl.DateTimeFormat(undefined, {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
}).format(date);
|
||||
};
|
||||
|
||||
export const getLogoUrlFromDomainName = (domainName?: string): string => {
|
||||
return `https://api.faviconkit.com/${domainName}/144`;
|
||||
};
|
||||
Reference in New Issue
Block a user