Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
README.md
.gitignore
21 changes: 21 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:alpine


# Create app directory
WORKDIR /mentor_mentee_app


# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY ./package.json /mentor_mentee_app

RUN npm install
# If you are building your code for production
# RUN npm ci --omit=dev

# Bundle app source
COPY . /mentor_mentee_app/

EXPOSE 5173
CMD npm run dev -- --host
101 changes: 101 additions & 0 deletions dist/assets/index-63bb8e50.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/assets/index-716dd03b.css

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

16 changes: 16 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<title>Product</title>
<script type="module" crossorigin src="/assets/index-63bb8e50.js"></script>
<link rel="stylesheet" href="/assets/index-716dd03b.css">
</head>
<body>
<div id="root"></div>

</body>
</html>
1 change: 1 addition & 0 deletions dist/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import {useDispatch, useSelector} from 'react-redux';
import { addData } from "./features/getSlice";
import Data from "./pages/Data";
import { useEffect } from "react";
import { getMobileList } from './services/mobileAction';

function App() {
const dispatch = useDispatch();
const apiData = useSelector((state) => state.getData);
async function getApi(){
const res = await axios.get('https://dummyjson.com/products');
const data = await res.data.products;
dispatch(addData(data))
}

const apiData = useSelector((state) => state.phoneReducer.phoneList);
// async function getApi(){
// const res = await axios.get('https://dummyjson.com/products');
// const data = await res.data.products;
// dispatch(addData(data))
// }
console.log(apiData, '>>>>>>>>>>>>>>>>>>>>>>>>');
useEffect(() => {
getApi();
console.log('LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL');
dispatch( getMobileList())
},[])
return (
<div className="App">
Expand Down
4 changes: 4 additions & 0 deletions src/pages/About.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const About = () => {
<div className="text-center m-auto">
<Navbar/>
<h1 className= "mt-20 text-2xl">About</h1>

<body>
<h1>Curious Ecosystem</h1>
</body>
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Contact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Contact = () => {
<div className="text-center m-auto">
<Navbar/>
<h1 className= "mt-20 text-2xl">Contact</h1>
<h1>This is Contact Page</h1>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Data = ({apiData}) => {
return (
<div>
<ul>
{apiData[0]?.map(data => (
{apiData?.map(data => (
<li key = {data.id}>{data.title}</li>
))}
</ul>
Expand Down
20 changes: 20 additions & 0 deletions src/reducers/phoneReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createSlice } from "@reduxjs/toolkit";
import { getMobileList } from "../services/mobileAction";

const initialState = {
phoneList: []
}
const phoneReducer = createSlice({
name: 'phone',
initialState,
extraReducers : ( builder) => {
builder.addCase( getMobileList.fulfilled, (state, action ) => {
state.phoneList = action.payload.data.products

})
}
});

export default phoneReducer.reducer;


11 changes: 11 additions & 0 deletions src/services/mobileAction.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from "axios";

export const getMobileList = createAsyncThunk(
'mobile-phone',
async () => {
console.log('KKKKKKKKKKKKKKKKKK');
const res = await axios.get('https://dummyjson.com/products');
return res;
}
)
4 changes: 2 additions & 2 deletions src/store/store.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { configureStore } from '@reduxjs/toolkit';
import getSlice from '../features/getSlice';
import phoneReducer from '../reducers/phoneReducer';

export const store = configureStore({
reducer: {
getData : getSlice
phoneReducer
},
})
10 changes: 10 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],

//below config is required to map the port between Docker container and your React app
server: {
host: true, // needed for the Docker Container port mapping to work
strictPort: true,
port: 5173, // you can replace this port with any port
watch: {
usePolling: true,
}
}
})