Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 3x 3x 1x 2x 16x | import { Button } from '@/ahuora-design-system/ui/button'
import DebouncedInput from '@/ahuora-design-system/ui/debounced-input'
import { ChevronLeft, ChevronRight } from 'lucide-react'
import { toast } from "sonner";
export default function RowResultHead({ componentName, row, setRow, maxRow, handleBack }) {
function handlePrevious() {
setRow(+row - 1);
}
function handleNext() {
setRow(+row + 1);
}
function handleSetRow(value: number | string | null) {
if (value) {
if (+value <= maxRow && +value >= 0) {
setRow(+value);
} else {
toast.error('Invalid row number');
}
} else E{
setRow(0);
}
}
return (
<div className="flex items-center justify-between">
<h1 className='flex-1'>{componentName}</h1>
<div className="flex items-center gap-3">
<div className="flex gap-2 items-center" aria-label="paginator-row-result-head">
<Button
variant="outline"
size="icon"
onClick={handlePrevious}
disabled={row <= 0}
className="h-7 w-7"
>
<ChevronLeft />
</Button>
<p>Row {row} / {maxRow}</p>
<Button
variant="outline"
size="icon"
onClick={handleNext}
disabled={row >= maxRow}
className="h-7 w-7"
>
<ChevronRight />
</Button>
</div>
<p>|</p>
<div className="flex gap-2 items-center" aria-label="goto-input-row-result-head">
<p>Go to row:</p>
<div>
<DebouncedInput value={row} onUpdate={handleSetRow} type="number" className="border rounded w-16 h-7" />
</div>
</div>
</div>
<div className='flex flex-1 gap-4 justify-end'>
<Button variant="ghost" className="p-0 gap-1" onClick={handleBack}>
<ChevronLeft />
<p>Back</p>
</Button>
</div>
</div>
)
}
|