PromucFlow_constructor/app/client/src/index.tsx
Pawan Kumar 0cc104ed93
chore: update import of AppState to DefaultReduxState (#40494)
We were using the AppState incorrectly in our selectors. We should use
`DefaultRootState` from react-redux.

/ok-to-test tags="@tag.Sanity"

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Updated state parameter types in numerous selectors and hooks across
the application from a custom application state type to a standard Redux
root state type, enhancing type consistency and maintainability without
impacting functionality or user experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14771101257>
> Commit: 48aef24d9a54ee63d06943128f7545ba0d461172
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14771101257&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 01 May 2025 07:16:33 UTC
<!-- end of auto-generated comment: Cypress test results  -->
2025-05-01 15:53:37 +05:30

88 lines
2.6 KiB
TypeScript
Executable File

// This file must be executed as early as possible to ensure the preloads are triggered ASAP
import "./preload-route-chunks";
// Initialise eval worker instance
import "utils/workerInstances";
import React from "react";
import "./wdyr";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import "./index.css";
import "@appsmith/ads-old/src/themes/default/index.css";
import "@appsmith/ads/src/__theme__/default/index.css";
import { ThemeProvider } from "styled-components";
import { appInitializer } from "utils/AppUtils";
import store, { runSagaMiddleware } from "./store";
import { LayersContext, Layers } from "constants/Layers";
import AppRouter from "ee/AppRouter";
import { getCurrentThemeDetails } from "selectors/themeSelectors";
import { connect } from "react-redux";
import type { DefaultRootState } from "react-redux";
import { Toast } from "@appsmith/ads";
import "./assets/styles/index.css";
import "./polyfills";
import GlobalStyles from "globalStyles";
// enable autofreeze only in development
import AppErrorBoundary from "./AppErrorBoundry";
import log from "loglevel";
import { FaroErrorBoundary } from "@grafana/faro-react";
runSagaMiddleware();
appInitializer();
(async () => {
try {
await import(/* webpackChunkName: "instrumentation" */ "./instrumentation");
} catch (e) {
log.error("Error loading telemetry script", e);
}
})();
function App() {
return (
<FaroErrorBoundary fallback={<div>An error has occured</div>}>
<Provider store={store}>
<LayersContext.Provider value={Layers}>
<ThemedAppWithProps />
</LayersContext.Provider>
</Provider>
</FaroErrorBoundary>
);
}
class ThemedApp extends React.Component<{
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
currentTheme: any;
}> {
render() {
return (
<ThemeProvider theme={this.props.currentTheme}>
<Toast />
<GlobalStyles />
<AppErrorBoundary>
<AppRouter />
</AppErrorBoundary>
</ThemeProvider>
);
}
}
const mapStateToProps = (state: DefaultRootState) => ({
currentTheme: getCurrentThemeDetails(state),
});
const ThemedAppWithProps = connect(mapStateToProps)(ThemedApp);
ReactDOM.render(<App />, document.getElementById("root"));
// expose store when run in Cypress
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if ((window as any).Cypress) {
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).store = store;
}