Skip to content

Commit

Permalink
feat: profile reducer created
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank-dev07 committed Nov 6, 2024
1 parent 0eb0a9a commit 7025239
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 24 deletions.
80 changes: 80 additions & 0 deletions src/app/Redux/Features/profile/profileSlice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"use client";
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { set } from "react-hook-form";

type Profilestate = {
who: string;
image: string;
name: string;
link: string;
description: string;
github: string;
twitter: string;
telegram: string;
discord: string;
};

const initialState: Profilestate = {
who: "",
image: "",
name: "",
link: "",
description: "",
github: "",
twitter: "",
telegram: "",
discord: "",
};

export const profileSlice = createSlice({
name: "profile",
initialState,
reducers: {
setUser: (state, action: PayloadAction<Profilestate>) => {
return { ...state, ...action.payload };
},
setWho: (state, action: PayloadAction<string>) => {
state.who = action.payload;
},
setImage: (state, action: PayloadAction<string>) => {
state.image = action.payload;
},
setName: (state, action: PayloadAction<string>) => {
state.name = action.payload;
},
setLink: (state, action: PayloadAction<string>) => {
state.link = action.payload;
},
setDescription: (state, action: PayloadAction<string>) => {
state.description = action.payload;
},
setGithub: (state, action: PayloadAction<string>) => {
state.github = action.payload;
},
setTwitter: (state, action: PayloadAction<string>) => {
state.twitter = action.payload;
},
setTelegram: (state, action: PayloadAction<string>) => {
state.telegram = action.payload;
},
setDiscord: (state, action: PayloadAction<string>) => {
state.discord = action.payload;
},
resetProfile: () => initialState,
},
});

export const {
setUser,
setImage,
setWho,
setName,
setLink,
setDescription,
setGithub,
setTwitter,
setTelegram,
setDiscord,
resetProfile,
} = profileSlice.actions;
export const profileReducer = profileSlice.reducer;
2 changes: 2 additions & 0 deletions src/app/Redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { errorReducer } from "./Features/error/error";
import { searchReducer } from "./Features/git/search";
import userReducer from "./Features/user/userSlice";
import counterReducer from "./Features/loader/loaderSlice";
import { profileReducer } from "./Features/profile/profileSlice";

export const store = configureStore({
reducer: {
Expand All @@ -19,6 +20,7 @@ export const store = configureStore({
search: searchReducer,
repoData: repoReducer,
counter: counterReducer,
profile: profileReducer,
},
});

Expand Down
24 changes: 0 additions & 24 deletions src/components/ui/textarea.tsx

This file was deleted.

0 comments on commit 7025239

Please sign in to comment.