fix: preserve bid drafts and align tender source data
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useApp } from '../context/AppContext';
|
||||
import { BidPackageBuilder } from './BidPackageBuilder';
|
||||
import { TenderDocuments } from './TenderDocuments';
|
||||
@@ -18,8 +18,20 @@ export const TenderDetailModal = () => {
|
||||
|
||||
// Kur Farkı Calculator State
|
||||
const [bidAmount, setBidAmount] = useState(15000);
|
||||
const usdRate = 36.45;
|
||||
const eurRate = 39.80;
|
||||
const [fx, setFx] = useState(null);
|
||||
const [fxError, setFxError] = useState(null);
|
||||
useEffect(() => {
|
||||
if (!activeTenderDetail) return;
|
||||
let cancelled = false;
|
||||
fetch('/api/exchange-rates').then(r => r.json()).then(d => {
|
||||
if (cancelled) return;
|
||||
if (!d.success) throw new Error(d.error);
|
||||
setFx(d); setFxError(d.refreshError || null);
|
||||
}).catch(e => { if (!cancelled) setFxError(e.message); });
|
||||
return () => { cancelled = true; };
|
||||
}, [activeTenderDetail?.id]);
|
||||
const usdRate = fx?.rates?.USD;
|
||||
const eurRate = fx?.rates?.EUR;
|
||||
|
||||
// Stamp Drag Position State
|
||||
const [stampPos, setStampPos] = useState({ x: 220, y: 180 });
|
||||
@@ -320,17 +332,19 @@ export const TenderDetailModal = () => {
|
||||
<span className="font-bold text-xs uppercase tracking-wider flex items-center gap-1.5">
|
||||
<Calculator className="w-4 h-4 text-blue-400" /> Kur Farkı Hesaplayıcı
|
||||
</span>
|
||||
<span className="text-[10px] bg-blue-500/30 text-blue-300 px-2 py-0.5 rounded font-bold">TCMB Canlı</span>
|
||||
<span className="text-[10px] bg-blue-500/30 text-blue-300 px-2 py-0.5 rounded font-bold">TCMB döviz satış</span>
|
||||
</div>
|
||||
|
||||
{fx && <p className="text-[11px]"><a href={fx.source} target="_blank" rel="noreferrer" className="underline">TCMB bülteni: {fx.bulletinDate}</a> · Alındı: {new Date(fx.fetchedAt).toLocaleString('tr-TR')}</p>}
|
||||
{fxError && <p role="alert" className="text-xs text-amber-200">{fxError}</p>}
|
||||
<div className="grid grid-cols-2 gap-2 text-xs font-semibold">
|
||||
<div className="bg-white/10 p-2.5 rounded-lg border border-white/10">
|
||||
<span className="text-slate-400 block text-[10px]">USD / TRY</span>
|
||||
<span className="text-base font-black text-emerald-400">₺{usdRate}</span>
|
||||
<span className="text-base font-black text-emerald-400">{usdRate ? `₺${usdRate}` : '—'}</span>
|
||||
</div>
|
||||
<div className="bg-white/10 p-2.5 rounded-lg border border-white/10">
|
||||
<span className="text-slate-400 block text-[10px]">EUR / TRY</span>
|
||||
<span className="text-base font-black text-blue-400">₺{eurRate}</span>
|
||||
<span className="text-base font-black text-blue-400">{eurRate ? `₺${eurRate}` : '—'}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -347,11 +361,11 @@ export const TenderDetailModal = () => {
|
||||
<div className="bg-blue-950/80 p-3 rounded-lg border border-blue-800 text-xs space-y-1">
|
||||
<div className="flex justify-between text-slate-300">
|
||||
<span>Dolar Karşılığı:</span>
|
||||
<span className="font-bold text-white">${(bidAmount / usdRate).toFixed(2)}</span>
|
||||
<span className="font-bold text-white">{usdRate ? '$' + (bidAmount / usdRate).toFixed(2) : 'Kur bekleniyor'}</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-slate-300">
|
||||
<span>Euro Karşılığı:</span>
|
||||
<span className="font-bold text-white">€{(bidAmount / eurRate).toFixed(2)}</span>
|
||||
<span className="font-bold text-white">{eurRate ? '€' + (bidAmount / eurRate).toFixed(2) : 'Kur bekleniyor'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user