diff --git a/resources/js/components/Display/InlineForm.tsx b/resources/js/components/Display/InlineForm.tsx index 9d6b693..fe189bc 100644 --- a/resources/js/components/Display/InlineForm.tsx +++ b/resources/js/components/Display/InlineForm.tsx @@ -3,6 +3,7 @@ import AddPurchaseForm from '@/components/Transactions/AddPurchaseForm'; import UpdatePriceForm from '@/components/Pricing/UpdatePriceForm'; import { cn } from '@/lib/utils'; import { X } from 'lucide-react'; +import ComponentTitle from '@/components/ui/ComponentTitle'; interface InlineFormProps { type: 'purchase' | 'milestone' | 'price' | null; @@ -13,66 +14,66 @@ interface InlineFormProps { className?: string; } -export default function InlineForm({ - type, - onClose, +export default function InlineForm({ + type, + onClose, onPurchaseSuccess, onMilestoneSuccess, onPriceSuccess, - className + className }: InlineFormProps) { if (!type) return null; const title = type === 'purchase' ? 'ADD PURCHASE' : type === 'milestone' ? 'ADD MILESTONE' : 'UPDATE PRICE'; return ( -
{/* Header */} -
-

- {title} -

- -
+
+
+ {title} - {/* Form Content */} -
- {type === 'purchase' ? ( - { - if (onPurchaseSuccess) onPurchaseSuccess(); - onClose(); - }} - /> - ) : type === 'milestone' ? ( - { - if (onMilestoneSuccess) onMilestoneSuccess(); - onClose(); - }} - /> - ) : ( - { - if (onPriceSuccess) onPriceSuccess(); - onClose(); - }} - /> - )} + +
+ + {/* Form Content */} +
+ {type === 'purchase' ? ( + { + if (onPurchaseSuccess) onPurchaseSuccess(); + onClose(); + }} + /> + ) : type === 'milestone' ? ( + { + if (onMilestoneSuccess) onMilestoneSuccess(); + onClose(); + }} + /> + ) : ( + { + if (onPriceSuccess) onPriceSuccess(); + onClose(); + }} + /> + )} +
); -} \ No newline at end of file +} diff --git a/resources/js/components/Display/StatsBox.tsx b/resources/js/components/Display/StatsBox.tsx index eafa4aa..1fc6a23 100644 --- a/resources/js/components/Display/StatsBox.tsx +++ b/resources/js/components/Display/StatsBox.tsx @@ -1,6 +1,7 @@ import { cn } from '@/lib/utils'; import { Plus, ChevronRight } from 'lucide-react'; import { useState } from 'react'; +import ComponentTitle from '@/components/ui/ComponentTitle'; interface Milestone { target: number; @@ -72,9 +73,8 @@ export default function StatsBox({
{/* STATS Title and Current Price */}
-

- STATS -

+ Stats +
{stats.currentPrice && (
@@ -185,8 +185,8 @@ export default function StatsBox({ key={index} className={cn( isSelectedMilestone - ? "text-red-500 font-bold" - : "bg-red-500 text-black" + ? "bg-red-500 text-black" + : "text-red-500 font-bold" )} > diff --git a/resources/js/components/ui/ComponentTitle.tsx b/resources/js/components/ui/ComponentTitle.tsx new file mode 100644 index 0000000..7c39a62 --- /dev/null +++ b/resources/js/components/ui/ComponentTitle.tsx @@ -0,0 +1,15 @@ +import { FC, ReactNode } from 'react'; + +interface ComponentTitleProps { + children: ReactNode; +} + +const ComponentTitle: FC = ({ children }) => { + return ( +

+ { children } +

+ ) +} + +export default ComponentTitle diff --git a/resources/js/pages/dashboard.tsx b/resources/js/pages/dashboard.tsx index 6753014..23c7449 100644 --- a/resources/js/pages/dashboard.tsx +++ b/resources/js/pages/dashboard.tsx @@ -27,11 +27,11 @@ export default function Dashboard() { total_investment: 0, average_cost_per_share: 0, }); - + const [priceData, setPriceData] = useState({ current_price: null, }); - + const [milestones, setMilestones] = useState([]); const [selectedMilestoneIndex, setSelectedMilestoneIndex] = useState(0); const [showProgressBar, setShowProgressBar] = useState(false); @@ -121,14 +121,14 @@ export default function Dashboard() { // Calculate portfolio stats - const currentValue = priceData.current_price - ? purchaseData.total_shares * priceData.current_price + const currentValue = priceData.current_price + ? purchaseData.total_shares * priceData.current_price : undefined; - - const profitLoss = currentValue - ? currentValue - purchaseData.total_investment + + const profitLoss = currentValue + ? currentValue - purchaseData.total_investment : undefined; - + const profitLossPercentage = profitLoss && purchaseData.total_investment > 0 ? (profitLoss / purchaseData.total_investment) * 100 : undefined; @@ -168,36 +168,37 @@ export default function Dashboard() { const handleProgressClick = () => { setShowStatsBox(!showStatsBox); + setActiveForm(null) }; return ( <> - + {/* Stacked Layout */}
{/* Box 1: LED Number Display - Fixed position from top */}
-
- + {/* Box 2: Progress Bar (toggleable) */} -
- +
- + {/* Box 3: Stats Box (toggleable) */} -
- + setActiveForm('price')} />
- + {/* Box 4: Forms (only when active form is set) */} -
+
setActiveForm(null)}