fix some APIs
This commit is contained in:
parent
5fa4ebfb04
commit
2c55926f49
|
|
@ -19,8 +19,9 @@ const CafeManagement = () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await cafeService.getCafeList();
|
const res = await cafeService.getCafeList();
|
||||||
if (res.data.success && res.data.data) {
|
console.log("🔄 Fetching cafes:", res?.data?.data?.data);
|
||||||
setCafes(res.data.data);
|
if (res.data.success && res?.data?.data?.data) {
|
||||||
|
setCafes(res?.data?.data?.data);
|
||||||
console.log("✅ Cafes loaded successfully:", res.data);
|
console.log("✅ Cafes loaded successfully:", res.data);
|
||||||
} else {
|
} else {
|
||||||
setError("دادههای دریافتی معتبر نیست");
|
setError("دادههای دریافتی معتبر نیست");
|
||||||
|
|
@ -85,37 +86,40 @@ const CafeManagement = () => {
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{cafes.map((cafe) => (
|
{cafes.map((cafe) => (
|
||||||
<tr key={cafe._id} className="border-b border-[#EFEEEE] hover:bg-hover transition-colors">
|
<tr key={cafe?._id} className="border-b border-[#EFEEEE] hover:bg-hover transition-colors">
|
||||||
<td className="px-4 py-4 text-right">
|
<td className="px-4 py-4 text-right">
|
||||||
<img
|
<img
|
||||||
src={cafe.photo || Pic1}
|
src={cafe?.photo || Pic1}
|
||||||
alt={cafe.Name}
|
alt={cafe?.Name}
|
||||||
className="w-10 h-10 rounded-full object-cover"
|
className="w-10 h-10 rounded-full object-cover"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-4 text-right text-[#402E32] font-medium text-sm whitespace-nowrap">
|
<td className="px-4 py-4 text-right text-[#402E32] font-medium text-sm whitespace-nowrap">
|
||||||
{cafe.Name}
|
{cafe?.Name}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-4 text-right text-[#402E32] text-sm max-w-xs overflow-hidden text-ellipsis">
|
<td className="px-4 py-4 text-right text-[#402E32] text-sm max-w-xs overflow-hidden text-ellipsis">
|
||||||
{cafe.address}
|
{cafe?.address}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-4 text-right">
|
<td className="px-4 py-4 text-right">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex flex-col gap-1">
|
||||||
<img src={Star1} alt="rating" className="w-5 h-5" />
|
<div className="flex items-center gap-1">
|
||||||
<span className="text-[#402E32] text-sm">{cafe.rating || 0}</span>
|
<img src={Star1} alt="rating" className="w-4 h-4" />
|
||||||
|
<span className="text-[#402E32]">{cafe?.rating || 0}</span>
|
||||||
|
</div>
|
||||||
|
<span className="block">از {cafe?.ratingCount} نفر</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-4 text-right">
|
<td className="px-4 py-4 text-right">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<img src={Group} alt="time" className="w-5 h-5" />
|
<img src={Group} alt="time" className="w-5 h-5" />
|
||||||
<span className="text-[#402E32] text-sm whitespace-nowrap">
|
<span className="text-[#402E32] text-sm whitespace-nowrap">
|
||||||
{cafe.openinghour || "نامشخص"}
|
{cafe?.openinghour || "نامشخص"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-4 text-center">
|
<td className="px-4 py-4 text-center">
|
||||||
<Link
|
<Link
|
||||||
to={`/edit-cafe/${cafe._id}`}
|
to={`/edit-cafe/${cafe?._id}`}
|
||||||
className="inline-flex items-center justify-center gap-2 border-2 border-[#BB8F70] px-6 py-2 rounded-3xl text-sm font-light text-text1 hover:bg-button1 hover:border-button1 transition-all duration-300"
|
className="inline-flex items-center justify-center gap-2 border-2 border-[#BB8F70] px-6 py-2 rounded-3xl text-sm font-light text-text1 hover:bg-button1 hover:border-button1 transition-all duration-300"
|
||||||
>
|
>
|
||||||
<span>ادیت</span>
|
<span>ادیت</span>
|
||||||
|
|
@ -132,40 +136,43 @@ const CafeManagement = () => {
|
||||||
<div className="lg:hidden mt-6 space-y-4">
|
<div className="lg:hidden mt-6 space-y-4">
|
||||||
{cafes.map((cafe) => (
|
{cafes.map((cafe) => (
|
||||||
<div
|
<div
|
||||||
key={cafe._id}
|
key={cafe?._id}
|
||||||
className="bg-white border-2 border-[#8b8886] rounded-xl p-4"
|
className="bg-white border-2 border-[#8b8886] rounded-xl p-4"
|
||||||
>
|
>
|
||||||
<div className="flex items-start gap-4 mb-4">
|
<div className="flex items-start gap-4 mb-4">
|
||||||
<img
|
<img
|
||||||
src={cafe.photo || Pic1}
|
src={cafe?.photo || Pic1}
|
||||||
alt={cafe.Name}
|
alt={cafe?.Name}
|
||||||
className="w-16 h-16 rounded-full object-cover flex-shrink-0"
|
className="w-16 h-16 rounded-full object-cover flex-shrink-0"
|
||||||
/>
|
/>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<h3 className="font-bold text-[#402E32] mb-1 text-sm">
|
<h3 className="font-bold text-[#402E32] mb-1 text-sm">
|
||||||
{cafe.Name}
|
{cafe?.Name}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-gray-600 truncate">
|
<p className="text-xs text-gray-600 truncate">
|
||||||
{cafe.address}
|
{cafe?.address}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between mb-4 text-xs gap-4">
|
<div className="flex items-center justify-between mb-4 text-xs gap-4">
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<img src={Star1} alt="rating" className="w-4 h-4" />
|
<img src={Star1} alt="rating" className="w-4 h-4" />
|
||||||
<span className="text-[#402E32]">{cafe.rating || 0}</span>
|
<span className="text-[#402E32]">{cafe?.rating || 0}</span>
|
||||||
|
</div>
|
||||||
|
<span className="block">از {cafe?.ratingCount} نفر</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<img src={Group} alt="time" className="w-4 h-4" />
|
<img src={Group} alt="time" className="w-4 h-4" />
|
||||||
<span className="text-[#402E32]">
|
<span className="text-[#402E32]">
|
||||||
{cafe.openinghour || "نامشخص"}
|
{cafe?.openinghour || "نامشخص"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
to={`/edit-cafe/${cafe._id}`}
|
to={`/edit-cafe/${cafe?._id}`}
|
||||||
className="flex justify-center items-center gap-2 w-full border-2 border-[#BB8F70] py-2 rounded-full text-sm font-medium text-text1 hover:bg-button1 hover:border-button1 transition-all duration-300"
|
className="flex justify-center items-center gap-2 w-full border-2 border-[#BB8F70] py-2 rounded-full text-sm font-medium text-text1 hover:bg-button1 hover:border-button1 transition-all duration-300"
|
||||||
>
|
>
|
||||||
<span className="">ادیت کافه</span>
|
<span className="">ادیت کافه</span>
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,18 @@ import { setProfile } from "../../redux/slices/profileSlice";
|
||||||
import authService from "../../services/auth";
|
import authService from "../../services/auth";
|
||||||
import toggleTheme from "../../components/ToggleTheme";
|
import toggleTheme from "../../components/ToggleTheme";
|
||||||
import { CgDarkMode } from "react-icons/cg";
|
import { CgDarkMode } from "react-icons/cg";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const token = useSelector((state) => state.auth.token);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (token) {
|
||||||
|
navigate("/dashboard");
|
||||||
|
}
|
||||||
|
}, [token, navigate]);
|
||||||
|
|
||||||
// State Management
|
// State Management
|
||||||
const [userName, setUserName] = useState("");
|
const [userName, setUserName] = useState("");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import requests from "./api/base-api";
|
import requests from "./api/base-api";
|
||||||
|
|
||||||
const cafeService = {
|
const cafeService = {
|
||||||
getCafeList: () => requests.get("/cafe/v1/get-cafe-list"),
|
getCafeList: () => requests.get("/admin/v1/get-cafe-lists"),
|
||||||
editCafe: (id, cafeData) => requests.put(`/cafe/v1/get-cafe-profile-by-cafe/${id}`, cafeData),
|
editCafe: (id, cafeData) => requests.put(`/cafe/v1/get-cafe-profile-by-cafe/${id}`, cafeData),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue