fix(reviews): admin может self-approve record draft через UI

This commit is contained in:
Александр Зимин
2026-06-02 13:02:13 +00:00
parent 039b6ef039
commit 308c9104e9
2 changed files with 51 additions and 6 deletions
+9 -3
View File
@@ -25,6 +25,7 @@ import {
} from '@/ui'
import axios from 'axios'
import { useAuth } from '@/auth/useAuth'
import { useIsAdmin } from '@/auth/usePermissions'
import { ArrowCounterClockwiseIcon, CheckCircleIcon, XCircleIcon } from '@phosphor-icons/react'
import {
useDictionaries,
@@ -693,11 +694,16 @@ function ReviewDrawer({ draftId, onClose }: DrawerProps) {
// 1. `isPending` = false: terminal draft (APPROVED/REJECTED/WITHDRAWN).
// Никаких actions — read-only diff + decision banner.
// 2. `isMineAndPending`: maker открыл свой собственный pending draft из
// "Мои" таба. Approve self запрещён backend'ом (self_approve_forbidden),
// reject своего черновика бессмыслен — показываем Withdraw.
// "Мои" таба. Для regular maker'а Approve self запрещён backend'ом
// (self_approve_forbidden), показываем Withdraw. Admin override
// (MR !280): backend разрешает self-approve если у actor'а admin
// роль → frontend тоже снимает блокировку, иначе UI скрывает кнопку
// которую backend бы пропустил.
// 3. Иначе — reviewer flow: approve/reject как было.
const isAdmin = useIsAdmin()
const isPending = draft?.status === 'PENDING'
const isMineAndPending = isPending && Boolean(currentSub) && draft?.makerId === currentSub
const isMineAndPending =
isPending && Boolean(currentSub) && draft?.makerId === currentSub && !isAdmin
const handleApprove = () => {
if (!draftId) return