260921_04_ENH: survey url full도 노출 및 경고문 추가

This commit is contained in:
2026-09-21 16:33:46 +09:00
parent c5e2a3a6db
commit 057f610704

View File

@@ -181,8 +181,8 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
// KON/KIWI는 호스트 placeholder까지 고정하고 '?' 이후 쿼리스트링만 편집 가능하게 한다.
const konKiwiPlaceholderPrefix = survey.surveyTy === SurveyType.KIWI ? 'https://[$KIWI-URL]' : 'https://[$KON-URL]'
// 저장 후 생성된 실제 URL(surveyFullUrl)이 있으면 placeholder 대신 실제 호스트를 접두어로 노출한다.
const konKiwiDisplayPrefix = survey.surveyUrl?.trim()
// 저장 후 surveyUrl의 placeholder가 실제(단축) 호스트로 치환되므로 현재 base를 그대로 접두어로 쓴다.
const konKiwiUrlBase = survey.surveyUrl?.trim()
? survey.surveyUrl.split('?')[0]
: konKiwiPlaceholderPrefix
const konKiwiQuery = (() => {
@@ -191,21 +191,28 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
return idx >= 0 ? url.slice(idx + 1) : ''
})()
const handleKonKiwiQueryChange = (query: string) => {
onChange(survey.uiKey, {
surveyUrl: `${konKiwiPlaceholderPrefix}?${query}`,
surveyFullUrl: null,
})
const handleKonKiwiQueryChange = (nextQuery: string) => {
// 파라미터만 수정: surveyUrl base(단축/placeholder)는 유지하고 뒤 파라미터만 교체한다.
const patch: Partial<ProjectSurvey> = {
surveyUrl: `${konKiwiUrlBase}?${nextQuery}`,
}
// surveyFullUrl은 base(psidx 등)는 고정하고, 동일한 파라미터 꼬리만 함께 교체한다.
// 파라미터 꼬리를 갖지 않는 값(순수 단축 URL 등)은 건드리지 않는다.
const fullUrl = survey.surveyFullUrl
if (fullUrl && konKiwiQuery && fullUrl.endsWith(konKiwiQuery)) {
patch.surveyFullUrl = fullUrl.slice(0, fullUrl.length - konKiwiQuery.length) + nextQuery
}
onChange(survey.uiKey, patch)
}
const [urlCopied, setUrlCopied] = useState(false)
const handleCopyUrl = async () => {
const url = survey.surveyUrl?.trim() ?? ''
if (!url) return
const [copiedField, setCopiedField] = useState<'url' | 'fullUrl' | null>(null)
const copyToClipboard = async (value: string | null | undefined, field: 'url' | 'fullUrl') => {
const text = value?.trim() ?? ''
if (!text) return
try {
await navigator.clipboard.writeText(url)
setUrlCopied(true)
setTimeout(() => setUrlCopied(false), 1500)
await navigator.clipboard.writeText(text)
setCopiedField(field)
setTimeout(() => setCopiedField((prev) => (prev === field ? null : prev)), 1500)
} catch {
// 클립보드 접근 실패 시 무시
}
@@ -276,12 +283,19 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
)}
<div className="space-y-2">
<Label className="text-base">설문 URL</Label>
<div className="flex items-center gap-2">
<Label className="text-base">설문 URL</Label>
{isKonKiwi && (
<span className="text-sm text-red-600" role="alert">
⚠️ {SURVEY_TYPE_LABEL[survey.surveyTy]}에서 제공하는 단축 URL과 다른 URL입니다.
</span>
)}
</div>
<div className="flex items-center gap-2">
{isKonKiwi ? (
<div className="flex flex-1 items-center">
<span className="inline-flex h-9 items-center whitespace-nowrap rounded-l-md border border-r-0 bg-gray-100 px-3 text-sm text-muted-foreground">
{konKiwiDisplayPrefix}?
{konKiwiUrlBase}?
</span>
<Input
ref={onRegisterFieldRef(survey.uiKey, 'surveyUrl')}
@@ -308,16 +322,40 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
<Button
type="button"
variant="outline"
onClick={handleCopyUrl}
onClick={() => copyToClipboard(survey.surveyUrl, 'url')}
disabled={!survey.surveyUrl?.trim()}
aria-label="설문 URL 복사"
className="h-9 w-9 shrink-0 p-0"
>
{urlCopied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
{copiedField === 'url' ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
</Button>
</div>
</div>
{isKonKiwi && (
<div className="space-y-2">
<Label className="text-base">설문 전체 URL</Label>
<div className="flex items-center gap-2">
<Input
value={survey.surveyFullUrl || ''}
readOnly
placeholder="저장 후 자동 생성됩니다"
className="h-9 flex-1 bg-gray-100"
/>
<Button
type="button"
variant="outline"
onClick={() => copyToClipboard(survey.surveyFullUrl, 'fullUrl')}
disabled={!survey.surveyFullUrl?.trim()}
aria-label="설문 전체 URL 복사"
className="h-9 w-9 shrink-0 p-0"
>
{copiedField === 'fullUrl' ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
</Button>
</div>
</div>
)}
{survey.surveyTy === SurveyType.EXTERNAL && (
<div className="space-y-2">
<Label className="text-base">설문 대시보드 URL</Label>