1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00
vault-frontend/src/components/boris/BorisStatsGitCard/index.tsx
2021-03-10 14:47:04 +07:00

35 lines
943 B
TypeScript

import React, { FC, useMemo } from 'react';
import styles from './styles.module.scss';
import { getPrettyDate } from '~/utils/dom';
import { IGithubIssue } from '~/redux/boris/types';
import classNames from 'classnames';
interface IProps {
data: IGithubIssue;
}
const stateLabels: Record<IGithubIssue['state'], string> = {
open: 'Ожидает',
closed: 'Сделано',
};
const BorisStatsGitCard: FC<IProps> = ({ data: { created_at, title, html_url, state } }) => {
if (!title || !created_at) return null;
const date = useMemo(() => getPrettyDate(created_at), [created_at]);
return (
<div className={styles.wrap}>
<div className={styles.time}>
<span className={classNames(styles.icon, styles[state])}>{stateLabels[state]}</span>
{date}
</div>
<a className={styles.subject} href={html_url} target="_blank">
{title}
</a>
</div>
);
};
export { BorisStatsGitCard };