PR-589725: Updating packages, fixing redux actions and fixing linting.

This commit is contained in:
2025-04-11 06:06:54 +00:00
parent d0f4f38381
commit be0bb6238f
25 changed files with 1499 additions and 992 deletions

View File

@ -1,4 +1,4 @@
import * as express from "express"
import * as express from 'express';
declare global {
namespace Express {
@ -6,4 +6,4 @@ declare global {
hashManifest?: Record<string,any>
}
}
}
}

View File

@ -1,4 +1,4 @@
declare module "*.svg" {
declare module '*.svg' {
const content: any;
export default content;
}

View File

@ -6,22 +6,22 @@ import initialStateReducer from '../frontend/reducers/initialState';
import setStore from '../frontend/setStore';
export const ProviderMock = ({ children, initialState }: { children: any, initialState?: any}) => {
let initialStateMock = initialStateReducer
let initialStateMock = initialStateReducer;
if(initialState !== undefined){
initialStateMock = initialState
}
if(initialState !== undefined){
initialStateMock = initialState;
}
const history = createMemoryHistory();
const store = setStore({ initialState: initialStateMock });
const history = createMemoryHistory();
const store = setStore({ initialState: initialStateMock });
return(
<Provider store={store}>
<Router location={history.location} navigator={history}>
{children}
</Router>
</Provider>
)
}
return(
<Provider store={store}>
<Router location={history.location} navigator={history}>
{children}
</Router>
</Provider>
);
};
export default ProviderMock;

View File

@ -1,9 +1 @@
import test, { TTest } from './testAction';
export type TAction = TTest
const actions = {
test
}
export default actions
export * from '@actions/testAction';

View File

@ -14,12 +14,12 @@ export interface IChangeHelloPayload {
export type TTest = IChangeHello
const changeHello = (payload: string) => ({
type: ActionTypesTest.ChangeHello,
payload
})
type: ActionTypesTest.ChangeHello,
payload
});
const actions = {
changeHello
}
changeHello
};
export default actions
export default actions;

View File

@ -1,18 +1,18 @@
import React from 'react';
import logo from '../logo.svg';
import './InitialComponent.scss';
import { Link } from "react-router-dom";
import { Link } from 'react-router-dom';
const OtherComponent = () => (
<div className="App">
<header className="App-header">
<img src="assets/img/logo.svg" className="App-logo" alt="logo" />
<p>
<div className="App">
<header className="App-header">
<img src="assets/img/logo.svg" className="App-logo" alt="logo" />
<p>
Edit <code>src/frontend/OtherComponent.jsx</code> and save to reload.
</p>
<Link className="App-link" to="/">Initial Component</Link>
</header>
</div>
</p>
<Link className="App-link" to="/">Initial Component</Link>
</header>
</div>
);
export default OtherComponent;

View File

@ -4,7 +4,7 @@ import { useRoutes } from 'react-router-dom';
import routes from '../../routes';
const PrincipalRoutes = () => {
let element = useRoutes(routes);
const element = useRoutes(routes);
return element;
};

View File

@ -4,20 +4,20 @@ import { ProviderMock } from '@mocks';
import App from '@components/App';
describe('<App/> Component', () => {
beforeEach(() => {
fetchMock.resetMocks();
});
beforeEach(() => {
fetchMock.resetMocks();
});
it('Should render root <App /> Component', async () => {
fetchMock.mockResponseOnce(JSON.stringify({
//First Data Fetch
data: 'data'
}));
it('Should render root <App /> Component', async () => {
fetchMock.mockResponseOnce(JSON.stringify({
//First Data Fetch
data: 'data'
}));
render(
<ProviderMock>
<App />
</ProviderMock>
)
})
})
render(
<ProviderMock>
<App />
</ProviderMock>
);
});
});

View File

@ -1,10 +1,6 @@
import { combineReducers } from 'redux';
import testReducer from './testReducer';
import { IChangeHelloPayload } from '../actions/testAction';
export interface IInitialState {
testReducer?: IChangeHelloPayload | undefined
}
export * from './initialState';
const rootReducer = combineReducers({
// Here comes the reducers

View File

@ -1,3 +1,6 @@
import { IInitialState } from './';
import { IChangeHelloPayload } from '@actions';
export interface IInitialState {
testReducer?: IChangeHelloPayload | undefined
}
const initialState: IInitialState = {};
export default initialState;

View File

@ -1,10 +1,10 @@
import { TAction } from '../actions';
import { TTest } from '@actions';
const initialState = {
hello: 'world'
};
const testReducer = (state = initialState, action: TAction) => {
const testReducer = (state = initialState, action: TTest) => {
switch (action.type){
case 'CHANGE_HELLO': {
const newHello = action.payload.hello;

View File

@ -3,8 +3,7 @@ import { legacy_createStore as createStore} from 'redux'; //, applyMiddleware
// import { Provider } from 'react-redux';
import { composeWithDevTools as composeWithDevToolsWeb } from '@redux-devtools/extension';
import { config } from '../../config';
import reducer, { IInitialState } from './reducers';
import reducer, { IInitialState } from '@reducers';
const { ENV } = config;
@ -15,11 +14,11 @@ const composeEnhancers = composeWithDevToolsWeb({
const setStore = ({ initialState }: { initialState: IInitialState | undefined }) => {
const store = ENV === 'development' ? createStore(
reducer,
initialState,
initialState as any,
composeEnhancers(),
) : createStore(
reducer,
initialState,
initialState as any,
);
return store;
};

View File

@ -129,7 +129,7 @@ const renderApp = (req, res, next) => {
};
app
.get('*', renderApp);
.get(/\*/, renderApp);
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);