Merge pull request '260921_04_ENH: survey url full도 노출 및 경고문 추가' (#41) from develop into master
Reviewed-on: #41
This commit is contained in:
@@ -181,8 +181,8 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
|
|||||||
|
|
||||||
// KON/KIWI는 호스트 placeholder까지 고정하고 '?' 이후 쿼리스트링만 편집 가능하게 한다.
|
// KON/KIWI는 호스트 placeholder까지 고정하고 '?' 이후 쿼리스트링만 편집 가능하게 한다.
|
||||||
const konKiwiPlaceholderPrefix = survey.surveyTy === SurveyType.KIWI ? 'https://[$KIWI-URL]' : 'https://[$KON-URL]'
|
const konKiwiPlaceholderPrefix = survey.surveyTy === SurveyType.KIWI ? 'https://[$KIWI-URL]' : 'https://[$KON-URL]'
|
||||||
// 저장 후 생성된 실제 URL(surveyFullUrl)이 있으면 placeholder 대신 실제 호스트를 접두어로 노출한다.
|
// 저장 후 surveyUrl의 placeholder가 실제(단축) 호스트로 치환되므로 현재 base를 그대로 접두어로 쓴다.
|
||||||
const konKiwiDisplayPrefix = survey.surveyUrl?.trim()
|
const konKiwiUrlBase = survey.surveyUrl?.trim()
|
||||||
? survey.surveyUrl.split('?')[0]
|
? survey.surveyUrl.split('?')[0]
|
||||||
: konKiwiPlaceholderPrefix
|
: konKiwiPlaceholderPrefix
|
||||||
const konKiwiQuery = (() => {
|
const konKiwiQuery = (() => {
|
||||||
@@ -191,21 +191,28 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
|
|||||||
return idx >= 0 ? url.slice(idx + 1) : ''
|
return idx >= 0 ? url.slice(idx + 1) : ''
|
||||||
})()
|
})()
|
||||||
|
|
||||||
const handleKonKiwiQueryChange = (query: string) => {
|
const handleKonKiwiQueryChange = (nextQuery: string) => {
|
||||||
onChange(survey.uiKey, {
|
// 파라미터만 수정: surveyUrl base(단축/placeholder)는 유지하고 뒤 파라미터만 교체한다.
|
||||||
surveyUrl: `${konKiwiPlaceholderPrefix}?${query}`,
|
const patch: Partial<ProjectSurvey> = {
|
||||||
surveyFullUrl: null,
|
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 [copiedField, setCopiedField] = useState<'url' | 'fullUrl' | null>(null)
|
||||||
const handleCopyUrl = async () => {
|
const copyToClipboard = async (value: string | null | undefined, field: 'url' | 'fullUrl') => {
|
||||||
const url = survey.surveyUrl?.trim() ?? ''
|
const text = value?.trim() ?? ''
|
||||||
if (!url) return
|
if (!text) return
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(url)
|
await navigator.clipboard.writeText(text)
|
||||||
setUrlCopied(true)
|
setCopiedField(field)
|
||||||
setTimeout(() => setUrlCopied(false), 1500)
|
setTimeout(() => setCopiedField((prev) => (prev === field ? null : prev)), 1500)
|
||||||
} catch {
|
} catch {
|
||||||
// 클립보드 접근 실패 시 무시
|
// 클립보드 접근 실패 시 무시
|
||||||
}
|
}
|
||||||
@@ -276,12 +283,19 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="space-y-2">
|
<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">
|
<div className="flex items-center gap-2">
|
||||||
{isKonKiwi ? (
|
{isKonKiwi ? (
|
||||||
<div className="flex flex-1 items-center">
|
<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">
|
<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>
|
</span>
|
||||||
<Input
|
<Input
|
||||||
ref={onRegisterFieldRef(survey.uiKey, 'surveyUrl')}
|
ref={onRegisterFieldRef(survey.uiKey, 'surveyUrl')}
|
||||||
@@ -308,16 +322,40 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
|
|||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={handleCopyUrl}
|
onClick={() => copyToClipboard(survey.surveyUrl, 'url')}
|
||||||
disabled={!survey.surveyUrl?.trim()}
|
disabled={!survey.surveyUrl?.trim()}
|
||||||
aria-label="설문 URL 복사"
|
aria-label="설문 URL 복사"
|
||||||
className="h-9 w-9 shrink-0 p-0"
|
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>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</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 && (
|
{survey.surveyTy === SurveyType.EXTERNAL && (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label className="text-base">설문 대시보드 URL</Label>
|
<Label className="text-base">설문 대시보드 URL</Label>
|
||||||
|
|||||||
Reference in New Issue
Block a user