chore: clean debug logs and harden helper utils

This commit is contained in:
WDI-Ideas
2026-03-30 02:48:26 +05:30
parent 9ec5604e5e
commit e0e4f79ebe
10 changed files with 8 additions and 27 deletions

View File

@@ -38,7 +38,6 @@ export function BookingModal({ isOpen, onClose, initialFacilityZone = "" }: Book
const handleBookingSubmit = (e: React.FormEvent) => {
e.preventDefault();
console.log('Booking form submitted:', bookingForm);
// Here you would typically send the form data to your backend
alert('Booking request submitted successfully! We will contact you within 24 hours.');
onClose();

View File

@@ -9,8 +9,7 @@ interface CTAPopupModalProps {
}
export function CTAPopupModal({ isOpen, onClose }: CTAPopupModalProps) {
console.log('CTAPopupModal render - isOpen:', isOpen); // Debug log
const handleVirtualTour = () => {
navigateTo('/services/learning-facility');
onClose();
@@ -25,22 +24,17 @@ export function CTAPopupModal({ isOpen, onClose }: CTAPopupModalProps) {
};
const handleBooking = () => {
console.log('Booking button clicked in modal'); // Debug log
// Use URL parameter approach for more reliable booking modal triggering
navigateTo('/services/learning-facility?autoBooking=true');
onClose();
// Also try the element-based approach as backup
const attemptBookingTrigger = (attempt = 1, maxAttempts = 5) => {
console.log(`Booking trigger attempt #${attempt}`); // Debug log
// Look for the booking trigger element
const bookingBtn = document.querySelector('[data-booking-trigger]') as HTMLButtonElement;
console.log('Found booking trigger:', bookingBtn); // Debug log
if (bookingBtn) {
console.log('Clicking booking trigger...'); // Debug log
bookingBtn.click();
return;
}
@@ -48,8 +42,6 @@ export function CTAPopupModal({ isOpen, onClose }: CTAPopupModalProps) {
// If not found and we haven't reached max attempts, try again
if (attempt < maxAttempts) {
setTimeout(() => attemptBookingTrigger(attempt + 1, maxAttempts), 200);
} else {
console.log('Element-based approach failed, relying on URL parameter approach'); // Debug log
}
};

View File

@@ -38,11 +38,9 @@ export function Contact({ topic }: ContactProps) {
const [createLead] = useCreateLeadMutation();
useEffect(() => {
console.log('Contact component mounted with topic:', topic);
// Set default interested in based on topic parameter
if (topic) {
const interestedIn = getTopicSubject(topic);
console.log('Setting form interestedIn to:', interestedIn);
setFormData(prev => ({
...prev,
interestedIn: interestedIn

View File

@@ -4,8 +4,7 @@ const listeners: (() => void)[] = [];
export function navigateTo(path: string) {
try {
console.log(`Navigating to: ${path}`);
// Update current path
currentPath = path;

View File

@@ -91,7 +91,7 @@ export function StatsSection({ stats = [], isLoading }: StatsSectionProps) {
<PrimaryCTAButton
text="About Us"
onClick={() => console.log("About us clicked")}
onClick={() => {}}
ariaLabel="Learn more about KLC"
/>
</div>

View File

@@ -208,7 +208,6 @@ function BookingModal({
const handleFormSubmit = (e: React.FormEvent) => {
e.preventDefault();
console.log('Booking form submitted:', bookingForm);
// Here you would typically send the form data to your backend
alert('Booking request submitted successfully! We will contact you soon.');
onClose();

View File

@@ -310,7 +310,6 @@ export function VirtualTour() {
const handleBookingSubmit = (e: React.FormEvent) => {
e.preventDefault();
console.log('Booking submitted:', bookingForm);
setIsBookingModalOpen(false);
setBookingForm({
companyName: '',

View File

@@ -415,12 +415,10 @@ export function LearningFacility() {
});
useEffect(() => {
console.log('LearningFacility component mounted'); // Debug log
window.scrollTo(0, 0);
// Listen for custom booking modal event from CTAPopupModal
const handleOpenBookingModal = () => {
console.log('Custom booking modal event received'); // Debug log
setIsBookingModalOpen(true);
};
@@ -429,7 +427,6 @@ export function LearningFacility() {
// Also check if we should auto-open the booking modal based on URL parameters
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('autoBooking') === 'true') {
console.log('Auto-opening booking modal from URL parameter'); // Debug log
setTimeout(() => setIsBookingModalOpen(true), 100);
}
@@ -461,7 +458,6 @@ export function LearningFacility() {
const handleBookingSubmit = (e: React.FormEvent) => {
e.preventDefault();
console.log('Booking submitted:', bookingForm);
setIsBookingModalOpen(false);
setBookingForm({
companyName: '',
@@ -484,7 +480,6 @@ export function LearningFacility() {
};
const handleBookingModalClose = (open: boolean) => {
console.log('Booking modal close triggered, open:', open); // Debug log
setIsBookingModalOpen(open);
if (!open) {
@@ -541,7 +536,6 @@ export function LearningFacility() {
<Button
variant="outline"
onClick={() => {
console.log('Book Facility button clicked');
setIsBookingModalOpen(true);
}}
data-booking-trigger

View File

@@ -3,6 +3,7 @@ export const getReadingTime = (text: string): string => {
// Remove HTML tags if present
const cleanText = text.replace(/<[^>]+>/g, "");
if (!cleanText.trim()) return "0 min read";
// Count words
const words = cleanText.trim().split(/\s+/).length;

View File

@@ -18,8 +18,8 @@ export const createSlug = (text: string): string => {
* Example: "Ad ut neque enim omn", "e7d611b6-853b-4785-b508-599eeed2af92" -> "ad-ut-neque-enim-omn-e7d611b6-853b-4785-b508-599eeed2af92"
*/
export const getSlugWithId = (title: string, id: string) => {
const slug = createSlug(title);
return slug && id ? `${slug}-${id}` : slug || id;
const normalizedId = id.trim();
return `${createSlug(title)}-${normalizedId}`;
};
/**