fix(reviews): anonymous Mine tab — dedicated empty state с sign-in CTA

This commit is contained in:
Александр Зимин
2026-05-15 13:29:11 +00:00
parent d31d16a9a6
commit e80d31a340
2 changed files with 31 additions and 0 deletions
@@ -1,6 +1,7 @@
import { useMemo, useState } from 'react'
import { Link } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { useAuth } from 'react-oidc-context'
import {
Badge,
Button,
@@ -103,10 +104,34 @@ const operationVariant = (op: DraftOperation): 'info' | 'success' | 'warning' =>
export function MyDraftsPanel({ onRecordClick }: Props) {
const { t } = useTranslation()
const auth = useAuth()
// Anonymous: backend /drafts/me + /admin/schema-drafts/me либо 401, либо
// empty list (зависит от auth.required gate). Раньше это упиралось в
// generic "У вас пока нет черновиков" — misleading: пользователь не
// понимал что нужно sign in. Теперь dedicated empty state с CTA.
const recordsQ = useMyDrafts(0, 50)
const schemasQ = useMySchemaDrafts(0, 50)
const [filter, setFilter] = useState<StatusFilter>('all')
if (!auth.isAuthenticated) {
return (
<EmptyState
title={t('reviews.mine.anonTitle', {
defaultValue: 'Войдите чтобы видеть свои черновики',
})}
description={t('reviews.mine.anonDescription', {
defaultValue:
'Собственные drafts видны только после авторизации — backend фильтрует по вашему JWT sub claim. Войдите через Keycloak чтобы открыть Мои.',
})}
action={
<Button onClick={() => auth.signinRedirect()}>
{t('auth.login', { defaultValue: 'Войти' })}
</Button>
}
/>
)
}
const rows: UnifiedRow[] = useMemo(() => {
const records: UnifiedRow[] = (recordsQ.data?.items ?? []).map((r) => ({
kind: 'record',