Changes DailyRecommended
This commit is contained in:
parent
5e1afc5ccc
commit
c2e8276d5f
@ -2,12 +2,13 @@ import { useRef, useState, useEffect } from 'react';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { Swiper, SwiperSlide } from 'swiper/react';
|
||||
import { Navigation, Pagination, Autoplay, EffectCoverflow } from 'swiper/modules';
|
||||
import { Crown, Bookmark, X, ChevronLeft, ChevronRight, RotateCcw, Heart, Timer } from 'lucide-react';
|
||||
import { Crown, Bookmark, X, Ban, ChevronLeft, ChevronRight, RotateCcw, Heart, Timer } from 'lucide-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import axiosInstance from "../../api/axiosInstance";
|
||||
import { API_ENDPOINTS } from "../../api/apiEndpoints";
|
||||
import { sendInterest, shortlistProfile } from '../../services/shortlistapi';
|
||||
import { unblockProfile } from '../../services/profileActionApi';
|
||||
import UpgradeModal from '../common/UpgradeModal';
|
||||
|
||||
// Custom Icons
|
||||
@ -16,7 +17,8 @@ import religionIcon from "../../assets/images/religonicon.svg";
|
||||
import locationIcon from "../../assets/images/locationicon.svg";
|
||||
import cashIcon from "../../assets/images/cashicon.svg";
|
||||
import SchoolIcon from "@mui/icons-material/School";
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getHeaderDetails } from "../../api/preview.api";
|
||||
|
||||
// Import Swiper styles
|
||||
import 'swiper/css';
|
||||
@ -100,9 +102,6 @@ const CountdownTimer = ({ onContinue }) => {
|
||||
);
|
||||
};
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getHeaderDetails } from "../../api/preview.api";
|
||||
|
||||
const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
|
||||
const swiperRef = useRef(null);
|
||||
const navigate = useNavigate();
|
||||
@ -119,6 +118,7 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
|
||||
staleTime: 60000,
|
||||
});
|
||||
|
||||
console.log("Header Data:", headerData);
|
||||
const isUserPaid = headerData?.myDetails?.is_paid_member === true;
|
||||
|
||||
useEffect(() => {
|
||||
@ -165,6 +165,17 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleUnblock = async (e, profileId) => {
|
||||
e.stopPropagation();
|
||||
try {
|
||||
const res = await unblockProfile(profileId);
|
||||
toast.success(res?.message || "Profile unblocked successfully");
|
||||
setActiveProfiles(prev => prev.map(p => p.id === profileId ? { ...p, is_blocked: 0 } : p));
|
||||
} catch (error) {
|
||||
toast.error(error?.message || "Failed to unblock profile.");
|
||||
}
|
||||
};
|
||||
|
||||
const ProfileCard = ({ profile }) => {
|
||||
const image = profile.photo || profile.image;
|
||||
const memberId = profile.member_id || profile.userId;
|
||||
@ -211,18 +222,20 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
<motion.button
|
||||
whileTap={{ scale: 0.9 }}
|
||||
className="absolute top-4 right-4 z-10 bg-white/90 backdrop-blur-sm rounded-full px-4 py-2 shadow-md flex items-center space-x-2 hover:bg-white transition-colors"
|
||||
onClick={handleShortlistClick}
|
||||
>
|
||||
<Bookmark
|
||||
className={`w-4 h-4 transition-colors ${isShortlisted ? "text-black fill-black" : "text-green-700"}`}
|
||||
/>
|
||||
<span className="text-[12px] font-bold text-gray-700">
|
||||
{isShortlisted ? "Shortlisted" : "Shortlist"}
|
||||
</span>
|
||||
</motion.button>
|
||||
{!profile.is_blocked && (
|
||||
<motion.button
|
||||
whileTap={{ scale: 0.9 }}
|
||||
className="absolute top-4 right-4 z-10 bg-white/90 backdrop-blur-sm rounded-full px-4 py-2 shadow-md flex items-center space-x-2 hover:bg-white transition-colors"
|
||||
onClick={handleShortlistClick}
|
||||
>
|
||||
<Bookmark
|
||||
className={`w-4 h-4 transition-colors ${isShortlisted ? "text-black fill-black" : "text-green-700"}`}
|
||||
/>
|
||||
<span className="text-[12px] font-bold text-gray-700">
|
||||
{isShortlisted ? "Shortlisted" : "Shortlist"}
|
||||
</span>
|
||||
</motion.button>
|
||||
)}
|
||||
|
||||
<div className="bg-gray-200 overflow-hidden w-full h-[300px]">
|
||||
<img
|
||||
@ -298,18 +311,29 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
|
||||
)}
|
||||
|
||||
<div className="flex gap-3 pt-4 justify-between">
|
||||
<button
|
||||
onClick={(e) => handleDecline(e, profile.id)}
|
||||
className="flex-1 px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-600 font-bold text-sm rounded-full transition-all flex items-center justify-center gap-2 active:scale-95"
|
||||
>
|
||||
<X size={16} /> Decline
|
||||
</button>
|
||||
<button
|
||||
className="flex-1 px-4 py-2 bg-[#034E08] hover:bg-green-800 text-white font-bold text-sm rounded-full transition-all flex items-center justify-center gap-2 shadow-lg shadow-green-900/20 active:scale-95"
|
||||
onClick={(e) => handleInterest(e, profile.id, profile.name)}
|
||||
>
|
||||
<Heart size={16} fill="white" /> Interest
|
||||
</button>
|
||||
{profile.is_blocked ? (
|
||||
<button
|
||||
onClick={(e) => handleUnblock(e, profile.id)}
|
||||
className="flex-1 px-4 py-2 bg-[#DF1D46] hover:bg-red-600 text-white font-bold text-sm rounded-full transition-all flex items-center justify-center gap-2 shadow-lg shadow-red-900/20 active:scale-95"
|
||||
>
|
||||
<Ban size={16} /> Unblock Profile
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
onClick={(e) => handleDecline(e, profile.id)}
|
||||
className="flex-1 px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-600 font-bold text-sm rounded-full transition-all flex items-center justify-center gap-2 active:scale-95"
|
||||
>
|
||||
<X size={16} /> Decline
|
||||
</button>
|
||||
<button
|
||||
className="flex-1 px-4 py-2 bg-[#034E08] hover:bg-green-800 text-white font-bold text-sm rounded-full transition-all flex items-center justify-center gap-2 shadow-lg shadow-green-900/20 active:scale-95"
|
||||
onClick={(e) => handleInterest(e, profile.id, profile.name)}
|
||||
>
|
||||
<Heart size={16} fill="white" /> Interest
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
@ -49,6 +49,7 @@ const MatrimonyProfile = ({ data, onRefresh }) => {
|
||||
if (!data) return null;
|
||||
|
||||
const profile = data.profile;
|
||||
console.log("profile",profile);
|
||||
const personal = data.personalDetails;
|
||||
const family = data.familyDetails;
|
||||
const education = data.educationalDetails;
|
||||
@ -344,7 +345,6 @@ const MatrimonyProfile = ({ data, onRefresh }) => {
|
||||
|
||||
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);
|
||||
@ -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={(e) => { e.stopPropagation(); handleUnblock(); }}
|
||||
className="w-[fit-content] flex items-center justify-center gap-2 py-2.5 px-10 bg-[#DF1D46] text-white rounded-full font-bold text-sm hover:bg-red-600 transition-all active:scale-[0.98] shadow-lg shadow-red-900/10"
|
||||
>
|
||||
<Ban size={18} /> Unblock Profile
|
||||
</button>
|
||||
) : profile.is_send_interest_received && profile.statusReceived?.toLowerCase() === 'pending' ? (
|
||||
<>
|
||||
<button
|
||||
onClick={handleSendInterest}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user