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 { 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,6 +222,7 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
</motion.div>
)}
{!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"
@ -223,6 +235,7 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
{isShortlisted ? "Shortlisted" : "Shortlist"}
</span>
</motion.button>
)}
<div className="bg-gray-200 overflow-hidden w-full h-[300px]">
<img
@ -298,6 +311,15 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
)}
<div className="flex gap-3 pt-4 justify-between">
{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"
@ -310,6 +332,8 @@ const DailyRecommendedCard = ({ profiles: initialProfiles = [] }) => {
>
<Heart size={16} fill="white" /> Interest
</button>
</>
)}
</div>
</div>
</motion.div>

View File

@ -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}