This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client"; | |
| import { configureStore } from "@reduxjs/toolkit"; | |
| import userReducer from "./features/userSlice"; | |
| const store = configureStore({ | |
| reducer: { | |
| user: userReducer, | |
| }, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client"; | |
| import React from "react"; | |
| import { Provider } from "react-redux"; | |
| import store from "./Store"; | |
| const CustomProvider = ({ children }) => { | |
| return <Provider store={store}>{children}</Provider>; | |
| }; | |
| export default CustomProvider; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // userSlice.js | |
| import { createSlice } from "@reduxjs/toolkit"; | |
| const initialState = { | |
| userData: {}, | |
| loading: true, | |
| error: null, | |
| }; | |
| const userSlice = createSlice({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client"; | |
| import React, { useState, useEffect } from "react"; | |
| import { useDispatch, useSelector } from "react-redux"; | |
| import { setUserData, setLoading, setError } from "@/redux/features/userSlice"; | |
| import axios from "axios"; | |
| import Link from "next/link"; | |
| import { TbPencilMinus } from "react-icons/tb"; | |
| import SearchBar from "../searchBar/page"; | |
| import Image from "next/image"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect, useState } from "react"; | |
| import { useSelector } from "react-redux"; | |
| import { setUserData } from "@/redux/features/userSlice"; | |
| const UserInitial = () => { | |
| const userData = useSelector(setUserData); | |
| const [user, setUser] = useState(null); | |
| useEffect(() => { | |
| setUser(userData.payload.user.userData.username); | |
| }, []); | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import User from "@/models/userModel"; | |
| import { NextRequest, NextResponse } from "next/server"; | |
| import { connect } from "@/dbConfig/dbConfig"; | |
| import { getDataFromToken } from "@/helpers/jwt"; | |
| connect(); | |
| export async function GET(request: NextRequest) { | |
| try { | |
| const userId: any = await getDataFromToken(request); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState } from 'react'; | |
| function useCounter(initialValue = 0) { | |
| const [count, setCount] = useState(initialValue); | |
| const increment = () => { | |
| setCount(count + 1); | |
| }; | |
| const decrement = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import useCounter from './useCounter'; | |
| function Counter() { | |
| const { count, increment, decrement } = useCounter(); | |
| return ( | |
| <div> | |
| <p>Count: {count}</p> | |
| <button onClick={increment}>Increment</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "./globals.css"; | |
| import { Inter } from "next/font/google"; | |
| import { Toaster } from "react-hot-toast"; | |
| const inter = Inter({ subsets: ["latin"] }); | |
| export const metadata = { | |
| title: "Create Next App", | |
| description: "Generated by create next app", | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { toast } from 'react-hot-toast'; | |
| function MyComponent() { | |
| const handleButtonClick = () => { | |
| toast.success('You did it!'); // Displays a success message | |
| }; | |
| return ( | |
| <div> | |
| <button onClick={handleButtonClick}>Show Success Toast</button> |
OlderNewer