Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 245 additions & 26 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from '@/utils/logger';
import { NextRequest, NextResponse } from 'next/server';
import { revalidateProperty, revalidateAllProperties } from '@/lib/propertyServiceServer';
import crypto from 'crypto';
Expand Down Expand Up @@ -59,7 +60,7 @@ export async function POST(request: NextRequest) {
}

// Log revalidation for monitoring
console.log(`ISR Revalidation: ${type}${propertyId ? ` for property ${propertyId}` : ''} - Reason: ${reason || 'Manual trigger'}`);
logger.info(`ISR Revalidation: ${type}${propertyId ? ` for property ${propertyId}` : ''} - Reason: ${reason || 'Manual trigger'}`);

return NextResponse.json({
success: true,
Expand All @@ -70,7 +71,7 @@ export async function POST(request: NextRequest) {
});

} catch (error) {
console.error('Webhook revalidation error:', error);
logger.error('Webhook revalidation error:', error);
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
Expand Down
3 changes: 2 additions & 1 deletion src/app/dashboard/saved-searches/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { logger } from '@/utils/logger';

import React, { useEffect, useState } from "react";
import Link from "next/link";
Expand Down Expand Up @@ -79,7 +80,7 @@ function SavedSearchesContent() {
toast.success("Search deleted successfully");
} catch (error) {
toast.error("Failed to delete search");
console.error("Delete search error:", error);
logger.error("Delete search error:", error);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Error({
},
}),
}).catch(err => {
console.error('Failed to report error:', err);
logger.error('Failed to report error:', err);
});
}, [error]);

