Skip to content

Commit e958205

Browse files
committed
feat: add test api url flow
1 parent 4d31624 commit e958205

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

libs/mobile/auth/features/email-sign-in-form/src/lib/component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AppButton, View, FormFloatedLabelInput } from '@open-webui-react-native
77
import { FormValues } from '@open-webui-react-native/mobile/shared/utils/form';
88
import { appConfigurationApi, authApi } from '@open-webui-react-native/shared/data-access/api';
99
import { appStorageService } from '@open-webui-react-native/shared/data-access/storage';
10+
import { resolveApiUrl } from '@open-webui-react-native/shared/utils/config';
1011
import { FeatureID, isFeatureEnabled } from '@open-webui-react-native/shared/utils/feature-flag';
1112
import { useDebouncedQuery } from '@open-webui-react-native/shared/utils/use-debounced-query';
1213
import { UrlInputLoader } from './components';
@@ -64,7 +65,7 @@ export function EmailSignInForm({ onSuccess, onApiUrlChange }: EmailSignInFormPr
6465
useEffect(() => {
6566
const refetchConfig = async (): Promise<void> => {
6667
if (isUrlValid) {
67-
const res = await fetchWithUrl(debouncedQuery);
68+
const res = await fetchWithUrl(resolveApiUrl(debouncedQuery));
6869

6970
if (res?.name && res?.version) {
7071
appStorageService.apiUrl.set(debouncedQuery);

libs/mobile/auth/features/sign-in/src/lib/component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ReactElement, useState } from 'react';
33
import { EmailSignInForm } from '@open-webui-react-native/mobile/auth/features/email-sign-in-form';
44
import { GoogleSignInForm } from '@open-webui-react-native/mobile/auth/features/google-sign-in-form';
55
import { AppText, View } from '@open-webui-react-native/mobile/shared/ui/ui-kit';
6-
import { ronasApiUrl } from '@open-webui-react-native/shared/utils/config';
6+
import { ronasApiUrl, testApiUrl } from '@open-webui-react-native/shared/utils/config';
77
import { ToastService } from '@open-webui-react-native/shared/utils/toast-service';
88

99
export interface SignInProps {
@@ -17,7 +17,8 @@ export function SignIn(props: SignInProps): ReactElement {
1717

1818
const normalizeUrl = (url?: string): string => (url ?? '').trim().replace(/\/+$/, '');
1919

20-
const showGoogleSignIn = normalizeUrl(apiUrlInput) === normalizeUrl(ronasApiUrl);
20+
const isTestApiUrl = normalizeUrl(apiUrlInput) === normalizeUrl(testApiUrl);
21+
const showGoogleSignIn = !isTestApiUrl && normalizeUrl(apiUrlInput) === normalizeUrl(ronasApiUrl);
2122

2223
const handleSuccess = (): void => {
2324
onSuccess();

libs/shared/utils/config/src/get-api-url.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ export const ronasApiUrl = appEnv.select({
88
production: 'https://ai.ronas.online',
99
});
1010

11-
export const getApiUrl = (): string => {
12-
const normalizeUrl = (url?: string): string => (url ?? '').trim().replace(/\/+$/, '');
11+
export const testApiUrl = 'https://ai.test-api.online';
12+
13+
const normalizeUrl = (url?: string): string => (url ?? '').trim().replace(/\/+$/, '');
1314

15+
export const resolveApiUrl = (url: string): string => {
16+
return normalizeUrl(url) === normalizeUrl(testApiUrl) ? normalizeUrl(ronasApiUrl) : normalizeUrl(url);
17+
};
18+
19+
export const getApiUrl = (): string => {
1420
const stored = normalizeUrl(appStorageService.apiUrl.get());
1521
const fallback = normalizeUrl(ronasApiUrl);
1622

17-
return stored || fallback;
23+
return resolveApiUrl(stored || fallback);
1824
};

0 commit comments

Comments
 (0)