Skip to content

Commit 1b0c778

Browse files
committed
feat(repo-explorer): last commit header prop destructured
1 parent 4359319 commit 1b0c778

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/features/repo-explorer/components/entries-view/last-commit-header.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,29 @@ type Props = {
88
lastCommit: GitCommit;
99
};
1010

11-
const LastCommitHeader = ({ lastCommit }: Props) => (
12-
<div className="repo-git-view__last-commit">
13-
<div className="commit-info">
14-
{lastCommit?.avatarUrl ? (
15-
<>
16-
<img src={lastCommit?.avatarUrl} alt="avatar" />
17-
<Link className="author-name" to={`/${lastCommit?.login}`}>
18-
{lastCommit?.login}
11+
const LastCommitHeader = ({ lastCommit }: Props) => {
12+
const { login, name, avatarUrl, message, date } = lastCommit || {};
13+
return (
14+
<div className="repo-git-view__last-commit">
15+
<div className="commit-info">
16+
<img src={avatarUrl ?? logo} alt="avatar" />
17+
{avatarUrl ? (
18+
<Link className="author-name" to={`/${login}`}>
19+
{login}
1920
</Link>
20-
</>
21-
) : (
22-
<>
23-
<img src={logo} alt="avatar" />
24-
<span className="author-name">{lastCommit?.name}</span>
25-
</>
26-
)}
27-
&nbsp;
28-
<span className="commit-message" title={lastCommit?.message}>
29-
{lastCommit?.message}
30-
</span>
21+
) : (
22+
<span className="author-name">{name}</span>
23+
)}
24+
&nbsp;
25+
<span className="commit-message" title={message}>
26+
{message}
27+
</span>
28+
</div>
29+
<div>
30+
<span className="commit-date">on {dayjs(date).format("D MMM YYYY")}</span>
31+
</div>
3132
</div>
32-
<div>
33-
<span className="commit-date">on {dayjs(lastCommit?.date).format("D MMM YYYY")}</span>
34-
</div>
35-
</div>
36-
);
33+
);
34+
};
3735

3836
export default LastCommitHeader;

0 commit comments

Comments
 (0)