Skip to content

Commit 0c89d3a

Browse files
authored
Merge pull request #1394 from chhsiao1981/refactor-app
refactor App.tsx
2 parents fc4f1ba + ec02582 commit 0c89d3a

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/App.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import Cart from "./components/NewLibrary/components/Cart";
1515
import Routes from "./routes";
1616
import type { RootState } from "./store/root/applicationState";
1717

18-
interface AllProps {
18+
type Props = {
1919
store: EnhancedStore<RootState>;
20-
}
20+
};
2121

2222
const queryClient = new QueryClient({
2323
defaultOptions: {
@@ -30,27 +30,30 @@ const queryClient = new QueryClient({
3030
},
3131
});
3232

33-
function App(props: AllProps) {
33+
export default (props: Props) => {
3434
const { isDarkTheme } = useContext(ThemeContext);
3535
const { store } = props;
3636

37-
const ackeeEnvironment = {
37+
/////
38+
// ackee
39+
/////
40+
const ackeeEnv = {
3841
server: import.meta.env.VITE_ACKEE_SERVER,
3942
domainId: import.meta.env.VITE_ACKEE_DOMAIN_ID,
4043
};
4144

42-
if (
43-
ackeeEnvironment.server &&
44-
ackeeEnvironment.server.length > 0 &&
45-
ackeeEnvironment.domainId
46-
) {
47-
useAckee("/", ackeeEnvironment, {
45+
if (ackeeEnv.server && ackeeEnv.server.length > 0 && ackeeEnv.domainId) {
46+
// biome-ignore lint/correctness/useHookAtTopLevel: useAckee depends on env, which is immutable.
47+
useAckee("/", ackeeEnv, {
4848
detailed: true,
4949
ignoreLocalhost: true,
5050
ignoreOwnVisits: true,
5151
});
5252
}
5353

54+
// to render
55+
const themeAlg = isDarkTheme ? theme.darkAlgorithm : theme.defaultAlgorithm;
56+
5457
return (
5558
<>
5659
<Provider store={store}>
@@ -59,9 +62,7 @@ function App(props: AllProps) {
5962
<QueryClientProvider client={queryClient}>
6063
<ConfigProvider
6164
theme={{
62-
algorithm: isDarkTheme
63-
? theme.darkAlgorithm
64-
: theme.defaultAlgorithm,
65+
algorithm: themeAlg,
6566
token: {
6667
// var(--pf-v5-global--primary-color--200)
6768
colorSuccess: "#004080",
@@ -87,6 +88,4 @@ function App(props: AllProps) {
8788
</Provider>
8889
</>
8990
);
90-
}
91-
92-
export default App;
91+
};

0 commit comments

Comments
 (0)