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
|
||||
|
||||
Reference in New Issue
Block a user