mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-18 10:09:49 -06:00
fix: single use link generation (#5004)
This commit is contained in:
committed by
GitHub
parent
3ee8485ef0
commit
a5cac35cfd
@@ -60,7 +60,7 @@ export const ShareEmbedSurvey = ({
|
||||
|
||||
const [activeId, setActiveId] = useState(survey.type === "link" ? tabs[0].id : tabs[3].id);
|
||||
const [showView, setShowView] = useState<"start" | "embed" | "panel">("start");
|
||||
const [surveyUrl, setSurveyUrl] = useState(webAppUrl + "/s/" + survey.id);
|
||||
const [surveyUrl, setSurveyUrl] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
if (survey.type !== "link") {
|
||||
|
||||
@@ -6,10 +6,17 @@ interface SurveyLinkDisplayProps {
|
||||
|
||||
export const SurveyLinkDisplay = ({ surveyUrl }: SurveyLinkDisplayProps) => {
|
||||
return (
|
||||
<Input
|
||||
autoFocus={true}
|
||||
className="mt-2 w-full min-w-96 text-ellipsis rounded-lg border bg-white px-4 py-2 text-slate-800 caret-transparent"
|
||||
defaultValue={surveyUrl}
|
||||
/>
|
||||
<>
|
||||
{surveyUrl ? (
|
||||
<Input
|
||||
autoFocus={true}
|
||||
className="mt-2 w-full min-w-96 text-ellipsis rounded-lg border bg-white px-4 py-2 text-slate-800 caret-transparent"
|
||||
value={surveyUrl}
|
||||
/>
|
||||
) : (
|
||||
//loading state
|
||||
<div className="mt-2 h-10 w-full min-w-96 animate-pulse rounded-lg bg-slate-100 px-4 py-2 text-slate-800 caret-transparent"></div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -80,6 +80,7 @@ export const ShareSurveyLink = ({
|
||||
<Button
|
||||
title={t("environments.surveys.preview_survey_in_a_new_tab")}
|
||||
aria-label={t("environments.surveys.preview_survey_in_a_new_tab")}
|
||||
disabled={!surveyUrl}
|
||||
onClick={() => {
|
||||
let previewUrl = surveyUrl;
|
||||
if (previewUrl.includes("?")) {
|
||||
@@ -93,6 +94,7 @@ export const ShareSurveyLink = ({
|
||||
<SquareArrowOutUpRight />
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!surveyUrl}
|
||||
variant="secondary"
|
||||
title={t("environments.surveys.copy_survey_link_to_clipboard")}
|
||||
aria-label={t("environments.surveys.copy_survey_link_to_clipboard")}
|
||||
@@ -108,11 +110,13 @@ export const ShareSurveyLink = ({
|
||||
title={t("environments.surveys.summary.download_qr_code")}
|
||||
aria-label={t("environments.surveys.summary.download_qr_code")}
|
||||
size={"icon"}
|
||||
disabled={!surveyUrl}
|
||||
onClick={downloadQRCode}>
|
||||
<QrCode style={{ width: "24px", height: "24px" }} />
|
||||
</Button>
|
||||
{survey.singleUse?.enabled && (
|
||||
<Button
|
||||
disabled={!surveyUrl}
|
||||
title="Regenerate single use survey link"
|
||||
aria-label="Regenerate single use survey link"
|
||||
onClick={generateNewSingleUseLink}>
|
||||
|
||||
Reference in New Issue
Block a user