mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-18 08:02:03 +03:00
c649f85a1c
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
/* eslint-disable max-lines */
|
|
"use client";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
import { CopyButton } from "@/lib/components/ui/CopyButton";
|
|
import { FieldHeader } from "@/lib/components/ui/FieldHeader/FieldHeader";
|
|
|
|
import styles from "./ApiKeyConfig.module.scss";
|
|
import { useApiKeyConfig } from "./hooks/useApiKeyConfig";
|
|
|
|
export const ApiKeyConfig = (): JSX.Element => {
|
|
const { apiKey, handleCopyClick, handleCreateClick } = useApiKeyConfig();
|
|
const { t } = useTranslation(["config"]);
|
|
|
|
return (
|
|
<div>
|
|
<FieldHeader iconName="key" label={`Quivr ${t("apiKey")}`} />
|
|
{apiKey === "" ? (
|
|
<Button
|
|
data-testid="create-new-key"
|
|
variant="secondary"
|
|
onClick={() => void handleCreateClick()}
|
|
>
|
|
Create New Key
|
|
</Button>
|
|
) : (
|
|
<div className={styles.response_wrapper}>
|
|
<span>{apiKey}</span>
|
|
<CopyButton handleCopy={handleCopyClick} size="small" />
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|