'use client'
import { useEffect, useRef, useState } from 'react'
import type { GitStatus } from '~/utils/git'
import { parsePatchFiles } from '@pierre/diffs'
interface Props {
status: GitStatus
workingDiff: string
stagedDiff: string
}
export function StatusView({ status, workingDiff, stagedDiff }: Props) {
const hasChanges =
status.staged.length > 0 ||
status.unstaged.length > 0 ||
status.untracked.length > 0
if (!hasChanges) {
return (
<div className="flex h-full items-center justify-center text-gray-500">
Working tree clean
</div>
)
}
return (
<div className="space-y-6 p-4">
{status.staged.length > 0 && (
<section>
<h2 className="mb-2 text-sm font-medium text-emerald-400">
Staged ({status.staged.length})
</h2>
<FileList items={status.staged} color="text-emerald-400" />
{stagedDiff && <PatchRenderer patch={stagedDiff} />}
</section>
)}
{status.unstaged.length > 0 && (
<section>
<h2 className="mb-2 text-sm font-medium text-amber-400">