Skip to content

Commit

Permalink
#1 feat: [ Setup] Setup code React + Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Nov 10, 2023
1 parent a85c1a5 commit 256356c
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# APP
NODE_ENV='dev'

# FIREBASE
API_KEY='AIzaSyB8pGeybQakGG65sNuXDNXXPhSUJj431Tg'
AUTH_DOMAIN='class-react-d5c6b.firebaseapp.com'
DATABASE_URL=''
PROJECT_ID='class-react-d5c6b'
STORAGE_BUCKET='class-react-d5c6b.appspot.com'
MESSAGE_SENDER_ID='870565752408'
APP_ID='1:870565752408:web:a1a365631866f80094a42d'
APP_ID='1:870565752408:web:a1a365631866f80094a42d'

39 changes: 38 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.7",
"firebase": "^10.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
1 change: 0 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useRoutes } from "react-router-dom";
import Route from "@/routers";

const App = () => {
console.log(process.env.API_KEY);
return useRoutes(Route);
};

Expand Down
4 changes: 4 additions & 0 deletions src/common/constants/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const NODE_APP = {
DEV: "dev",
PRO: "pro",
};
10 changes: 7 additions & 3 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
//* LIB
import ReactDOM from "react-dom/client";
import { Provider } from "react-redux";
import { BrowserRouter as Router } from "react-router-dom";

//* IMPORT
import App from "./App.jsx";
import store from "./redux/store.jsx";

ReactDOM.createRoot(document.getElementById("root")).render(
<Router>
<App />
</Router>
<Provider store={store}>
<Router>
<App />
</Router>
</Provider>
);
24 changes: 24 additions & 0 deletions src/redux/auth/authSlice.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//* LIB
import { createSlice } from "@reduxjs/toolkit";

const initialState = {
authData: null,
isLoading: false,
error: null,
};

const AuthSlice = createSlice({
name: "auth",
initialState,
reducers: {
resetDataAuth: (state) => {
return state;
},
},
extraReducers: {},
});
const AuthReducer = AuthSlice.reducer;
// eslint-disable-next-line react-refresh/only-export-components
export const { resetDataAuth } = AuthSlice.actions;

export default AuthReducer;
24 changes: 24 additions & 0 deletions src/redux/store.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//* LIB
import { combineReducers, configureStore } from "@reduxjs/toolkit";
import logger from "redux-logger";
import thunk from "redux-thunk";

//* IMPORT
import AuthReducer from "./auth/authSlice";
import { NODE_APP } from "@/common/constants";

const middleware = [thunk];

const checkLogDev = process.env.NODE_ENV === NODE_APP.DEV;
if (checkLogDev) {
middleware.push(logger);
}

const reducer = combineReducers({
auth: AuthReducer,
});

const store = configureStore({
reducer: reducer,
});
export default store;

0 comments on commit 256356c

Please sign in to comment.