From 4a599e986f1c56c3e3543e61b9403bdd01593c37 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Sat, 30 Sep 2023 22:16:34 +0700 Subject: [PATCH 1/4] UI Page [Auth Page] [+] feat(auth.tsx): add support for resetting access token in resetAccessCode function [+] fix(auth.tsx): fix formatting issue in resetAccessCode function [+] feat(locales): add support for sub tips in Auth component for multiple languages : - Add sub tips in Arabic locale (ar.ts) - Add sub tips in Bengali locale (bn.ts) - Add sub tips in Chinese locale (cn.ts) - Add sub tips in English locale (en.ts) - Add sub tips in Indonesian locale (id.ts) --- app/components/auth.tsx | 23 ++++++++++++++++++----- app/locales/ar.ts | 1 + app/locales/bn.ts | 1 + app/locales/cn.ts | 1 + app/locales/en.ts | 1 + app/locales/id.ts | 8 ++++++-- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/components/auth.tsx b/app/components/auth.tsx index 9a5b0c655e6..4e5ab8dc6a3 100644 --- a/app/components/auth.tsx +++ b/app/components/auth.tsx @@ -15,7 +15,7 @@ export function AuthPage() { const access = useAccessStore(); const goHome = () => navigate(Path.Home); - const resetAccessCode = () => access.updateCode(""); // Reset access code to empty string + const resetAccessCode = () => { access.updateCode(""); access.updateToken(""); }; // Reset access code to empty string useEffect(() => { if (getClientConfig()?.isApp) { @@ -42,6 +42,16 @@ export function AuthPage() { access.updateCode(e.currentTarget.value); }} /> +
{Locale.Auth.SubTips}
+ { + access.updateToken(e.currentTarget.value); + }} + />
- { - resetAccessCode(); - goHome(); - }} /> + { + resetAccessCode(); + goHome(); + }} + />
); diff --git a/app/locales/ar.ts b/app/locales/ar.ts index 520cb26356e..d5844acd695 100644 --- a/app/locales/ar.ts +++ b/app/locales/ar.ts @@ -10,6 +10,7 @@ const ar: PartialLocaleType = { Auth: { Title: "تحتاج إلى رمز الوصول", Tips: "يرجى إدخال رمز الوصول أدناه", + SubTips: "أو أدخل مفتاح واجهة برمجة تطبيقات OpenAI الخاص بك", Input: "رمز الوصول", Confirm: "تأكيد", Later: "لاحقًا", diff --git a/app/locales/bn.ts b/app/locales/bn.ts index 2d2266b3f43..2db132cecc2 100644 --- a/app/locales/bn.ts +++ b/app/locales/bn.ts @@ -10,6 +10,7 @@ const bn: PartialLocaleType = { Auth: { Title: "একটি অ্যাক্সেস কোড প্রয়োজন", Tips: "নীচে অ্যাক্সেস কোড ইনপুট করুন", + SubTips: "অথবা আপনার OpenAI API কী প্রবেশ করুন", Input: "অ্যাক্সেস কোড", Confirm: "নিশ্চিত করুন", Later: "পরে", diff --git a/app/locales/cn.ts b/app/locales/cn.ts index b2afc753457..8eeef9e013c 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -13,6 +13,7 @@ const cn = { Auth: { Title: "需要密码", Tips: "管理员开启了密码验证,请在下方填入访问码", + SubTips: "或者输入你的 OpenAI API 密钥", Input: "在此处填写访问码", Confirm: "确认", Later: "稍后再说", diff --git a/app/locales/en.ts b/app/locales/en.ts index 697d09d1f4e..458d53dd568 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -15,6 +15,7 @@ const en: LocaleType = { Auth: { Title: "Need Access Code", Tips: "Please enter access code below", + SubTips: "Or enter your OpenAI API Key", Input: "access code", Confirm: "Confirm", Later: "Later", diff --git a/app/locales/id.ts b/app/locales/id.ts index 244c5ade19a..4b61f6434dc 100644 --- a/app/locales/id.ts +++ b/app/locales/id.ts @@ -1,15 +1,19 @@ +import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import { PartialLocaleType } from "./index"; +const isApp = !!getClientConfig()?.isApp; const id: PartialLocaleType = { WIP: "Coming Soon...", Error: { - Unauthorized: - "Akses tidak diizinkan. Silakan [otorisasi](/#/auth) dengan memasukkan kode akses.", + Unauthorized: isApp + ? "Kunci API tidak valid, silakan periksa di halaman [Pengaturan](/#/settings)." + : "Akses tidak diizinkan, silakan masukkan kode akses di halaman [autentikasi](/#/auth), atau masukkan kunci API OpenAI Anda.", }, Auth: { Title: "Diperlukan Kode Akses", Tips: "Masukkan kode akses di bawah", + SubTips: "Atau masukkan kunci API OpenAI Anda", Input: "Kode Akses", Confirm: "Konfirmasi", Later: "Nanti", From bc00be9065a9ea1af8ab38925400f2bfd8dc10b3 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Sat, 30 Sep 2023 22:33:18 +0700 Subject: [PATCH 2/4] Feat & Fix UI Page [Auth Page] [+] feat(auth.tsx): add goChat function to navigate to chat page [+] fix(auth.tsx): change onClick event from goHome to goChat --- app/components/auth.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/auth.tsx b/app/components/auth.tsx index 4e5ab8dc6a3..8e2b964ab3d 100644 --- a/app/components/auth.tsx +++ b/app/components/auth.tsx @@ -15,6 +15,7 @@ export function AuthPage() { const access = useAccessStore(); const goHome = () => navigate(Path.Home); + const goChat = () => navigate(Path.Chat); const resetAccessCode = () => { access.updateCode(""); access.updateToken(""); }; // Reset access code to empty string useEffect(() => { @@ -57,7 +58,7 @@ export function AuthPage() { Date: Sat, 30 Sep 2023 22:59:24 +0700 Subject: [PATCH 3/4] Refactor Locale Indonesia [+] refactor(id.ts): remove unused import and isApp variable [+] fix(id.ts): update Unauthorized error message --- app/locales/id.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/locales/id.ts b/app/locales/id.ts index 4b61f6434dc..1036e66b64e 100644 --- a/app/locales/id.ts +++ b/app/locales/id.ts @@ -1,15 +1,11 @@ -import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import { PartialLocaleType } from "./index"; -const isApp = !!getClientConfig()?.isApp; const id: PartialLocaleType = { WIP: "Coming Soon...", Error: { - Unauthorized: isApp - ? "Kunci API tidak valid, silakan periksa di halaman [Pengaturan](/#/settings)." - : "Akses tidak diizinkan, silakan masukkan kode akses di halaman [autentikasi](/#/auth), atau masukkan kunci API OpenAI Anda.", - }, + Unauthorized: "Akses tidak diizinkan, silakan masukkan kode akses atau masukkan kunci API OpenAI Anda. di halaman [autentikasi](/#/auth) atau di halaman [Pengaturan](/#/settings).", + }, Auth: { Title: "Diperlukan Kode Akses", Tips: "Masukkan kode akses di bawah", From 04b638aa064e346f72a6fcef295f151379c1be17 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Sun, 1 Oct 2023 00:23:19 +0700 Subject: [PATCH 4/4] Fix & Refactor UI Page [Auth Page] [+] fix(auth.tsx): fix conditional rendering of token input field [+] refactor(auth.tsx): improve code readability by using conditional rendering for token input field --- app/components/auth.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/components/auth.tsx b/app/components/auth.tsx index 8e2b964ab3d..b82d0e894c7 100644 --- a/app/components/auth.tsx +++ b/app/components/auth.tsx @@ -43,16 +43,20 @@ export function AuthPage() { access.updateCode(e.currentTarget.value); }} /> -
{Locale.Auth.SubTips}
- { - access.updateToken(e.currentTarget.value); - }} - /> + {!access.hideUserApiKey ? ( + <> +
{Locale.Auth.SubTips}
+ { + access.updateToken(e.currentTarget.value); + }} + /> + + ) : null}