Move data provider to shared package (#582)

* create data-provider package and move code from data-provider folder to be shared between apps

* fix type issues

* add packages to ignore

* add new data-provider package to apps

* refactor: change client imports to use @librechat/data-provider package

* include data-provider build script in frontend build

* fix type issue after rebasing

* delete admin/package.json from this branch

* update test ci script to include building of data-provider package

* Try using regular build for test action

* Switch frontend-review back to build:ci

* Remove loginRedirect from Login.tsx

* Add ChatGPT back to EModelEndpoint
This commit is contained in:
Dan Orlando 2023-07-04 12:47:41 -07:00 committed by GitHub
parent d0078d478d
commit 04e4259005
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 1472 additions and 141 deletions

View file

@ -16,7 +16,7 @@ import {
useGetUserQuery,
useRefreshTokenMutation,
TLoginUser
} from '~/data-provider';
} from '@librechat/data-provider';
import { useNavigate } from 'react-router-dom';
export type TAuthContext = {
@ -35,10 +35,20 @@ export type TUserContext = {
redirect?: string;
};
export type TAuthConfig = {
loginRedirect: string;
};
//@ts-ignore - index expression is not of type number
window['errorTimeout'] = undefined;
const AuthContext = createContext<TAuthContext | undefined>(undefined);
const AuthContextProvider = ({ children }: { children: ReactNode }) => {
const AuthContextProvider = ({
authConfig,
children
}: {
authConfig: TAuthConfig;
children: ReactNode;
}) => {
const [user, setUser] = useState<TUser | undefined>(undefined);
const [token, setToken] = useState<string | undefined>(undefined);
const [error, setError] = useState<string | undefined>(undefined);
@ -60,7 +70,7 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => {
setError(error);
}, 400);
}
}
};
const setUserContext = useCallback(
(userContext: TUserContext) => {
@ -79,7 +89,7 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => {
[navigate]
);
const getCookieValue = (key) => {
const getCookieValue = (key: string) => {
let keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
};
@ -157,7 +167,7 @@ const AuthContextProvider = ({ children }: { children: ReactNode }) => {
// setError(error.message);
// }
// });
//
//
// }, [setUserContext]);
// useEffect(() => {