edit tender module
This commit is contained in:
@@ -35,6 +35,24 @@ const DIRECTIVE_TYPE_LABELS: Record<string, string> = {
|
||||
PREPARE_TO_BID: 'Prepare to bid',
|
||||
}
|
||||
|
||||
const getDisplayFileName = (attachment: any) => {
|
||||
const name = String(attachment.originalName || attachment.fileName || 'file')
|
||||
|
||||
if (!/[ÃÄÅØÙ]/.test(name)) {
|
||||
return name
|
||||
}
|
||||
|
||||
try {
|
||||
const bytes = new Uint8Array(
|
||||
Array.from(name, (char: string) => char.charCodeAt(0) & 0xff)
|
||||
)
|
||||
|
||||
return new TextDecoder('utf-8').decode(bytes)
|
||||
} catch {
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
function TenderDetailContent() {
|
||||
const searchParams = useSearchParams()
|
||||
const params = useParams()
|
||||
@@ -45,8 +63,8 @@ function TenderDetailContent() {
|
||||
const [tender, setTender] = useState<Tender | null>(null)
|
||||
const [history, setHistory] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
type TenderTab = 'details' | 'directives' | 'attachments' | 'logs' | 'info' |'history'
|
||||
const [activeTab, setActiveTab] = useState<TenderTab>('details')
|
||||
type TenderTab = 'info' | 'directives' | 'attachments' | 'history'
|
||||
const [activeTab, setActiveTab] = useState<TenderTab>('info')
|
||||
const openTab = (tab: TenderTab) => {
|
||||
setActiveTab(tab)
|
||||
router.replace(`/tenders/${params.id}?tab=${tab}`)
|
||||
@@ -94,9 +112,7 @@ function TenderDetailContent() {
|
||||
}
|
||||
useEffect(() => {
|
||||
const tabParam = searchParams.get('tab') as TenderTab | null
|
||||
|
||||
const allowedTabs: TenderTab[] = ['details', 'directives', 'attachments', 'logs']
|
||||
|
||||
const allowedTabs: TenderTab[] = ['info', 'directives', 'attachments', 'history']
|
||||
if (tabParam && allowedTabs.includes(tabParam)) {
|
||||
setActiveTab(tabParam)
|
||||
}
|
||||
@@ -284,7 +300,7 @@ function TenderDetailContent() {
|
||||
{tabs.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
onClick={() => setActiveTab(tab.id as any)}
|
||||
onClick={() => openTab(tab.id as TenderTab)}
|
||||
className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium ${
|
||||
activeTab === tab.id
|
||||
? 'bg-indigo-100 text-indigo-800'
|
||||
@@ -510,7 +526,7 @@ function TenderDetailContent() {
|
||||
className="text-sm text-indigo-600 hover:underline flex items-center gap-1"
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" />
|
||||
{a.originalName || a.fileName}
|
||||
{getDisplayFileName(a)}
|
||||
</a>
|
||||
|
||||
<button
|
||||
|
||||
@@ -662,6 +662,7 @@ function TendersContent() {
|
||||
>
|
||||
<option value="all">{t('common.all') || 'All status'}</option>
|
||||
<option value="ACTIVE">Active</option>
|
||||
<option value="EXPIRED">Expired</option>
|
||||
<option value="CONVERTED_TO_DEAL">Converted</option>
|
||||
<option value="CANCELLED">Cancelled</option>
|
||||
</select>
|
||||
@@ -721,12 +722,14 @@ function TendersContent() {
|
||||
className={`inline-flex px-2.5 py-1 text-xs font-medium rounded-full ${
|
||||
tender.status === 'ACTIVE'
|
||||
? 'bg-green-100 text-green-800'
|
||||
: tender.status === 'CONVERTED_TO_DEAL'
|
||||
? 'bg-blue-100 text-blue-800'
|
||||
: 'bg-gray-100 text-gray-800'
|
||||
: tender.status === 'EXPIRED'
|
||||
? 'bg-red-100 text-red-800'
|
||||
: tender.status === 'CONVERTED_TO_DEAL'
|
||||
? 'bg-blue-100 text-blue-800'
|
||||
: 'bg-gray-100 text-gray-800'
|
||||
}`}
|
||||
>
|
||||
{tender.status}
|
||||
{tender.status === 'EXPIRED' ? 'EXPIRED' : tender.status}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-6 py-4 text-right align-middle">
|
||||
|
||||
Reference in New Issue
Block a user