From 78fcf8c8da7188b335929bc05a64c06d44cea611 Mon Sep 17 00:00:00 2001 From: MuhammadShakkeer2030 Date: Fri, 23 Feb 2024 16:50:28 +0530 Subject: [PATCH 1/3] feature: workflow added --- .github/workflow/main.yml | 32 +++++++++++++++++++++++++++++ .vscode/settings.json | 22 ++++++++++++++++++++ app/layout.tsx | 14 ++++++++++--- redux/reducers/DarkReducer.ts | 38 ++++++++++++++++++----------------- redux/store.ts | 30 +++++++++++---------------- 5 files changed, 97 insertions(+), 39 deletions(-) create mode 100644 .github/workflow/main.yml create mode 100644 .vscode/settings.json diff --git a/.github/workflow/main.yml b/.github/workflow/main.yml new file mode 100644 index 0000000..b689aea --- /dev/null +++ b/.github/workflow/main.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: + - main + - feature/workflow + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 20 + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Test + run: npm test diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f0d02c5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#87bfb5", + "activityBar.background": "#87bfb5", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#9859a6", + "activityBarBadge.foreground": "#e7e7e7", + "commandCenter.border": "#15202b99", + "sash.hoverBorder": "#87bfb5", + "statusBar.background": "#66ada0", + "statusBar.foreground": "#15202b", + "statusBarItem.hoverBackground": "#4e9285", + "statusBarItem.remoteBackground": "#66ada0", + "statusBarItem.remoteForeground": "#15202b", + "titleBar.activeBackground": "#66ada0", + "titleBar.activeForeground": "#15202b", + "titleBar.inactiveBackground": "#66ada099", + "titleBar.inactiveForeground": "#15202b99" + }, + "peacock.color": "#66ada0" +} \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index 5ceb2d0..8c314b2 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,10 +1,12 @@ +// "use client" import type { Metadata } from 'next'; import './globals.css' import Navbar from '@/components/Navbar'; import Footer from '@/components/Footer'; // import { store } from '@/redux/store'; -import { Provider } from 'react-redux'; +import { Provider, useSelector } from 'react-redux'; +import { RootState } from '@/redux/store'; export const metadata: Metadata = { title: 'Travel', @@ -13,11 +15,17 @@ export const metadata: Metadata = { export default function RootLayout({ children, + DarkMode }: { - children: React.ReactNode + children: React.ReactNode, + DarkMode:RootState }) { + + // const DarkMode = useSelector((state:RootState)=>state) + console.log(DarkMode) + return ( - + {/* */} diff --git a/redux/reducers/DarkReducer.ts b/redux/reducers/DarkReducer.ts index 0da0c34..118b79b 100644 --- a/redux/reducers/DarkReducer.ts +++ b/redux/reducers/DarkReducer.ts @@ -1,22 +1,24 @@ -// import { createSlice } from '@reduxjs/toolkit'; +const TOGGLE__DARKMODE = "TOGGLE__DARKMODE" -// const initialState = { -// counter: 0, -// }; +const toggleDarkMode=()=>({ + type:TOGGLE__DARKMODE +}) -// export const counterSlice = createSlice({ -// name: 'counter', -// initialState, -// reducers: { -// increment: (state) => { -// state.counter += 1; -// }, -// decrement: (state) => { -// state.counter -= 1; -// }, -// }, -// }); +const initialState:{isEnabled:boolean} = { + isEnabled:false +} -// export const { increment, decrement } = counterSlice.actions; +const DarkReducer=(state=initialState , action:{type:string})=>{ + switch (action.type) { + case TOGGLE__DARKMODE: + return { + ...state, isEnabled: !state.isEnabled + } + + default: + return state + } + +} -// export default counterSlice.reducer; +export default DarkReducer \ No newline at end of file diff --git a/redux/store.ts b/redux/store.ts index 7bb84c0..d2b9b08 100644 --- a/redux/store.ts +++ b/redux/store.ts @@ -1,22 +1,16 @@ -// // store.ts -// import { configureStore } from '@reduxjs/toolkit'; -// import rootReducer from './reducers/DarkReducer'; // Import your reducers +import { combineReducers, configureStore } from "@reduxjs/toolkit"; +import DarkReducer from "./reducers/DarkReducer"; -// export interface RootState { -// // Define your RootState interface here -// dark: ReturnType; -// } +export type DarkState = ReturnType; -// let store: any = null; +export type RootState = { + dark: DarkState; +}; -// if (typeof window !== 'undefined') { -// // This check ensures that the store is only created in the client-side context -// store = configureStore({ -// reducer: rootReducer, -// }); -// } else { -// // In server-side or during pre-rendering, set store to an empty or default value -// store = {}; // Or any default value you want to assign for server-side rendering -// } +const RootReducer = combineReducers({ + dark: DarkReducer, +}); -// export { store }; +export const store = configureStore({ + reducer: RootReducer, +}); From 31f57172c1c9ef78ef4647a2dd4c80665b3d0274 Mon Sep 17 00:00:00 2001 From: MuhammadShakkeer2030 Date: Fri, 23 Feb 2024 16:52:18 +0530 Subject: [PATCH 2/3] fix: spelling changed to workflows --- .github/{workflow => workflows}/main.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/main.yml (100%) diff --git a/.github/workflow/main.yml b/.github/workflows/main.yml similarity index 100% rename from .github/workflow/main.yml rename to .github/workflows/main.yml From d84928c7eb55409970022f715fdd006a8603ec5c Mon Sep 17 00:00:00 2001 From: MuhammadShakkeer2030 Date: Fri, 23 Feb 2024 16:54:15 +0530 Subject: [PATCH 3/3] comment: test step commented on main.yml file --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b689aea..227e34f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,5 +28,5 @@ jobs: - name: Build run: npm run build - - name: Test - run: npm test + # - name: Test + # run: npm test