From d592b6fcdaa819d37261ccca4ae11f816f0cd68b Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 2 Oct 2025 14:47:01 -0700 Subject: [PATCH] stuff --- .../components/CommitInfo/CommitInfo.tsx | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/pages/RepoPage/shared/components/CommitInfo/CommitInfo.tsx diff --git a/src/pages/RepoPage/shared/components/CommitInfo/CommitInfo.tsx b/src/pages/RepoPage/shared/components/CommitInfo/CommitInfo.tsx new file mode 100644 index 0000000000..2b4bd2b58e --- /dev/null +++ b/src/pages/RepoPage/shared/components/CommitInfo/CommitInfo.tsx @@ -0,0 +1,74 @@ +import { useMemo } from 'react' + +import { cn } from 'shared/utils/cn' + +interface CommitInfoProps { + commitSha: string + author: string + message: string + timestamp: number + branch: string + ciPassed?: boolean +} + +export function CommitInfo({ + commitSha, + author, + message, + timestamp, + branch, + ciPassed, +}: CommitInfoProps) { + const shortSha = useMemo(() => commitSha.slice(0, 7), [commitSha]) + + const authorDisplay = useMemo( + () => `${author} on ${branch}`, + [author, branch] + ) + + const formattedDate = useMemo(() => { + return new Date(timestamp).toLocaleDateString() + }, [timestamp]) + + const statusText = useMemo(() => { + return ciPassed ? 'Passed' : 'Failed' + }, [ciPassed]) + + const statusClassName = useMemo( + () => + cn( + 'rounded px-2 py-1 text-xs font-semibold', + ciPassed + ? 'bg-ds-primary-green text-white' + : 'bg-ds-primary-red text-white' + ), + [ciPassed] + ) + + const truncatedMessage = useMemo(() => { + return message.length > 50 ? message.slice(0, 50) + '...' : message + }, [message]) + + return ( +
+
+
+ + {shortSha} + + {ciPassed !== undefined && ( + {statusText} + )} +
+ {formattedDate} +
+ +
+

{truncatedMessage}

+

{authorDisplay}

+
+
+ ) +} + +export default CommitInfo