diff --git a/components/dashboard/projects-widget.tsx b/components/dashboard/projects-widget.tsx index fca4309..abacde3 100644 --- a/components/dashboard/projects-widget.tsx +++ b/components/dashboard/projects-widget.tsx @@ -61,7 +61,12 @@ export function ProjectsWidget({
Profit
{Object.entries(statsPerProject[project.code]?.profitPerCurrency).map(([currency, total]) => ( -
+
= 0 ? "text-green-500" : "text-red-500" + }`} + > {formatCurrency(total, currency)}
))} diff --git a/components/forms/date-range-picker.tsx b/components/forms/date-range-picker.tsx index 5d7725b..0454258 100644 --- a/components/forms/date-range-picker.tsx +++ b/components/forms/date-range-picker.tsx @@ -66,6 +66,18 @@ export function DateRangePicker({ const [rangeName, setRangeName] = useState(defaultDate?.from ? "custom" : defaultRange) const [dateRange, setDateRange] = useState(defaultDate) + const getDisplayText = () => { + if (rangeName === "custom") { + if (dateRange?.from) { + return dateRange.to + ? `${format(dateRange.from, "LLL dd, y")} - ${format(dateRange.to, "LLL dd, y")}` + : format(dateRange.from, "LLL dd, y") + } + return "Select dates" + } + return predefinedRanges.find((range) => range.code === rangeName)?.label || "Select dates" + } + return ( @@ -78,19 +90,7 @@ export function DateRangePicker({ )} > - {rangeName === "custom" ? ( - dateRange?.from ? ( - dateRange.to ? ( - `${format(dateRange.from, "LLL dd, y")} - ${format(dateRange.to, "LLL dd, y")}` - ) : ( - format(dateRange.from, "LLL dd, y") - ) - ) : ( - ??? - ) - ) : ( - predefinedRanges.find((range) => range.code === rangeName)?.label - )} + {getDisplayText()}