feat(frontend): edit projects and show semantic match evidence
This commit is contained in:
1 parent
5a731c25b7
commit
bc00d6901f
52 files changed
+2992
-111
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import type { ReactNode } from "react";
|
||||
import styles from "./profile-form.module.css";
|
||||
|
||||
/* Field helpers shared by the steps of the profile form. */
|
||||
|
||||
export function ErrorText({ id, children }: { id: string; children?: string | undefined }) {
|
||||
return children ? (
|
||||
<p className={styles.error} id={id}>
|
||||
{children}
|
||||
</p>
|
||||
) : null;
|
||||
}
|
||||
|
||||
export function Suggestion({
|
||||
source,
|
||||
}: {
|
||||
source: { quote: string | null; origin: string } | null;
|
||||
}) {
|
||||
if (!source || source.origin === "manual") return null;
|
||||
const origin = source.origin === "imported" ? "Импортировано" : "Предложено из документа";
|
||||
return (
|
||||
<details className={styles.suggestion}>
|
||||
<summary>{origin}. Значение пока не подтверждено.</summary>
|
||||
{source.quote ? <blockquote>{source.quote}</blockquote> : <p>Цитата не сохранена.</p>}
|
||||
</details>
|
||||
);
|
||||
}
|
||||
|
||||
export type FieldProps = {
|
||||
id: string;
|
||||
label: string;
|
||||
error?: string | undefined;
|
||||
description?: ReactNode | undefined;
|
||||
suggestion?: { quote: string | null; origin: string } | null | undefined;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export function Field({ id, label, error, description, suggestion, children }: FieldProps) {
|
||||
return (
|
||||
<div className={styles.field}>
|
||||
<label htmlFor={id}>{label}</label>
|
||||
{description ? (
|
||||
<p className={styles.hint} id={`${id}-hint`}>
|
||||
{description}
|
||||
</p>
|
||||
) : null}
|
||||
{children}
|
||||
{suggestion ? (
|
||||
<div id={`${id}-suggestion`}>
|
||||
<Suggestion source={suggestion} />
|
||||
</div>
|
||||
) : null}
|
||||
<ErrorText id={`${id}-error`}>{error}</ErrorText>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user