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