26 lines
944 B
TypeScript
26 lines
944 B
TypeScript
import type { ReactNode } from "react";
|
|
import { parseSupportCaseContext } from "../../../entities/support-case";
|
|
import type { SupportCaseObjectReference } from "../../../shared/api/schemas";
|
|
import { paths } from "../../../shared/config";
|
|
import { ButtonLink } from "../../../shared/ui";
|
|
|
|
export type SupportEntryProps = {
|
|
context?: SupportCaseObjectReference | undefined;
|
|
children?: ReactNode;
|
|
variant?: "primary" | "secondary" | "quiet" | undefined;
|
|
};
|
|
|
|
/** A support entry link carries only an allowlisted object reference in router state. */
|
|
export function SupportEntry({ context, children = "Поддержка", variant }: SupportEntryProps) {
|
|
const safeContext = context ? parseSupportCaseContext(context) : null;
|
|
return (
|
|
<ButtonLink
|
|
to={paths.support}
|
|
state={safeContext ? { supportContext: safeContext } : undefined}
|
|
{...(variant ? { variant } : {})}
|
|
>
|
|
{children}
|
|
</ButtonLink>
|
|
);
|
|
}
|