mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30:15 +01:00
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:
parent
d0078d478d
commit
04e4259005
48 changed files with 1472 additions and 141 deletions
|
|
@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|||
import LoginForm from './LoginForm';
|
||||
import { useAuthContext } from '~/hooks/AuthContext';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useGetStartupConfig } from '~/data-provider';
|
||||
import { useGetStartupConfig } from '@librechat/data-provider';
|
||||
|
||||
function Login() {
|
||||
const { login, error, isAuthenticated } = useAuthContext();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useForm } from 'react-hook-form';
|
||||
import { TLoginUser } from '~/data-provider';
|
||||
import { TLoginUser } from '@librechat/data-provider';
|
||||
|
||||
type TLoginFormProps = {
|
||||
onSubmit: (data: TLoginUser) => void;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useRegisterUserMutation, TRegisterUser, useGetStartupConfig } from '~/data-provider';
|
||||
import {
|
||||
useRegisterUserMutation,
|
||||
TRegisterUser,
|
||||
useGetStartupConfig
|
||||
} from '@librechat/data-provider';
|
||||
|
||||
function Registration() {
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -27,7 +31,9 @@ function Registration() {
|
|||
},
|
||||
onError: (error) => {
|
||||
setError(true);
|
||||
//@ts-ignore - error is of type unknown
|
||||
if (error.response?.data?.message) {
|
||||
//@ts-ignore - error is of type unknown
|
||||
setErrorMessage(error.response?.data?.message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useRequestPasswordResetMutation, TRequestPasswordReset } from '~/data-provider';
|
||||
import {
|
||||
useRequestPasswordResetMutation,
|
||||
TRequestPasswordReset,
|
||||
TRequestPasswordResetResponse
|
||||
} from '@librechat/data-provider';
|
||||
|
||||
function RequestPasswordReset() {
|
||||
const {
|
||||
|
|
@ -15,7 +19,7 @@ function RequestPasswordReset() {
|
|||
|
||||
const onSubmit = (data: TRequestPasswordReset) => {
|
||||
requestPasswordReset.mutate(data, {
|
||||
onSuccess: (data) => {
|
||||
onSuccess: (data: TRequestPasswordResetResponse) => {
|
||||
setSuccess(true);
|
||||
setResetLink(data.link);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useResetPasswordMutation, TResetPassword } from '~/data-provider';
|
||||
import { useResetPasswordMutation, TResetPassword } from '@librechat/data-provider';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
|
||||
function ResetPassword() {
|
||||
|
|
@ -73,12 +73,14 @@ function ResetPassword() {
|
|||
<input
|
||||
type="hidden"
|
||||
id="token"
|
||||
// @ts-ignore - Type 'string | null' is not assignable to type 'string | number | readonly string[] | undefined'
|
||||
value={params.get('token')}
|
||||
{...register('token', { required: 'Unable to process: No valid reset token' })}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
id="userId"
|
||||
// @ts-ignore - Type 'string | null' is not assignable to type 'string | number | readonly string[] | undefined'
|
||||
value={params.get('userId')}
|
||||
{...register('userId', { required: 'Unable to process: No valid user id' })}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { render, waitFor } from 'layout-test-utils';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import Login from '../Login';
|
||||
import * as mockDataProvider from '~/data-provider';
|
||||
import * as mockDataProvider from '@librechat/data-provider';
|
||||
|
||||
jest.mock('~/data-provider');
|
||||
jest.mock('@librechat/data-provider');
|
||||
|
||||
const setup = ({
|
||||
useGetUserQueryReturnValue = {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { render, waitFor } from 'layout-test-utils';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import Registration from '../Registration';
|
||||
import * as mockDataProvider from '~/data-provider';
|
||||
import * as mockDataProvider from '@librechat/data-provider';
|
||||
|
||||
jest.mock('~/data-provider');
|
||||
jest.mock('@librechat/data-provider');
|
||||
|
||||
const setup = ({
|
||||
useGetUserQueryReturnValue = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue