// components/TemplateFormClient.tsx 'use client'; import { useState, type ChangeEvent } from 'react'; import Link from "next/link"; import DependentDropdown, { type DropdownData } from '@/components/utils/DependentDropdown'; interface TemplateFormClientProps { templateData: DropdownData; } export default function TemplateFormClient({ templateData }: TemplateFormClientProps) { const handleTmplSelect = (template: string, data: string) => { // Handle selection if needed }; return (
{/* ส่วน Template & Data แสดงรายการไฟล์จริงจากโฟลเดอร์ */}

Template & Data

{Object.entries(templateData).map(([tid, jsonList]) => (
Template: {tid}.docx
Data: {jsonList.map((fid, idx) => ( {fid}.json {idx < jsonList.length - 1 ? ', ' : ''} ))}
))}
นำไฟล์ไปทดสอบกับ API
{/* ส่วน Form (POST) */}

Form (POST)

{/* ส่วน Link (GET) */}

Link (GET)

{Object.entries(templateData).map(([tid, jsonList]) => { // jsonList คืออาเรย์ของชื่อไฟล์ json (fid) ที่ผูกอยู่กับ template (tid) นี้ return jsonList.map((fid) => { const linkHref = `/docedit/api/template/download-docx?tid=${tid}&fid=${fid}&uid=john&uname=John%20Doe`; const displayLabel = `${fid}_john_xxx.docx`; // หรือปรับรูปแบบข้อความแสดงผลตามต้องการ return ( {displayLabel}
); }); })}

); }