Risk hesaplama katmanı: rapor listesi satırları adayın sırasına göre renklenir
sihirbaz-modal'ın kullandığı RaporListesi adaySira prop'u bu dosyalara bağlıydı; önceki commit'te eksik kalınca CI build'i kırıldı. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,25 +1,54 @@
|
||||
import { Rocket, Scale, ShieldCheck } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import type { RaporSonuc } from "@/lib/ai/rapor";
|
||||
import {
|
||||
RISK_ETIKET,
|
||||
dilimdenRisk,
|
||||
riskHesapla,
|
||||
type RiskSeviyesi,
|
||||
} from "@/lib/risk";
|
||||
|
||||
export const DILIM_STIL: Record<
|
||||
string,
|
||||
{ label: string; cls: string; icon: typeof Rocket }
|
||||
export const DILIM_ETIKET: Record<string, string> = {
|
||||
hayal: "Hayal",
|
||||
dengeli: "Dengeli",
|
||||
garanti: "Garanti",
|
||||
};
|
||||
|
||||
// Risk renk dili: yeşil = güvenli, sarı = az riskli, kırmızı = riskli
|
||||
export const RISK_STIL: Record<
|
||||
RiskSeviyesi,
|
||||
{ badge: string; kenar: string; icon: typeof Rocket }
|
||||
> = {
|
||||
hayal: { label: "Hayal", cls: "bg-orange-100 text-orange-700", icon: Rocket },
|
||||
dengeli: { label: "Dengeli", cls: "bg-blue-100 text-blue-700", icon: Scale },
|
||||
garanti: {
|
||||
label: "Garanti",
|
||||
cls: "bg-emerald-100 text-emerald-700",
|
||||
riskli: {
|
||||
badge: "bg-red-100 text-red-700",
|
||||
kenar: "border-l-red-500",
|
||||
icon: Rocket,
|
||||
},
|
||||
"az-riskli": {
|
||||
badge: "bg-amber-100 text-amber-700",
|
||||
kenar: "border-l-amber-500",
|
||||
icon: Scale,
|
||||
},
|
||||
guvenli: {
|
||||
badge: "bg-emerald-100 text-emerald-700",
|
||||
kenar: "border-l-emerald-500",
|
||||
icon: ShieldCheck,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 24'lük listenin gövdesi (genel değerlendirme + tercih kartları).
|
||||
* Hem sonuç modalında hem PDF/yazdır sayfasında kullanılır.
|
||||
* Hem sonuç modalında hem sohbet sayfasında kullanılır. Risk rengi
|
||||
* adayın sıralamasına göre deterministik hesaplanır (adaySira verilirse);
|
||||
* eski raporlarda dilimden türetilir.
|
||||
*/
|
||||
export function RaporListesi({ rapor }: { rapor: RaporSonuc }) {
|
||||
export function RaporListesi({
|
||||
rapor,
|
||||
adaySira,
|
||||
}: {
|
||||
rapor: RaporSonuc;
|
||||
adaySira?: number;
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<div className="rounded-2xl border border-slate-200 bg-white p-6">
|
||||
@@ -29,14 +58,36 @@ export function RaporListesi({ rapor }: { rapor: RaporSonuc }) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<ol className="mt-6 space-y-3">
|
||||
<div className="mt-4 flex flex-wrap gap-2 text-xs text-slate-500">
|
||||
{(["guvenli", "az-riskli", "riskli"] as const).map((r) => (
|
||||
<span key={r} className="inline-flex items-center gap-1.5">
|
||||
<span
|
||||
className={`size-2.5 rounded-full ${
|
||||
r === "guvenli"
|
||||
? "bg-emerald-500"
|
||||
: r === "az-riskli"
|
||||
? "bg-amber-500"
|
||||
: "bg-red-500"
|
||||
}`}
|
||||
aria-hidden
|
||||
/>
|
||||
{RISK_ETIKET[r]}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<ol className="mt-3 space-y-3">
|
||||
{rapor.tercihler.map((t) => {
|
||||
const p = rapor.programlar[t.programId];
|
||||
const stil = DILIM_STIL[t.dilim];
|
||||
const risk =
|
||||
(adaySira != null
|
||||
? riskHesapla(p?.efektifSira, adaySira)
|
||||
: null) ?? dilimdenRisk(t.dilim);
|
||||
const stil = RISK_STIL[risk];
|
||||
return (
|
||||
<li
|
||||
key={t.sira}
|
||||
className="rounded-2xl border border-slate-200 bg-white p-5"
|
||||
className={`rounded-2xl border border-l-4 border-slate-200 bg-white p-5 ${stil.kenar}`}
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<span className="flex size-8 items-center justify-center rounded-full bg-slate-100 font-heading text-sm font-bold">
|
||||
@@ -47,11 +98,14 @@ export function RaporListesi({ rapor }: { rapor: RaporSonuc }) {
|
||||
<p className="text-sm text-slate-500">
|
||||
{p?.universite} · {p?.il ?? "—"}
|
||||
{p?.unitur ? ` · ${p.unitur}` : ""}
|
||||
{p?.efektifSira != null
|
||||
? ` · taban ~${p.efektifSira.toLocaleString("tr-TR")}.`
|
||||
: ""}
|
||||
</p>
|
||||
</div>
|
||||
<Badge variant="secondary" className={stil.cls}>
|
||||
<Badge variant="secondary" className={stil.badge}>
|
||||
<stil.icon className="size-3" aria-hidden />
|
||||
{stil.label}
|
||||
{DILIM_ETIKET[t.dilim]} · {RISK_ETIKET[risk]}
|
||||
</Badge>
|
||||
</div>
|
||||
<dl className="mt-3 grid gap-2 text-sm sm:grid-cols-3">
|
||||
|
||||
Reference in New Issue
Block a user