feat: add back button to test edit form
TestForm now accepts optional onBack/backLabel props. TestEdit passes 'К просмотру теста' back button when in edit mode. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
|
import { ArrowLeftOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
} from 'antd'
|
} from 'antd'
|
||||||
|
|
||||||
|
|
||||||
const { Title } = Typography
|
const { Title } = Typography
|
||||||
|
|
||||||
const EMPTY_ANSWER = { text: '', is_correct: false }
|
const EMPTY_ANSWER = { text: '', is_correct: false }
|
||||||
@@ -33,6 +34,8 @@ interface TestFormProps {
|
|||||||
isPending: boolean
|
isPending: boolean
|
||||||
submitLabel: string
|
submitLabel: string
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
|
onBack?: () => void
|
||||||
|
backLabel?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TestForm({
|
export default function TestForm({
|
||||||
@@ -42,6 +45,8 @@ export default function TestForm({
|
|||||||
isPending,
|
isPending,
|
||||||
submitLabel,
|
submitLabel,
|
||||||
onCancel,
|
onCancel,
|
||||||
|
onBack,
|
||||||
|
backLabel = 'Назад',
|
||||||
}: TestFormProps) {
|
}: TestFormProps) {
|
||||||
const [form] = Form.useForm<TestFormValues>()
|
const [form] = Form.useForm<TestFormValues>()
|
||||||
|
|
||||||
@@ -55,6 +60,15 @@ export default function TestForm({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ maxWidth: 820, margin: '0 auto', padding: 24 }}>
|
<div style={{ maxWidth: 820, margin: '0 auto', padding: 24 }}>
|
||||||
|
{onBack && (
|
||||||
|
<Button
|
||||||
|
icon={<ArrowLeftOutlined />}
|
||||||
|
onClick={onBack}
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
>
|
||||||
|
{backLabel}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Title level={2}>{heading}</Title>
|
<Title level={2}>{heading}</Title>
|
||||||
|
|
||||||
<Form form={form} layout="vertical" onFinish={onSubmit} initialValues={defaultValues}>
|
<Form form={form} layout="vertical" onFinish={onSubmit} initialValues={defaultValues}>
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ export default function TestEdit() {
|
|||||||
isPending={isPending}
|
isPending={isPending}
|
||||||
submitLabel="Сохранить"
|
submitLabel="Сохранить"
|
||||||
onCancel={() => setEditMode(false)}
|
onCancel={() => setEditMode(false)}
|
||||||
|
onBack={() => setEditMode(false)}
|
||||||
|
backLabel="К просмотру теста"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user