Expand Down
3 changes: 2 additions & 1 deletion src/components/CartSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React from 'react';
import Image from 'next/image';
Expand Down Expand Up @@ -44,7 +45,7 @@ export const CartSidebar: React.FC = () => {
alert(`Purchase failed: ${result.error}`);
}
} catch (error) {
console.error('Checkout error:', error);
logger.error('Checkout error:', error);
alert('Checkout failed. Please try again.');
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/MortgageCalculator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState, useEffect } from 'react';
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
Expand Down Expand Up @@ -81,7 +82,7 @@ export const MortgageCalculator: React.FC<{ propertyPrice?: number, defaultYield
title: 'PropChain Investment Projection',
text,
url: window.location.href,
}).catch(console.error);
}).catch((err) => logger.error('Mortgage calculation error:', err));
} else {
navigator.clipboard.writeText(text);
alert('Result copied to clipboard!');
Expand Down
3 changes: 2 additions & 1 deletion src/components/MultiCurrencyBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState, useEffect } from 'react';
import { Wallet, DollarSign, ChevronDown } from 'lucide-react';
Expand Down Expand Up @@ -42,7 +43,7 @@ export const MultiCurrencyBalance: React.FC = () => {
const price = mockPrices[chainId] || 2000;
setUsdPrice(price);
} catch (error) {
console.error('Failed to fetch USD price:', error);
logger.error('Failed to fetch USD price:', error);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/SaveSearchButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState } from 'react';
import { Button } from '@/components/ui/button';
Expand Down Expand Up @@ -69,7 +70,7 @@ export const SaveSearchButton: React.FC<SaveSearchButtonProps> = ({
setIsOpen(false);
} catch (error) {
toast.error('Failed to save search. Please try again.');
console.error('Save search error:', error);
logger.error('Save search error:', error);
} finally {
setIsLoading(false);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/SecureTransactionConfirmation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState, useEffect } from 'react';
import { ethers } from 'ethers';
Expand Down Expand Up @@ -143,7 +144,7 @@ export const SecureTransactionConfirmation: React.FC<SecureTransactionConfirmati
});
}
} catch (error) {
console.error('Signing failed:', error);
logger.error('Signing failed:', error);
setCurrentStep('validation');
}
};
Expand All @@ -162,7 +163,7 @@ export const SecureTransactionConfirmation: React.FC<SecureTransactionConfirmati
onConfirm(txHash);
}
} catch (error) {
console.error('Broadcast failed:', error);
logger.error('Broadcast failed:', error);
setCurrentStep('signing');
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/TransactionConfirmation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState } from 'react';
import Link from 'next/link';
Expand Down Expand Up @@ -144,7 +145,7 @@ export const TransactionConfirmation: React.FC<TransactionConfirmationProps> = (
);
setValidation(result);
} catch (error) {
console.error('Transaction validation failed:', error);
logger.error('Transaction validation failed:', error);
setValidation({
isValid: false,
riskScore: 100,
Expand Down
5 changes: 3 additions & 2 deletions src/components/TransactionHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState, useMemo } from 'react';
import { useTransactionStore } from '@/store/transactionStore';
Expand Down Expand Up @@ -113,7 +114,7 @@ export const TransactionHistory: React.FC = () => {
saveAs(blob, fileName);
toast.success('Transaction history exported to CSV successfully');
} catch (error) {
console.error('Error exporting to CSV:', error);
logger.error('Error exporting to CSV:', error);
toast.error('Failed to export to CSV');
}
};
Expand All @@ -136,7 +137,7 @@ export const TransactionHistory: React.FC = () => {
saveAs(blob, fileName);
toast.success('Transaction history exported to Excel successfully');
} catch (error) {
console.error('Error exporting to Excel:', error);
logger.error('Error exporting to Excel:', error);
toast.error('Failed to export to Excel');
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/TransactionProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState, useEffect, useCallback, memo } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
Expand Down Expand Up @@ -107,7 +108,7 @@ export const TransactionProgress: React.FC<TransactionProgressProps> = memo(({
};

simulateProgress().catch(error => {
console.error('Transaction simulation error:', error);
logger.error('Transaction simulation error:', error);
if (onError) {
onError('Transaction failed. Please try again.');
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/dashboard/DraggablePropertiesList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import { motion } from "framer-motion";
import { useState, useEffect, useCallback, memo } from "react";
Expand Down Expand Up @@ -103,7 +104,7 @@ export const DraggablePropertiesList = memo(() => {
).filter(Boolean);
setProperties(orderedProperties.length > 0 ? orderedProperties : defaultProperties);
} catch (error) {
console.error('Error loading portfolio order:', error);
logger.error('Error loading portfolio order:', error);
setProperties(defaultProperties);
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/components/dashboard/RentalIncomeDistribution.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { logger } from '@/utils/logger';

import { useState, useEffect } from "react";
import { motion } from "framer-motion";
Expand Down Expand Up @@ -83,7 +84,7 @@ const RentalIncomeDistribution = ({
},
]);
} catch (error) {
console.error("Failed to load distributions:", error);
logger.error("Failed to load distributions:", error);
} finally {
setIsLoading(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { logger } from '@/utils/logger';

import { useState } from "react";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
Expand All @@ -21,7 +22,7 @@ const PendingDistributions = ({ pending, count, onClaimAll }: PendingDistributio
// await claimDistributions();
onClaimAll();
} catch (error) {
console.error("Failed to claim distributions:", error);
logger.error("Failed to claim distributions:", error);
} finally {
setIsClaiming(false);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/error/withRouteErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React from 'react';
import { EnhancedErrorBoundary } from './EnhancedErrorBoundary';
Expand All @@ -20,7 +21,7 @@ export const WithRouteErrorBoundary: React.FC<WithRouteErrorBoundaryProps> = ({
onError,
}) => {
const handleError = (error: any) => {
console.error(`Error in route ${routeName}:`, error);
logger.error(`Error in route ${routeName}:`, error);

// Report to monitoring service
if (typeof window !== 'undefined') {
Expand All @@ -43,7 +44,7 @@ export const WithRouteErrorBoundary: React.FC<WithRouteErrorBoundaryProps> = ({
},
}),
}).catch(err => {
console.error('Failed to report route error:', err);
logger.error('Failed to report route error:', err);
});
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/property/ShareButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState } from 'react';
import { Share2, Twitter, Linkedin, Link2, Check } from 'lucide-react';
Expand Down Expand Up @@ -69,7 +70,7 @@ export const ShareButton: React.FC<ShareButtonProps> = ({
} catch (error) {
// User cancelled or error occurred
if ((error as Error).name !== 'AbortError') {
console.error('Error sharing:', error);
logger.error('Error sharing:', error);
toast.error('Failed to share property');
}
}
Expand All @@ -88,7 +89,7 @@ export const ShareButton: React.FC<ShareButtonProps> = ({
// Reset copied state after 2 seconds
setTimeout(() => setCopied(false), 2000);
} catch (error) {
console.error('Error copying link:', error);
logger.error('Error copying link:', error);
toast.error('Failed to copy link');
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/referral/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

/**
* CopyButton - Button for copying referral links to clipboard
Expand All @@ -22,7 +23,7 @@ export default function CopyButton({
await navigator.clipboard.writeText(text);
onCopy?.();
} catch (error) {
console.error('Failed to copy:', error);
logger.error('Failed to copy:', error);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/security/WalletAddressInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState, useCallback, useEffect } from 'react';
import { Input } from '@/components/ui/input';
Expand Down Expand Up @@ -79,7 +80,7 @@ export const WalletAddressInput: React.FC<WalletAddressInputProps> = ({
onChange(address, result);
}
} catch (error) {
console.error('Address validation failed:', error);
logger.error('Address validation failed:', error);
setValidationResult(null);
} finally {
setIsValidating(false);
Expand Down
5 changes: 3 additions & 2 deletions src/components/ui/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
import { logger } from '@/utils/logger';

import React, { useState } from 'react';
import { Button } from '@/components/ui/button';
Expand Down Expand Up @@ -45,7 +46,7 @@ export const CopyButton: React.FC<CopyButtonProps> = ({
// Reset copied state after 2 seconds
setTimeout(() => setCopied(false), 2000);
} catch (error) {
console.error('Failed to copy:', error);
logger.error('Failed to copy:', error);
toast.error('Failed to copy to clipboard', {
duration: 3000,
position: 'top-right',
Expand Down Expand Up @@ -227,7 +228,7 @@ export const useCopyToClipboard = () => {
}
return true;
} catch (error) {
console.error('Failed to copy:', error);
logger.error('Failed to copy:', error);
toast.error('Failed to copy to clipboard');
return false;
}
Expand Down
7 changes: 4 additions & 3 deletions src/config/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* const appName = env.NEXT_PUBLIC_APP_NAME;
*/

import { logger } from '@/utils/logger';
import {
validateEnv,
validateEnvRequirements,
Expand Down Expand Up @@ -41,7 +42,7 @@ export function initEnv(): EnvConfig {

// Log initialization in development
if (validatedEnvConfig.NEXT_PUBLIC_DEBUG_MODE) {
console.log("[EnvConfig] Environment initialized:", {
logger.info("[EnvConfig] Environment initialized:", {
NODE_ENV: validatedEnvConfig.NODE_ENV,
NEXT_PUBLIC_APP_NAME: validatedEnvConfig.NEXT_PUBLIC_APP_NAME,
NEXT_PUBLIC_APP_URL: validatedEnvConfig.NEXT_PUBLIC_APP_URL,
Expand All @@ -50,7 +51,7 @@ export function initEnv(): EnvConfig {

return validatedEnvConfig;
} catch (error) {
console.error("[EnvConfig] Environment validation failed:", error);
logger.error("[EnvConfig] Environment validation failed:", error);
throw error;
}
}
Expand Down Expand Up @@ -164,6 +165,6 @@ if (typeof window === "undefined") {
initEnv();
} catch (error) {
// Log but don't throw during module load to allow Next.js to handle gracefully
console.warn("[EnvConfig] Early validation warning:", error);
logger.warn("[EnvConfig] Early validation warning:", error);
}
}
3 changes: 2 additions & 1 deletion src/config/env/schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from '@/utils/logger';
import {z} from "zod";

/**
Expand Down Expand Up @@ -148,7 +149,7 @@ export function validateEnvRequirements(config: EnvConfig): void {
.join("\n");

if (env === 'production') {
console.warn(
logger.warn(
`Environment-specific requirements for 'production' are not fully met:\n${errors}`
);
return;
Expand Down
Loading