31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { ContextHelp } from "@repo/shadcn-ui/components/context-help";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { SupportApiError } from "./support-api";
|
|
export function SupportHelp({ tool = false }: { tool?: boolean }) {
|
|
const { t } = useTranslation("assets");
|
|
return (
|
|
<ContextHelp
|
|
description={t(tool ? "support.toolDescription" : "support.description")}
|
|
examples={t(tool ? "support.toolExamples" : "support.examples")}
|
|
examplesLabel={t("support.examplesLabel")}
|
|
guidance={t(tool ? "support.toolGuidance" : "support.guidance")}
|
|
scopeNote={tool ? undefined : t("support.scope")}
|
|
title={t(tool ? "support.toolHelp" : "support.help")}
|
|
/>
|
|
);
|
|
}
|
|
export function SupportFeedback({ error, invalid = false }: { error: unknown; invalid?: boolean }) {
|
|
const { t } = useTranslation("assets");
|
|
const code = invalid
|
|
? "INVALID_REQUEST"
|
|
: error instanceof SupportApiError
|
|
? error.code
|
|
: "INTERNAL_ERROR";
|
|
return error || invalid ? (
|
|
<p className="text-sm text-destructive" role="alert">
|
|
{t(`support.errors.${code}`, { defaultValue: t("support.errors.INTERNAL_ERROR") })}
|
|
</p>
|
|
) : null;
|
|
}
|