Skip to content
Open
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
40 changes: 23 additions & 17 deletions frontend/src/components/CountryPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const CountryPicker = ({
const [searchQuery, setSearchQuery] = useState("");
const inputRef = useRef(null);
const searchInputRef = useRef(null);
const [failedFlags, setFailedFlags] = useState({});


const handleImageError = (code) => {
setFailedFlags((prev) => ({ ...prev, [code]: true }));
};

// Find selected country
const selectedCountry = countriesData.find(
Expand Down Expand Up @@ -54,7 +60,7 @@ const CountryPicker = ({
return `https://flagcdn.com/w40/${code.toLowerCase()}.png`;
};

return (
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<button
Expand All @@ -70,14 +76,14 @@ const CountryPicker = ({
<div className="flex items-center gap-2 flex-1 min-w-0">
{selectedCountry ? (
<>
<img
src={getFlagUrl(selectedCountry.code)}
alt={selectedCountry.name}
className="w-5 h-4 object-cover rounded-sm flex-shrink-0"
onError={(e) => {
e.target.style.display = "none";
}}
/>
{!failedFlags[selectedCountry.code] && (
<img
src={getFlagUrl(selectedCountry.code)}
alt={selectedCountry.name}
className="w-5 h-4 object-cover rounded-sm flex-shrink-0"
onError={() => handleImageError(selectedCountry.code)}
/>
)}
<span className="truncate text-left">{selectedCountry.name}</span>
</>
) : (
Expand Down Expand Up @@ -121,14 +127,14 @@ const CountryPicker = ({
selectedCountry?.code === country.code && "bg-accent"
)}
>
<img
src={getFlagUrl(country.code)}
alt={country.name}
className="w-5 h-4 object-cover rounded-sm flex-shrink-0"
onError={(e) => {
e.target.style.display = "none";
}}
/>
{!failedFlags[country.code] && (
<img
src={getFlagUrl(country.code)}
alt={country.name}
className="w-5 h-4 object-cover rounded-sm flex-shrink-0"
onError={() => handleImageError(country.code)}
/>
)}
<span className="text-left">{country.name}</span>
</button>
))}
Expand Down
43 changes: 20 additions & 23 deletions frontend/src/components/InvoicePreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import PaidIcon from "@mui/icons-material/CheckCircle";
import UnpaidIcon from "@mui/icons-material/Pending";
import CancelIcon from "@mui/icons-material/Cancel";
import CurrencyExchangeIcon from "@mui/icons-material/CurrencyExchange";
import { useState } from "react";

const InvoicePreview = ({
invoice,
Expand All @@ -55,35 +56,34 @@ const InvoicePreview = ({
};

const networkFee = formatFee(fee);
const [logoError, setLogoError] = useState(false);
const [tokenLogoError, setTokenLogoError] = useState(false);

return (
<div className="flex flex-col h-full">
<div
id="invoice-print"
className="bg-white p-5 sm:p-6 lg:p-8 rounded-lg shadow-sm border border-gray-200 max-w-4xl mx-auto w-full my-4 sm:my-6"
>
{/* Header - Enhanced Layout with Bigger Logo */}
{/* Header - Enhanced Layout with Bigger Logo */}
<div className="border-b-2 border-gray-200 pb-5 mb-6">
<div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div className="flex items-center space-x-4">
<div className="bg-white p-3.5 rounded-xl border-2 border-gray-200 shadow-lg flex-shrink-0 hover:shadow-xl transition-shadow duration-200">
<img
src="/logo.png"
alt="Chainvoice"
className="h-14 w-14 sm:h-16 sm:w-16 md:h-20 md:w-20 object-contain"
onError={(e) => {
e.target.style.display = "none";
const fallback = e.target.parentElement.querySelector(
".logo-fallback"
);
if (fallback) fallback.style.display = "flex";
}}
/>
<div className="logo-fallback hidden h-14 w-14 sm:h-16 sm:w-16 md:h-20 md:w-20 bg-gradient-to-br from-green-500 to-emerald-600 rounded-xl items-center justify-center shadow-sm">
<span className="text-white font-bold text-xl sm:text-2xl md:text-3xl">
CV
</span>
</div>
{!logoError ? (
<img
src="/logo.png"
alt="Chainvoice"
className="h-14 w-14 sm:h-16 sm:w-16 md:h-20 md:w-20 object-contain"
onError={() => setLogoError(true)}
/>
) : (
<div className="h-14 w-14 sm:h-16 sm:w-16 md:h-20 md:w-20 bg-gradient-to-br from-green-500 to-emerald-600 rounded-xl flex items-center justify-center shadow-sm">
<span className="text-white font-bold text-xl sm:text-2xl md:text-3xl">
CV
</span>
</div>
)}
</div>
<div className="flex flex-col justify-center">
<h1 className="text-2xl sm:text-3xl md:text-4xl font-bold mb-1 leading-tight">
Expand Down Expand Up @@ -236,15 +236,13 @@ const InvoicePreview = ({
Payment Currency
</h3>
<div className="flex items-center">
{invoice.paymentToken?.logo ? (
{invoice.paymentToken?.logo && !tokenLogoError ? (
<div className="bg-white p-1.5 rounded-lg border border-gray-200 mr-3">
<img
src={invoice.paymentToken.logo}
alt={invoice.paymentToken.symbol}
className="w-7 h-7 sm:w-8 sm:h-8 object-contain"
onError={(e) => {
e.target.src = "/tokenImages/generic.png";
}}
onError={() => setTokenLogoError(true)}
/>
</div>
) : (
Expand Down Expand Up @@ -453,4 +451,3 @@ const InvoicePreview = ({
};

export default InvoicePreview;

33 changes: 16 additions & 17 deletions frontend/src/page/ReceivedInvoice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function ReceivedInvoice() {
selectedInvoice: null,
});

const [logoError, setLogoError] = useState(false);

const { tokens } = useTokenList(chainId || 1);

const handleChangePage = (event, newPage) => {
Expand Down Expand Up @@ -1562,23 +1564,20 @@ function ReceivedInvoice() {
<div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-6">
<div className="flex items-center space-x-4">
<div className="bg-white p-3.5 rounded-xl border-2 border-gray-200 shadow-lg flex-shrink-0">
<img
src="/logo.png"
alt="Chainvoice"
className="h-16 w-16 object-contain"
onError={(e) => {
e.target.style.display = "none";
const fallback = e.target.parentElement.querySelector(
".logo-fallback"
);
if (fallback) fallback.style.display = "flex";
}}
/>
<div className="logo-fallback hidden h-16 w-16 bg-gradient-to-br from-green-500 to-emerald-600 rounded-xl items-center justify-center shadow-sm">
<span className="text-white font-bold text-2xl">
CV
</span>
</div>
{!logoError ? (
<img
src="/logo.png"
alt="Chainvoice"
className="h-16 w-16 object-contain"
onError={() => setLogoError(true)}
/>
) : (
<div className="h-16 w-16 bg-gradient-to-br from-green-500 to-emerald-600 rounded-xl flex items-center justify-center shadow-sm">
<span className="text-white font-bold text-2xl">
CV
</span>
</div>
)}
</div>
<div className="flex flex-col justify-center">
<h1 className="text-3xl sm:text-4xl font-bold mb-1 leading-tight">
Expand Down