Skip to content

Commit 018139a

Browse files
Copilotrajbos
andcommitted
Implement plan selection dropdown and simplify table display
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
1 parent ea2512e commit 018139a

1 file changed

Lines changed: 43 additions & 6 deletions

File tree

src/App.tsx

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Separator } from "@/components/ui/separator";
1111
import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart";
1212
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
1313
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet";
14+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
1415
import {
1516
AggregatedData,
1617
CopilotUsageData,
@@ -22,7 +23,8 @@ import {
2223
getModelUsageSummary,
2324
getDailyModelData,
2425
getPowerUsers,
25-
getPowerUserDailyData
26+
getPowerUserDailyData,
27+
COPILOT_PLANS
2628
} from "@/lib/utils";
2729

2830
function App() {
@@ -33,6 +35,7 @@ function App() {
3335
const [dailyModelData, setDailyModelData] = useState<DailyModelData[]>([]);
3436
const [powerUserSummary, setPowerUserSummary] = useState<PowerUserSummary | null>(null);
3537
const [isDragging, setIsDragging] = useState(false);
38+
const [selectedPlan, setSelectedPlan] = useState<string>(COPILOT_PLANS.BUSINESS); // Default to Business
3639
const fileInputRef = useRef<HTMLInputElement>(null);
3740

3841
const processFile = useCallback((file: File) => {
@@ -267,6 +270,27 @@ function App() {
267270
}, {} as Record<string, string>);
268271
}, [uniqueModels]);
269272

273+
// Helper function to get plan limit based on selected plan
274+
const getPlanLimit = useCallback((item: ModelUsageSummary) => {
275+
let limit: number;
276+
switch (selectedPlan) {
277+
case COPILOT_PLANS.INDIVIDUAL:
278+
limit = item.individualPlanLimit;
279+
break;
280+
case COPILOT_PLANS.BUSINESS:
281+
limit = item.businessPlanLimit;
282+
break;
283+
case COPILOT_PLANS.ENTERPRISE:
284+
limit = item.enterprisePlanLimit;
285+
break;
286+
default:
287+
limit = item.businessPlanLimit;
288+
}
289+
290+
// Handle infinity (unlimited) for 0x multiplier models
291+
return limit === Infinity ? "Unlimited" : limit.toLocaleString();
292+
}, [selectedPlan]);
293+
270294
return (
271295
<div className="container max-w-7xl mx-auto py-8 px-4 min-h-screen">
272296
<header className="mb-8">
@@ -494,7 +518,22 @@ function App() {
494518
{/* Model Usage Table */}
495519
<div className="mb-6">
496520
<Card className="p-5">
497-
<h3 className="text-md font-medium mb-3">Requests per Model</h3>
521+
<div className="flex items-center justify-between mb-3">
522+
<h3 className="text-md font-medium">Requests per Model</h3>
523+
<div className="flex items-center gap-2">
524+
<span className="text-sm text-muted-foreground">Plan Type:</span>
525+
<Select value={selectedPlan} onValueChange={setSelectedPlan}>
526+
<SelectTrigger className="w-32">
527+
<SelectValue placeholder="Select plan" />
528+
</SelectTrigger>
529+
<SelectContent>
530+
<SelectItem value={COPILOT_PLANS.INDIVIDUAL}>Individual</SelectItem>
531+
<SelectItem value={COPILOT_PLANS.BUSINESS}>Business</SelectItem>
532+
<SelectItem value={COPILOT_PLANS.ENTERPRISE}>Enterprise</SelectItem>
533+
</SelectContent>
534+
</Select>
535+
</div>
536+
</div>
498537
<div className="overflow-auto max-h-60">
499538
<Table>
500539
<TableHeader>
@@ -504,8 +543,7 @@ function App() {
504543
<TableHead className="text-right">Compliant</TableHead>
505544
<TableHead className="text-right">Exceeding</TableHead>
506545
<TableHead className="text-right">Multiplier</TableHead>
507-
<TableHead className="text-right">Individual Limit</TableHead>
508-
<TableHead className="text-right">Business/Enterprise Limit</TableHead>
546+
<TableHead className="text-right">Plan Limit</TableHead>
509547
<TableHead className="text-right">Excess Cost</TableHead>
510548
</TableRow>
511549
</TableHeader>
@@ -517,8 +555,7 @@ function App() {
517555
<TableCell className="text-right">{item.compliantRequests.toLocaleString(undefined, {maximumFractionDigits: 2, minimumFractionDigits: 0})}</TableCell>
518556
<TableCell className="text-right">{item.exceedingRequests.toLocaleString(undefined, {maximumFractionDigits: 2, minimumFractionDigits: 0})}</TableCell>
519557
<TableCell className="text-right">{item.multiplier}x</TableCell>
520-
<TableCell className="text-right">{item.individualPlanLimit.toLocaleString()}</TableCell>
521-
<TableCell className="text-right">{item.businessPlanLimit.toLocaleString()}</TableCell>
558+
<TableCell className="text-right">{getPlanLimit(item)}</TableCell>
522559
<TableCell className="text-right">${item.excessCost.toFixed(2)}</TableCell>
523560
</TableRow>
524561
))}

0 commit comments

Comments
 (0)