Changes DailyRecommended

This commit is contained in:
Nagarajan 2026-04-30 12:00:31 +05:30
parent 5e1afc5ccc
commit c2e8276d5f
2 changed files with 62 additions and 31 deletions

View File

@ -2,12 +2,13 @@ import { useRef, useState, useEffect } from 'react';
import { motion, AnimatePresence } from 'framer-motion'; import { motion, AnimatePresence } from 'framer-motion';
import { Swiper, SwiperSlide } from 'swiper/react'; import { Swiper, SwiperSlide } from 'swiper/react';
import { Navigation, Pagination, Autoplay, EffectCoverflow } from 'swiper/modules'; 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 { useNavigate } from 'react-router-dom';
import { toast } from 'react-hot-toast'; import { toast } from 'react-hot-toast';
import axiosInstance from "../../api/axiosInstance"; import axiosInstance from "../../api/axiosInstance";
import { API_ENDPOINTS } from "../../api/apiEndpoints"; import { API_ENDPOINTS } from "../../api/apiEndpoints";
import { sendInterest, shortlistProfile } from '../../services/shortlistapi'; import { sendInterest, shortlistProfile } from '../../services/shortlistapi';
import { unblockProfile } from '../../services/profileActionApi';
import UpgradeModal from '../common/UpgradeModal'; import UpgradeModal from '../common/UpgradeModal';
// Custom Icons // Custom Icons
@ -16,7 +17,8 @@ import religionIcon from "../../assets/images/religonicon.svg";
import locationIcon from "../../assets/images/locationicon.svg"; import locationIcon from "../../assets/images/locationicon.svg";
import cashIcon from "../../assets/images/cashicon.svg"; import cashIcon from "../../assets/images/cashicon.svg";
import SchoolIcon from "@mui/icons-material/School"; import SchoolIcon from "@mui/icons-material/School";
import { useQuery } from '@tanstack/react-query';
import { getHeaderDetails } from "../../api/preview.api";
// Import Swiper styles // Import Swiper styles
import 'swiper/css'; 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 DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
const swiperRef = useRef(null); const swiperRef = useRef(null);
const navigate = useNavigate(); const navigate = useNavigate();
@ -119,6 +118,7 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
staleTime: 60000, staleTime: 60000,
}); });
console.log("Header Data:", headerData);
const isUserPaid = headerData?.myDetails?.is_paid_member === true; const isUserPaid = headerData?.myDetails?.is_paid_member === true;
useEffect(() => { 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 ProfileCard = ({ profile }) => {
const image = profile.photo || profile.image; const image = profile.photo || profile.image;
const memberId = profile.member_id || profile.userId; const memberId = profile.member_id || profile.userId;
@ -211,18 +222,20 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
</motion.div> </motion.div>
)} )}
<motion.button {!profile.is_blocked && (
whileTap={{ scale: 0.9 }} <motion.button
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" whileTap={{ scale: 0.9 }}
onClick={handleShortlistClick} 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"}`} <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 className="text-[12px] font-bold text-gray-700">
</span> {isShortlisted ? "Shortlisted" : "Shortlist"}
</motion.button> </span>
</motion.button>
)}
<div className="bg-gray-200 overflow-hidden w-full h-[300px]"> <div className="bg-gray-200 overflow-hidden w-full h-[300px]">
<img <img
@ -298,18 +311,29 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
)} )}
<div className="flex gap-3 pt-4 justify-between"> <div className="flex gap-3 pt-4 justify-between">
<button {profile.is_blocked ? (
onClick={(e) => handleDecline(e, profile.id)} <button
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" 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"
<X size={16} /> Decline >
</button> <Ban size={16} /> Unblock Profile
<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)} <>
> <button
<Heart size={16} fill="white" /> Interest onClick={(e) => handleDecline(e, profile.id)}
</button> 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>
</div> </div>
</motion.div> </motion.div>

View File

@ -49,6 +49,7 @@ const MatrimonyProfile = ({ data, onRefresh }) => {
if (!data) return null; if (!data) return null;
const profile = data.profile; const profile = data.profile;
console.log("profile",profile);
const personal = data.personalDetails; const personal = data.personalDetails;
const family = data.familyDetails; const family = data.familyDetails;
const education = data.educationalDetails; const education = data.educationalDetails;
@ -344,7 +345,6 @@ const MatrimonyProfile = ({ data, onRefresh }) => {
const handleUnblock = async () => { const handleUnblock = async () => {
try { try {
// Calling the same blockProfile API without a model/reason to trigger unblocking
const res = await blockProfile(profile.id, ""); const res = await blockProfile(profile.id, "");
toast.success(res?.message || "Profile Unblocked successfully"); toast.success(res?.message || "Profile Unblocked successfully");
if (onRefresh) onRefresh(false); if (onRefresh) onRefresh(false);
@ -543,7 +543,14 @@ const MatrimonyProfile = ({ data, onRefresh }) => {
{/* Action Buttons */} {/* Action Buttons */}
<div className="flex justify-start gap-3 mt-4"> <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 <button
onClick={handleSendInterest} onClick={handleSendInterest}