changes
This commit is contained in:
parent
11cc3c58b6
commit
10477e0932
@ -543,7 +543,14 @@ const MatrimonyProfile = ({ data, onRefresh }) => {
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex justify-start gap-3 mt-4">
|
||||
{profile.is_send_interest_received && profile.statusReceived?.toLowerCase() === 'pending' ? (
|
||||
{profile.is_blocked ? (
|
||||
<button
|
||||
onClick={handleUnblock}
|
||||
className="w-[fit-content] flex items-center justify-center gap-2 py-2 px-8 bg-gray-500 text-white rounded-full font-bold text-sm hover:bg-gray-600 transition-all active:scale-[0.98]"
|
||||
>
|
||||
<Ban size={18} /> Unblock Profile
|
||||
</button>
|
||||
) : profile.is_send_interest_received && profile.statusReceived?.toLowerCase() === 'pending' ? (
|
||||
<>
|
||||
<button
|
||||
onClick={handleSendInterest}
|
||||
|
||||
@ -13,16 +13,19 @@ import {
|
||||
CheckCircle,
|
||||
XCircle,
|
||||
Clock,
|
||||
Sparkles
|
||||
Sparkles,
|
||||
Ban,
|
||||
Flag
|
||||
} from "lucide-react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { getInterestList, updateInterestStatus } from "../services/profileActionApi";
|
||||
import { blockProfile, reportProfile, getInterestList, updateInterestStatus } from "../services/profileActionApi";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import axiosInstance, { apiForFiles } from "../api/axiosInstance";
|
||||
import { API_ENDPOINTS } from "../api/apiEndpoints";
|
||||
import { sendMessage } from "../services/chatApi";
|
||||
import UpgradeModal from "../components/common/UpgradeModal";
|
||||
import ReportModel from "../feature/ReportModel";
|
||||
|
||||
|
||||
const InterestSendPage = () => {
|
||||
@ -194,6 +197,7 @@ const InterestSendPage = () => {
|
||||
profile={profile}
|
||||
tabIndex={selectedTabIndex}
|
||||
onStatusUpdate={handleStatusUpdate}
|
||||
onRefresh={fetchInterests}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@ -208,7 +212,7 @@ const InterestSendPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const ProfileCard = ({ profile, tabIndex, onStatusUpdate }) => {
|
||||
const ProfileCard = ({ profile, tabIndex, onStatusUpdate, onRefresh }) => {
|
||||
const navigate = useNavigate();
|
||||
const [isUpgradeModalOpen, setIsUpgradeModalOpen] = useState(false);
|
||||
const [isViewContactModalOpen, setIsViewContactModalOpen] = useState(false);
|
||||
@ -218,6 +222,10 @@ const ProfileCard = ({ profile, tabIndex, onStatusUpdate }) => {
|
||||
const [isInterestRejectedModalOpen, setIsInterestRejectedModalOpen] = useState(false);
|
||||
const [unlockedMobile, setUnlockedMobile] = useState(null);
|
||||
const [isCreatingChat, setIsCreatingChat] = useState(false);
|
||||
const [showMenu, setShowMenu] = useState(false);
|
||||
const [reportModalOpen, setReportModalOpen] = useState(false);
|
||||
const [reportActionType, setReportActionType] = useState("report");
|
||||
|
||||
|
||||
// New state for Accept/Reject confirmation
|
||||
const [statusConfirm, setStatusConfirm] = useState({ open: false, status: null });
|
||||
@ -324,9 +332,47 @@ const ProfileCard = ({ profile, tabIndex, onStatusUpdate }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const openReportModal = (type) => {
|
||||
setReportActionType(type);
|
||||
setReportModalOpen(true);
|
||||
setShowMenu(false);
|
||||
};
|
||||
|
||||
const handleReportAction = async (reason) => {
|
||||
try {
|
||||
if (reportActionType === 'report') {
|
||||
const res = await reportProfile(profile.id, reason);
|
||||
toast.success(res?.message || "Profile Reported successfully");
|
||||
} else {
|
||||
const res = await blockProfile(profile.id, reason);
|
||||
toast.success(res?.message || "Profile Blocked successfully");
|
||||
}
|
||||
if (onRefresh) onRefresh(false);
|
||||
} catch (error) {
|
||||
toast.error(error?.message || `Failed to ${reportActionType === 'report' ? 'Report' : 'Block'}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUnblock = async () => {
|
||||
try {
|
||||
// Calling the same blockProfile API without a model/reason to trigger unblocking
|
||||
const res = await blockProfile(profile.id, "");
|
||||
toast.success(res?.message || "Profile Unblocked successfully");
|
||||
if (onRefresh) onRefresh(false);
|
||||
} catch (error) {
|
||||
toast.error(error?.message || "Failed to Unblock");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<ReportModel
|
||||
open={reportModalOpen}
|
||||
onClose={() => setReportModalOpen(false)}
|
||||
onSubmit={handleReportAction}
|
||||
actionType={reportActionType}
|
||||
/>
|
||||
<div
|
||||
onClick={() => navigate(`/profile-details/${profile.id}`)}
|
||||
className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden hover:shadow-md transition-shadow cursor-pointer p-4"
|
||||
@ -351,9 +397,54 @@ const ProfileCard = ({ profile, tabIndex, onStatusUpdate }) => {
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex justify-between items-start mb-1">
|
||||
<h3 className="text-lg font-bold text-gray-900 truncate pr-2">{profile.name}</h3>
|
||||
<button className="p-1 hover:bg-gray-100 rounded-full">
|
||||
{/* <button className="p-1 hover:bg-gray-100 rounded-full">
|
||||
<MoreVertical className="w-5 h-5 text-gray-400" />
|
||||
</button> */}
|
||||
<div className="relative">
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowMenu(!showMenu);
|
||||
}}
|
||||
className="p-2 hover:bg-gray-100 rounded-full transition-colors"
|
||||
>
|
||||
<svg
|
||||
className="w-6 h-6"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 20 20"
|
||||
>
|
||||
<path d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" />
|
||||
</svg>
|
||||
</button>
|
||||
{showMenu && (
|
||||
<div className="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-xl border z-10" onClick={(e) => e.stopPropagation()}>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowMenu(false);
|
||||
if (profile.is_blocked) {
|
||||
handleUnblock();
|
||||
} else {
|
||||
openReportModal('block');
|
||||
}
|
||||
}}
|
||||
className="w-full px-4 py-3 text-left hover:bg-gray-50 flex items-center gap-3"
|
||||
>
|
||||
<Ban className="w-4 h-4" /> {profile.is_blocked ? "Unblock Profile" : "Block Profile"}
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowMenu(false);
|
||||
openReportModal('report');
|
||||
}}
|
||||
className="w-full px-4 py-3 text-left hover:bg-gray-50 flex items-center gap-3 text-red-600"
|
||||
>
|
||||
<Flag className="w-4 h-4" /> Report Profile
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1 mb-3">
|
||||
@ -392,7 +483,14 @@ const ProfileCard = ({ profile, tabIndex, onStatusUpdate }) => {
|
||||
|
||||
{/* Action Buttons based on Tab */}
|
||||
<div className="mt-4 flex gap-3">
|
||||
{tabIndex === 0 && profile.statusReceived === 'pending' ? (
|
||||
{profile.is_blocked ? (
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleUnblock(); }}
|
||||
className="flex-1 py-2 rounded-lg font-bold bg-gray-500 text-white hover:bg-gray-600 transition-all flex items-center justify-center gap-2"
|
||||
>
|
||||
<Ban className="w-5 h-5" /> Unblock Profile
|
||||
</button>
|
||||
) : tabIndex === 0 && profile.statusReceived === 'pending' ? (
|
||||
<>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); setStatusConfirm({ open: true, status: 'reject' }); }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user