done
This commit is contained in:
parent
b054298296
commit
0d7e7d8ab7
File diff suppressed because one or more lines are too long
|
@ -54,7 +54,7 @@
|
|||
<!-- Custom styles for this template-->
|
||||
<link href="css/sb-admin-2.min.css" rel="stylesheet">
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-BCe6aC64.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-BPQs8JJk.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BH_0_em5.css">
|
||||
</head>
|
||||
|
||||
|
|
|
@ -1,28 +1,20 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { getProperties } from "../../redux/features/propertySlice";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
|
||||
import UserProperties from "./UserProperties";
|
||||
|
||||
const AdminDashboard = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const { properties } = useSelector((state) => state.property);
|
||||
|
||||
// Set pagination state
|
||||
const page = 1;
|
||||
const limit = 10; // Number of results per page
|
||||
const keyword = "";
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
|
||||
|
||||
// State to track selected tab
|
||||
const [selectedTab, setSelectedTab] = useState("dashboard");
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(getProperties({ page, limit, keyword }));
|
||||
}, [dispatch, page, keyword]);
|
||||
|
||||
console.log("properties", properties);
|
||||
|
||||
const renderContent = () => {
|
||||
switch (selectedTab) {
|
||||
|
@ -41,7 +33,16 @@ const AdminDashboard = () => {
|
|||
default:
|
||||
return (
|
||||
<div>
|
||||
|
||||
|
||||
<NavLink to={`/AdminPLogin/admininfo`}>
|
||||
|
||||
Welcome to the Dashboard
|
||||
|
||||
</NavLink>
|
||||
|
||||
|
||||
|
||||
<div
|
||||
className="container-fluid"
|
||||
style={{ padding: "20px", maxwidth: "150%" }}
|
||||
|
|
|
@ -5,7 +5,7 @@ import PropTypes from "prop-types";
|
|||
function ProtectedRoute({ children }) {
|
||||
const navigate = useNavigate();
|
||||
const token = localStorage.getItem("token");
|
||||
console.log("token", token)
|
||||
// console.log("token", token)
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
|
|
|
@ -4,8 +4,8 @@ import { fetchAdminUser } from '../../redux/features/adminSlice';
|
|||
|
||||
const AdminDetails = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { adminuser, loading, error } = useSelector((state) => state.admin);
|
||||
console.log("adminuser", adminuser)
|
||||
const { user, loading, error } = useSelector((state) => state.admin);
|
||||
console.log("user", user)
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchAdminUser());
|
||||
|
@ -16,14 +16,14 @@ const AdminDetails = () => {
|
|||
|
||||
return (
|
||||
<div>
|
||||
|
||||
{adminuser ? (
|
||||
<h2>Admin Details</h2>
|
||||
{user ? (
|
||||
<div>
|
||||
<p><strong>Username:</strong> {adminuser.username}</p>
|
||||
<p><strong>Username:</strong> {user.username}</p>
|
||||
{/* Add other fields here if available in the response */}
|
||||
</div>
|
||||
) : (
|
||||
<p>No admin user details found. Thank you</p>
|
||||
<p>No user details found. Thank you</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
|
||||
import axios from 'axios';
|
||||
|
||||
const BASE_URL = import.meta.env.VITE_REACT_APP_SECRET;
|
||||
|
||||
// Async thunk to fetch admin user details
|
||||
export const fetchAdminUser = createAsyncThunk('admin/fetchAdminUser', async () => {
|
||||
const response = await axios.get('http://localhost:3002/admin/username');
|
||||
const response = await axios.get(`${BASE_URL}/admin/username`);
|
||||
return response.data;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue