@ozguraltan/strapi-content-input 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/admin/{AnalyticsHubPage-K_trli5i.js → AnalyticsHubPage-0fb7chuv.js} +372 -7
- package/dist/admin/{AnalyticsHubPage-Dvpx3KsP.mjs → AnalyticsHubPage-BO6Lg1qh.mjs} +372 -7
- package/dist/admin/{ContentInputField-C2kmtUwD.mjs → ContentInputField-C-fh5qGC.mjs} +64 -19
- package/dist/admin/{ContentInputField-CjxYYEps.js → ContentInputField-CnVzTBNf.js} +64 -19
- package/dist/admin/{SurveyWidgetEditor-DOYxWop9.js → SurveyWidgetEditor-DNDtKbmo.js} +3069 -318
- package/dist/admin/{SurveyWidgetEditor-DMWOkHUt.mjs → SurveyWidgetEditor-DdZBpfbS.mjs} +3070 -320
- package/dist/admin/{index-B9C8Qrfd.js → index--fSIDKkt.js} +2 -2
- package/dist/admin/{index-AePRA0IB.mjs → index-BdrFmPg5.mjs} +2 -2
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/widgets/SurveyTransferCleanupModal.d.ts +35 -0
- package/dist/admin/src/components/widgets/surveyStepTreeOps.d.ts +54 -0
- package/dist/server/index.js +616 -25
- package/dist/server/index.mjs +616 -25
- package/dist/server/src/controllers/ci-survey.d.ts +4 -0
- package/dist/server/src/controllers/index.d.ts +4 -0
- package/dist/server/src/index.d.ts +46 -1
- package/dist/server/src/services/ci-form.d.ts +5 -1
- package/dist/server/src/services/ci-survey.d.ts +37 -0
- package/dist/server/src/services/index.d.ts +42 -1
- package/dist/server/src/utils/demoSeedState.d.ts +14 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useMemo, useRef, createContext, useContext, useEffect, useCallback } from "react";
|
|
2
|
+
import React, { useState, useMemo, useRef, createContext, useContext, useEffect, useCallback } from "react";
|
|
3
3
|
import ReactDOM, { createPortal } from "react-dom";
|
|
4
4
|
import { useFetchClient, useStrapiApp } from "@strapi/strapi/admin";
|
|
5
|
-
import { M as MaterialIcon } from "./index-
|
|
5
|
+
import { M as MaterialIcon } from "./index-BdrFmPg5.mjs";
|
|
6
6
|
import cloneDeep from "lodash/cloneDeep";
|
|
7
7
|
const ROW_PRESETS = [
|
|
8
8
|
{
|
|
@@ -10886,6 +10886,1440 @@ const SurveyLivePreviewPane = ({
|
|
|
10886
10886
|
}
|
|
10887
10887
|
);
|
|
10888
10888
|
};
|
|
10889
|
+
function triggerJsonDownload(filename, dataObj) {
|
|
10890
|
+
const jsonText = JSON.stringify(dataObj, null, 2);
|
|
10891
|
+
const blob = new Blob([jsonText], { type: "application/json;charset=utf-8" });
|
|
10892
|
+
const url = URL.createObjectURL(blob);
|
|
10893
|
+
const a = document.createElement("a");
|
|
10894
|
+
a.href = url;
|
|
10895
|
+
a.download = filename;
|
|
10896
|
+
document.body.appendChild(a);
|
|
10897
|
+
a.click();
|
|
10898
|
+
document.body.removeChild(a);
|
|
10899
|
+
URL.revokeObjectURL(url);
|
|
10900
|
+
}
|
|
10901
|
+
function sanitizeSurveyRecordForClientBundle(srv, rawResponses = []) {
|
|
10902
|
+
const cleanTitle = String(srv?.title || "Untitled Survey").trim();
|
|
10903
|
+
const cleanSlug = String(srv?.slug || "survey").trim();
|
|
10904
|
+
const sortedResponses = Array.isArray(rawResponses) ? [...rawResponses].sort((a, b) => {
|
|
10905
|
+
const ta = new Date(a?.submittedAt || a?.createdAt || 0).getTime();
|
|
10906
|
+
const tb = new Date(b?.submittedAt || b?.createdAt || 0).getTime();
|
|
10907
|
+
return ta - tb;
|
|
10908
|
+
}) : [];
|
|
10909
|
+
return {
|
|
10910
|
+
title: cleanTitle,
|
|
10911
|
+
titleI18n: srv?.titleI18n || { tr: cleanTitle, en: cleanTitle },
|
|
10912
|
+
slug: cleanSlug,
|
|
10913
|
+
description: srv?.description ?? { tr: "", en: "" },
|
|
10914
|
+
status: srv?.status || "published",
|
|
10915
|
+
displayMode: srv?.displayMode || "single_page",
|
|
10916
|
+
startsAt: srv?.startsAt || null,
|
|
10917
|
+
endsAt: srv?.endsAt || null,
|
|
10918
|
+
quotaLimit: srv?.quotaLimit ? Number(srv.quotaLimit) : null,
|
|
10919
|
+
submissionPolicy: srv?.submissionPolicy || "one_per_voter",
|
|
10920
|
+
anonymizeIp: srv?.anonymizeIp !== void 0 ? Boolean(srv.anonymizeIp) : true,
|
|
10921
|
+
showPublicResults: srv?.showPublicResults || "after_vote",
|
|
10922
|
+
allowBackNavigation: srv?.allowBackNavigation !== void 0 ? Boolean(srv.allowBackNavigation) : true,
|
|
10923
|
+
showProgressBar: srv?.showProgressBar !== void 0 ? Boolean(srv.showProgressBar) : true,
|
|
10924
|
+
useRecaptcha: srv?.useRecaptcha !== void 0 ? Boolean(srv.useRecaptcha) : false,
|
|
10925
|
+
recaptchaSiteKey: srv?.recaptchaSiteKey ? String(srv.recaptchaSiteKey) : "",
|
|
10926
|
+
steps: Array.isArray(srv?.steps) ? srv.steps : [],
|
|
10927
|
+
questions: Array.isArray(srv?.questions) ? srv.questions : [],
|
|
10928
|
+
settings: srv?.settings && typeof srv.settings === "object" ? srv.settings : {},
|
|
10929
|
+
version: Number(srv?.version || 1),
|
|
10930
|
+
responses: sortedResponses.map((r) => ({
|
|
10931
|
+
answers: r?.answers && typeof r.answers === "object" && !Array.isArray(r.answers) ? r.answers : {},
|
|
10932
|
+
otherTexts: r?.otherTexts && typeof r.otherTexts === "object" && !Array.isArray(r.otherTexts) ? r.otherTexts : {},
|
|
10933
|
+
score: typeof r?.score === "number" ? r.score : null,
|
|
10934
|
+
npsValue: typeof r?.npsValue === "number" ? r.npsValue : null,
|
|
10935
|
+
npsCategory: r?.npsCategory || null,
|
|
10936
|
+
locale: String(r?.locale || "en"),
|
|
10937
|
+
durationSeconds: Math.max(0, Number(r?.durationSeconds || 0) || 0),
|
|
10938
|
+
voterHash: r?.voterHash || null,
|
|
10939
|
+
respondentToken: r?.respondentToken || null,
|
|
10940
|
+
submittedAt: r?.submittedAt || r?.createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10941
|
+
}))
|
|
10942
|
+
};
|
|
10943
|
+
}
|
|
10944
|
+
function buildClientDraftBundle(draft) {
|
|
10945
|
+
const portableItem = sanitizeSurveyRecordForClientBundle(draft, []);
|
|
10946
|
+
return {
|
|
10947
|
+
filename: `${portableItem.slug}-structure.ci-survey.json`,
|
|
10948
|
+
bundle: {
|
|
10949
|
+
packageType: "strapi-content-input-survey-bundle",
|
|
10950
|
+
schemaVersion: 1,
|
|
10951
|
+
mode: "structure",
|
|
10952
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10953
|
+
surveyCount: 1,
|
|
10954
|
+
totalResponses: 0,
|
|
10955
|
+
surveys: [portableItem]
|
|
10956
|
+
}
|
|
10957
|
+
};
|
|
10958
|
+
}
|
|
10959
|
+
function isRouteNotLoadedError(err) {
|
|
10960
|
+
const status = err?.status || err?.response?.status;
|
|
10961
|
+
const msg = String(
|
|
10962
|
+
err?.response?.data?.error?.message || err?.message || ""
|
|
10963
|
+
).toLowerCase();
|
|
10964
|
+
return status === 404 && (msg === "not found" || msg.includes("not found"));
|
|
10965
|
+
}
|
|
10966
|
+
const SurveyExportModal = ({
|
|
10967
|
+
open,
|
|
10968
|
+
uiLocale = "en",
|
|
10969
|
+
targetSurvey,
|
|
10970
|
+
allowAllSurveys = false,
|
|
10971
|
+
defaultScope = "single",
|
|
10972
|
+
totalSurveysCount = 0,
|
|
10973
|
+
isUnsavedDraft = false,
|
|
10974
|
+
onClose
|
|
10975
|
+
}) => {
|
|
10976
|
+
const tr = uiLocale === "tr";
|
|
10977
|
+
const { get } = useFetchClient();
|
|
10978
|
+
const [scope, setScope] = useState(
|
|
10979
|
+
!targetSurvey && allowAllSurveys ? "all" : defaultScope
|
|
10980
|
+
);
|
|
10981
|
+
const [mode, setMode] = useState("full");
|
|
10982
|
+
const [busy, setBusy] = useState(false);
|
|
10983
|
+
const [errorMsg, setErrorMsg] = useState("");
|
|
10984
|
+
React.useEffect(() => {
|
|
10985
|
+
if (open) {
|
|
10986
|
+
setScope(!targetSurvey && allowAllSurveys ? "all" : defaultScope);
|
|
10987
|
+
setMode(isUnsavedDraft ? "structure" : "full");
|
|
10988
|
+
setErrorMsg("");
|
|
10989
|
+
}
|
|
10990
|
+
}, [open, targetSurvey, allowAllSurveys, defaultScope, isUnsavedDraft]);
|
|
10991
|
+
if (!open || typeof document === "undefined") return null;
|
|
10992
|
+
const handleExport = async () => {
|
|
10993
|
+
setBusy(true);
|
|
10994
|
+
setErrorMsg("");
|
|
10995
|
+
try {
|
|
10996
|
+
if (scope === "single" && targetSurvey && isUnsavedDraft) {
|
|
10997
|
+
const localPkg = buildClientDraftBundle(targetSurvey);
|
|
10998
|
+
triggerJsonDownload(localPkg.filename, localPkg.bundle);
|
|
10999
|
+
onClose();
|
|
11000
|
+
return;
|
|
11001
|
+
}
|
|
11002
|
+
const targetParam = scope === "all" ? "all" : String(targetSurvey?.slug || targetSurvey?.id || "");
|
|
11003
|
+
if (!targetParam) {
|
|
11004
|
+
setErrorMsg(tr ? "Dışa aktarılacak anket bulunamadı." : "No survey selected.");
|
|
11005
|
+
return;
|
|
11006
|
+
}
|
|
11007
|
+
try {
|
|
11008
|
+
const res = await get(
|
|
11009
|
+
`/content-input/survey-bundle/export?target=${encodeURIComponent(
|
|
11010
|
+
targetParam
|
|
11011
|
+
)}&mode=${mode}`
|
|
11012
|
+
);
|
|
11013
|
+
const payload = res?.data;
|
|
11014
|
+
if (payload?.bundle) {
|
|
11015
|
+
triggerJsonDownload(
|
|
11016
|
+
payload.filename || `survey-${mode}.ci-survey.json`,
|
|
11017
|
+
payload.bundle
|
|
11018
|
+
);
|
|
11019
|
+
onClose();
|
|
11020
|
+
return;
|
|
11021
|
+
}
|
|
11022
|
+
} catch (bundleErr) {
|
|
11023
|
+
if (!isRouteNotLoadedError(bundleErr)) {
|
|
11024
|
+
throw bundleErr;
|
|
11025
|
+
}
|
|
11026
|
+
let list = [];
|
|
11027
|
+
if (scope === "all") {
|
|
11028
|
+
const allRes = await get("/content-input/surveys");
|
|
11029
|
+
list = Array.isArray(allRes?.data) ? allRes.data : [];
|
|
11030
|
+
} else {
|
|
11031
|
+
const oneRes = await get(
|
|
11032
|
+
`/content-input/surveys/${encodeURIComponent(targetParam)}`
|
|
11033
|
+
);
|
|
11034
|
+
if (oneRes?.data) list = [oneRes.data];
|
|
11035
|
+
}
|
|
11036
|
+
if (list.length === 0) {
|
|
11037
|
+
throw new Error(tr ? "Anket bulunamadı." : "Survey not found.");
|
|
11038
|
+
}
|
|
11039
|
+
let totalResponses = 0;
|
|
11040
|
+
const portableSurveys = [];
|
|
11041
|
+
for (const srv of list) {
|
|
11042
|
+
let rawResps = [];
|
|
11043
|
+
if (mode === "full" && srv?.slug) {
|
|
11044
|
+
const rRes = await get(
|
|
11045
|
+
`/content-input/surveys/${encodeURIComponent(srv.slug)}/responses?limit=500`
|
|
11046
|
+
);
|
|
11047
|
+
rawResps = Array.isArray(rRes?.data) ? rRes.data : [];
|
|
11048
|
+
}
|
|
11049
|
+
const item = sanitizeSurveyRecordForClientBundle(srv, rawResps);
|
|
11050
|
+
totalResponses += item.responses.length;
|
|
11051
|
+
portableSurveys.push(item);
|
|
11052
|
+
}
|
|
11053
|
+
const dateStamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
11054
|
+
const modeSuffix = mode === "full" ? "full-backup" : "structure";
|
|
11055
|
+
const fallbackFilename = scope === "single" && portableSurveys[0]?.slug ? `${portableSurveys[0].slug}-${modeSuffix}.ci-survey.json` : `ci-surveys-all-${modeSuffix}-${dateStamp}.ci-survey.json`;
|
|
11056
|
+
triggerJsonDownload(fallbackFilename, {
|
|
11057
|
+
packageType: "strapi-content-input-survey-bundle",
|
|
11058
|
+
schemaVersion: 1,
|
|
11059
|
+
mode,
|
|
11060
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11061
|
+
surveyCount: portableSurveys.length,
|
|
11062
|
+
totalResponses,
|
|
11063
|
+
surveys: portableSurveys
|
|
11064
|
+
});
|
|
11065
|
+
onClose();
|
|
11066
|
+
return;
|
|
11067
|
+
}
|
|
11068
|
+
} catch (err) {
|
|
11069
|
+
setErrorMsg(err?.message || (tr ? "Dışa aktarma başarısız oldu." : "Export failed."));
|
|
11070
|
+
} finally {
|
|
11071
|
+
setBusy(false);
|
|
11072
|
+
}
|
|
11073
|
+
};
|
|
11074
|
+
return createPortal(
|
|
11075
|
+
/* @__PURE__ */ jsx(
|
|
11076
|
+
"div",
|
|
11077
|
+
{
|
|
11078
|
+
className: "ci-root",
|
|
11079
|
+
style: {
|
|
11080
|
+
position: "fixed",
|
|
11081
|
+
inset: 0,
|
|
11082
|
+
background: "rgba(15, 23, 42, 0.68)",
|
|
11083
|
+
zIndex: 310,
|
|
11084
|
+
display: "flex",
|
|
11085
|
+
alignItems: "center",
|
|
11086
|
+
justifyContent: "center",
|
|
11087
|
+
padding: 16
|
|
11088
|
+
},
|
|
11089
|
+
onClick: onClose,
|
|
11090
|
+
children: /* @__PURE__ */ jsxs(
|
|
11091
|
+
"div",
|
|
11092
|
+
{
|
|
11093
|
+
style: {
|
|
11094
|
+
width: "100%",
|
|
11095
|
+
maxWidth: 540,
|
|
11096
|
+
background: "#ffffff",
|
|
11097
|
+
borderRadius: 12,
|
|
11098
|
+
boxShadow: "0 24px 54px rgba(15, 23, 42, 0.4)",
|
|
11099
|
+
overflow: "hidden",
|
|
11100
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
|
|
11101
|
+
},
|
|
11102
|
+
onClick: (e) => e.stopPropagation(),
|
|
11103
|
+
children: [
|
|
11104
|
+
/* @__PURE__ */ jsxs(
|
|
11105
|
+
"div",
|
|
11106
|
+
{
|
|
11107
|
+
style: {
|
|
11108
|
+
padding: "14px 18px",
|
|
11109
|
+
background: "#0f172a",
|
|
11110
|
+
color: "#ffffff",
|
|
11111
|
+
display: "flex",
|
|
11112
|
+
alignItems: "center",
|
|
11113
|
+
justifyContent: "space-between"
|
|
11114
|
+
},
|
|
11115
|
+
children: [
|
|
11116
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
11117
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "download", size: 20, color: "#38bdf8" }),
|
|
11118
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 700 }, children: tr ? "Anket Paketi Dışa Aktar (.ci-survey.json)" : "Export Survey Package (.ci-survey.json)" })
|
|
11119
|
+
] }),
|
|
11120
|
+
/* @__PURE__ */ jsx(
|
|
11121
|
+
"button",
|
|
11122
|
+
{
|
|
11123
|
+
type: "button",
|
|
11124
|
+
onClick: onClose,
|
|
11125
|
+
style: {
|
|
11126
|
+
border: "none",
|
|
11127
|
+
background: "transparent",
|
|
11128
|
+
color: "#cbd5e1",
|
|
11129
|
+
fontSize: 18,
|
|
11130
|
+
cursor: "pointer"
|
|
11131
|
+
},
|
|
11132
|
+
children: "×"
|
|
11133
|
+
}
|
|
11134
|
+
)
|
|
11135
|
+
]
|
|
11136
|
+
}
|
|
11137
|
+
),
|
|
11138
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: 18, display: "flex", flexDirection: "column", gap: 14 }, children: [
|
|
11139
|
+
allowAllSurveys && /* @__PURE__ */ jsxs("div", { children: [
|
|
11140
|
+
/* @__PURE__ */ jsx(
|
|
11141
|
+
"div",
|
|
11142
|
+
{
|
|
11143
|
+
style: {
|
|
11144
|
+
fontSize: 11.5,
|
|
11145
|
+
fontWeight: 700,
|
|
11146
|
+
color: "#334155",
|
|
11147
|
+
marginBottom: 6
|
|
11148
|
+
},
|
|
11149
|
+
children: tr ? "1. Dışa Aktarım Kapsamı" : "1. Export Scope"
|
|
11150
|
+
}
|
|
11151
|
+
),
|
|
11152
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
|
|
11153
|
+
/* @__PURE__ */ jsxs(
|
|
11154
|
+
"button",
|
|
11155
|
+
{
|
|
11156
|
+
type: "button",
|
|
11157
|
+
disabled: !targetSurvey,
|
|
11158
|
+
onClick: () => setScope("single"),
|
|
11159
|
+
style: {
|
|
11160
|
+
padding: "9px 10px",
|
|
11161
|
+
borderRadius: 8,
|
|
11162
|
+
border: scope === "single" ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
11163
|
+
background: scope === "single" ? "#eff6ff" : "#f8fafc",
|
|
11164
|
+
color: !targetSurvey ? "#94a3b8" : scope === "single" ? "#1e3a8a" : "#334155",
|
|
11165
|
+
fontSize: 12,
|
|
11166
|
+
fontWeight: 700,
|
|
11167
|
+
cursor: !targetSurvey ? "not-allowed" : "pointer",
|
|
11168
|
+
textAlign: "left"
|
|
11169
|
+
},
|
|
11170
|
+
children: [
|
|
11171
|
+
/* @__PURE__ */ jsx("div", { children: tr ? "Seçili Anket" : "Selected Survey" }),
|
|
11172
|
+
/* @__PURE__ */ jsx(
|
|
11173
|
+
"div",
|
|
11174
|
+
{
|
|
11175
|
+
style: {
|
|
11176
|
+
fontSize: 10.5,
|
|
11177
|
+
fontWeight: 500,
|
|
11178
|
+
color: "#64748b",
|
|
11179
|
+
marginTop: 2,
|
|
11180
|
+
overflow: "hidden",
|
|
11181
|
+
textOverflow: "ellipsis",
|
|
11182
|
+
whiteSpace: "nowrap"
|
|
11183
|
+
},
|
|
11184
|
+
children: targetSurvey ? targetSurvey.title : "-"
|
|
11185
|
+
}
|
|
11186
|
+
)
|
|
11187
|
+
]
|
|
11188
|
+
}
|
|
11189
|
+
),
|
|
11190
|
+
/* @__PURE__ */ jsxs(
|
|
11191
|
+
"button",
|
|
11192
|
+
{
|
|
11193
|
+
type: "button",
|
|
11194
|
+
disabled: totalSurveysCount === 0,
|
|
11195
|
+
onClick: () => setScope("all"),
|
|
11196
|
+
style: {
|
|
11197
|
+
padding: "9px 10px",
|
|
11198
|
+
borderRadius: 8,
|
|
11199
|
+
border: scope === "all" ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
11200
|
+
background: scope === "all" ? "#eff6ff" : "#f8fafc",
|
|
11201
|
+
color: totalSurveysCount === 0 ? "#94a3b8" : scope === "all" ? "#1e3a8a" : "#334155",
|
|
11202
|
+
fontSize: 12,
|
|
11203
|
+
fontWeight: 700,
|
|
11204
|
+
cursor: totalSurveysCount === 0 ? "not-allowed" : "pointer",
|
|
11205
|
+
textAlign: "left"
|
|
11206
|
+
},
|
|
11207
|
+
children: [
|
|
11208
|
+
/* @__PURE__ */ jsx("div", { children: tr ? "Tüm Anketler (Toplu Paket)" : "All Surveys (Bundle)" }),
|
|
11209
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10.5, fontWeight: 500, color: "#64748b", marginTop: 2 }, children: tr ? `${totalSurveysCount} anket tek dosyada` : `${totalSurveysCount} surveys in one file` })
|
|
11210
|
+
]
|
|
11211
|
+
}
|
|
11212
|
+
)
|
|
11213
|
+
] })
|
|
11214
|
+
] }),
|
|
11215
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11216
|
+
/* @__PURE__ */ jsx(
|
|
11217
|
+
"div",
|
|
11218
|
+
{
|
|
11219
|
+
style: {
|
|
11220
|
+
fontSize: 11.5,
|
|
11221
|
+
fontWeight: 700,
|
|
11222
|
+
color: "#334155",
|
|
11223
|
+
marginBottom: 6
|
|
11224
|
+
},
|
|
11225
|
+
children: allowAllSurveys ? tr ? "2. Paket İçeriği Seçin" : "2. Choose Package Mode" : tr ? "Paket İçeriği Seçin" : "Choose Package Mode"
|
|
11226
|
+
}
|
|
11227
|
+
),
|
|
11228
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
11229
|
+
/* @__PURE__ */ jsxs(
|
|
11230
|
+
"label",
|
|
11231
|
+
{
|
|
11232
|
+
onClick: () => setMode("structure"),
|
|
11233
|
+
style: {
|
|
11234
|
+
padding: 12,
|
|
11235
|
+
borderRadius: 9,
|
|
11236
|
+
border: mode === "structure" ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
11237
|
+
background: mode === "structure" ? "#eff6ff" : "#ffffff",
|
|
11238
|
+
cursor: "pointer",
|
|
11239
|
+
display: "flex",
|
|
11240
|
+
alignItems: "flex-start",
|
|
11241
|
+
gap: 10
|
|
11242
|
+
},
|
|
11243
|
+
children: [
|
|
11244
|
+
/* @__PURE__ */ jsx(
|
|
11245
|
+
"input",
|
|
11246
|
+
{
|
|
11247
|
+
type: "radio",
|
|
11248
|
+
checked: mode === "structure",
|
|
11249
|
+
onChange: () => setMode("structure"),
|
|
11250
|
+
style: { marginTop: 3 }
|
|
11251
|
+
}
|
|
11252
|
+
),
|
|
11253
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11254
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12.5, fontWeight: 700, color: "#0f172a" }, children: tr ? "Sadece Yapı (Şema, Kategoriler, Sorular & Kurallar)" : "Structure Only (Schema, Steps, Questions & Logic)" }),
|
|
11255
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "#475569", marginTop: 3, lineHeight: 1.45 }, children: tr ? "Tüm adımlar, çok dilli metinler, ölçek etiketleri ve koşullu mantık kurallarını dışa aktarır. Yanıt verisi içermez (0 yanıt). Şablon taşımak için idealdir." : "Exports all wizard steps, localized labels, scale labels, and skip-logic rules without participant responses (0 responses). Ideal for templates." })
|
|
11256
|
+
] })
|
|
11257
|
+
]
|
|
11258
|
+
}
|
|
11259
|
+
),
|
|
11260
|
+
/* @__PURE__ */ jsxs(
|
|
11261
|
+
"label",
|
|
11262
|
+
{
|
|
11263
|
+
onClick: () => {
|
|
11264
|
+
if (!isUnsavedDraft) setMode("full");
|
|
11265
|
+
},
|
|
11266
|
+
style: {
|
|
11267
|
+
padding: 12,
|
|
11268
|
+
borderRadius: 9,
|
|
11269
|
+
border: mode === "full" ? "2px solid #059669" : "1px solid #cbd5e1",
|
|
11270
|
+
background: isUnsavedDraft ? "#f8fafc" : mode === "full" ? "#ecfdf5" : "#ffffff",
|
|
11271
|
+
opacity: isUnsavedDraft ? 0.6 : 1,
|
|
11272
|
+
cursor: isUnsavedDraft ? "not-allowed" : "pointer",
|
|
11273
|
+
display: "flex",
|
|
11274
|
+
alignItems: "flex-start",
|
|
11275
|
+
gap: 10
|
|
11276
|
+
},
|
|
11277
|
+
children: [
|
|
11278
|
+
/* @__PURE__ */ jsx(
|
|
11279
|
+
"input",
|
|
11280
|
+
{
|
|
11281
|
+
type: "radio",
|
|
11282
|
+
disabled: isUnsavedDraft,
|
|
11283
|
+
checked: mode === "full",
|
|
11284
|
+
onChange: () => setMode("full"),
|
|
11285
|
+
style: { marginTop: 3 }
|
|
11286
|
+
}
|
|
11287
|
+
),
|
|
11288
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11289
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12.5, fontWeight: 700, color: "#0f172a" }, children: tr ? "Yapı + Yanıt Verileri (Tam Yedek & Rapor Canlandırma)" : "Structure + Response Data (Full Backup & Analytics Restore)" }),
|
|
11290
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "#475569", marginTop: 3, lineHeight: 1.45 }, children: isUnsavedDraft ? tr ? "Bu taslak henüz kaydedilmediği için sunucuda yanıt verisi bulunmuyor." : "Save this draft first to export server responses." : tr ? "Anket şemasıyla birlikte tüm katılımcı yanıtlarını, NPS skorlarını ve tarihçeyi dışa aktarır. İçe aktarıldığında tüm grafikler birebir canlanır." : "Includes complete survey structure plus all recorded responses, NPS metrics, and timestamps so charts and Excel exports revive 1:1." })
|
|
11291
|
+
] })
|
|
11292
|
+
]
|
|
11293
|
+
}
|
|
11294
|
+
)
|
|
11295
|
+
] })
|
|
11296
|
+
] }),
|
|
11297
|
+
/* @__PURE__ */ jsx(
|
|
11298
|
+
"div",
|
|
11299
|
+
{
|
|
11300
|
+
style: {
|
|
11301
|
+
padding: "8px 11px",
|
|
11302
|
+
borderRadius: 7,
|
|
11303
|
+
background: "#f8fafc",
|
|
11304
|
+
border: "1px solid #e2e8f0",
|
|
11305
|
+
fontSize: 11,
|
|
11306
|
+
color: "#64748b"
|
|
11307
|
+
},
|
|
11308
|
+
children: tr ? "Güvenlik notu: Gizli reCAPTCHA Secret Key ve özel SMTP parolaları dışa aktarılan JSON paketine dahil edilmez." : "Security note: Private reCAPTCHA secret keys and SMTP credentials are automatically stripped from exported packages."
|
|
11309
|
+
}
|
|
11310
|
+
),
|
|
11311
|
+
errorMsg && /* @__PURE__ */ jsx(
|
|
11312
|
+
"div",
|
|
11313
|
+
{
|
|
11314
|
+
style: {
|
|
11315
|
+
padding: "8px 12px",
|
|
11316
|
+
borderRadius: 7,
|
|
11317
|
+
background: "#fee2e2",
|
|
11318
|
+
color: "#991b1b",
|
|
11319
|
+
fontSize: 11.5,
|
|
11320
|
+
fontWeight: 600
|
|
11321
|
+
},
|
|
11322
|
+
children: errorMsg
|
|
11323
|
+
}
|
|
11324
|
+
),
|
|
11325
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
|
|
11326
|
+
/* @__PURE__ */ jsx(
|
|
11327
|
+
"button",
|
|
11328
|
+
{
|
|
11329
|
+
type: "button",
|
|
11330
|
+
onClick: onClose,
|
|
11331
|
+
style: {
|
|
11332
|
+
padding: "8px 14px",
|
|
11333
|
+
borderRadius: 7,
|
|
11334
|
+
border: "1px solid #cbd5e1",
|
|
11335
|
+
background: "#ffffff",
|
|
11336
|
+
color: "#334155",
|
|
11337
|
+
fontSize: 12,
|
|
11338
|
+
fontWeight: 600,
|
|
11339
|
+
cursor: "pointer"
|
|
11340
|
+
},
|
|
11341
|
+
children: tr ? "Vazgeç" : "Cancel"
|
|
11342
|
+
}
|
|
11343
|
+
),
|
|
11344
|
+
/* @__PURE__ */ jsxs(
|
|
11345
|
+
"button",
|
|
11346
|
+
{
|
|
11347
|
+
type: "button",
|
|
11348
|
+
disabled: busy,
|
|
11349
|
+
onClick: handleExport,
|
|
11350
|
+
style: {
|
|
11351
|
+
padding: "8px 16px",
|
|
11352
|
+
borderRadius: 7,
|
|
11353
|
+
border: "none",
|
|
11354
|
+
background: mode === "full" ? "#059669" : "#2563eb",
|
|
11355
|
+
color: "#ffffff",
|
|
11356
|
+
fontSize: 12,
|
|
11357
|
+
fontWeight: 700,
|
|
11358
|
+
cursor: "pointer",
|
|
11359
|
+
display: "inline-flex",
|
|
11360
|
+
alignItems: "center",
|
|
11361
|
+
gap: 6
|
|
11362
|
+
},
|
|
11363
|
+
children: [
|
|
11364
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "download", size: 16, color: "#fff" }),
|
|
11365
|
+
/* @__PURE__ */ jsx("span", { children: busy ? tr ? "Hazırlanıyor..." : "Preparing..." : tr ? "JSON Paketini İndir" : "Download JSON Package" })
|
|
11366
|
+
]
|
|
11367
|
+
}
|
|
11368
|
+
)
|
|
11369
|
+
] })
|
|
11370
|
+
] })
|
|
11371
|
+
]
|
|
11372
|
+
}
|
|
11373
|
+
)
|
|
11374
|
+
}
|
|
11375
|
+
),
|
|
11376
|
+
document.body
|
|
11377
|
+
);
|
|
11378
|
+
};
|
|
11379
|
+
function inspectSurveyBundle(raw, existingSlugs) {
|
|
11380
|
+
let items = [];
|
|
11381
|
+
let mode = "structure";
|
|
11382
|
+
if (Array.isArray(raw)) {
|
|
11383
|
+
items = raw;
|
|
11384
|
+
} else if (raw && typeof raw === "object") {
|
|
11385
|
+
if (typeof raw.mode === "string") mode = raw.mode;
|
|
11386
|
+
if (Array.isArray(raw.surveys)) {
|
|
11387
|
+
items = raw.surveys;
|
|
11388
|
+
} else if (Array.isArray(raw.questions) || raw.title || raw.slug) {
|
|
11389
|
+
items = [raw];
|
|
11390
|
+
}
|
|
11391
|
+
}
|
|
11392
|
+
const valid = items.filter(
|
|
11393
|
+
(it) => it && typeof it === "object" && (Array.isArray(it.questions) || it.title)
|
|
11394
|
+
);
|
|
11395
|
+
if (valid.length === 0) return null;
|
|
11396
|
+
let totalQuestions = 0;
|
|
11397
|
+
let totalResponses = 0;
|
|
11398
|
+
let conflictCount = 0;
|
|
11399
|
+
const surveys = valid.map((it) => {
|
|
11400
|
+
const slug = String(it.slug || "").trim();
|
|
11401
|
+
const stepCount = Array.isArray(it.steps) ? it.steps.length : 0;
|
|
11402
|
+
const questionCount = Array.isArray(it.questions) ? it.questions.length : 0;
|
|
11403
|
+
const responseCount = Array.isArray(it.responses) ? it.responses.length : 0;
|
|
11404
|
+
const hasConflict = Boolean(slug && existingSlugs.has(slug));
|
|
11405
|
+
totalQuestions += questionCount;
|
|
11406
|
+
totalResponses += responseCount;
|
|
11407
|
+
if (hasConflict) conflictCount += 1;
|
|
11408
|
+
return {
|
|
11409
|
+
title: String(it.title || slug || "Survey"),
|
|
11410
|
+
slug: slug || "(auto)",
|
|
11411
|
+
displayMode: String(it.displayMode || "single_page"),
|
|
11412
|
+
stepCount,
|
|
11413
|
+
questionCount,
|
|
11414
|
+
responseCount,
|
|
11415
|
+
hasConflict
|
|
11416
|
+
};
|
|
11417
|
+
});
|
|
11418
|
+
if (totalResponses > 0) mode = "full";
|
|
11419
|
+
return {
|
|
11420
|
+
raw,
|
|
11421
|
+
mode,
|
|
11422
|
+
surveys,
|
|
11423
|
+
totalQuestions,
|
|
11424
|
+
totalResponses,
|
|
11425
|
+
conflictCount
|
|
11426
|
+
};
|
|
11427
|
+
}
|
|
11428
|
+
const SurveyImportModal = ({
|
|
11429
|
+
open,
|
|
11430
|
+
uiLocale = "en",
|
|
11431
|
+
existingSlugs = [],
|
|
11432
|
+
onClose,
|
|
11433
|
+
onImported
|
|
11434
|
+
}) => {
|
|
11435
|
+
const tr = uiLocale === "tr";
|
|
11436
|
+
const { post } = useFetchClient();
|
|
11437
|
+
const fileInputRef = useRef(null);
|
|
11438
|
+
const [fileName, setFileName] = useState("");
|
|
11439
|
+
const [summary, setSummary] = useState(null);
|
|
11440
|
+
const [conflictStrategy, setConflictStrategy] = useState(
|
|
11441
|
+
"duplicate"
|
|
11442
|
+
);
|
|
11443
|
+
const [includeResponses, setIncludeResponses] = useState(true);
|
|
11444
|
+
const [dragOver, setDragOver] = useState(false);
|
|
11445
|
+
const [importing, setImporting] = useState(false);
|
|
11446
|
+
const [errorMsg, setErrorMsg] = useState("");
|
|
11447
|
+
React.useEffect(() => {
|
|
11448
|
+
if (open) {
|
|
11449
|
+
setFileName("");
|
|
11450
|
+
setSummary(null);
|
|
11451
|
+
setConflictStrategy("duplicate");
|
|
11452
|
+
setIncludeResponses(true);
|
|
11453
|
+
setErrorMsg("");
|
|
11454
|
+
}
|
|
11455
|
+
}, [open]);
|
|
11456
|
+
if (!open || typeof document === "undefined") return null;
|
|
11457
|
+
const slugSet = new Set(existingSlugs.map((s) => String(s || "").trim()).filter(Boolean));
|
|
11458
|
+
const parseFile = (file) => {
|
|
11459
|
+
setErrorMsg("");
|
|
11460
|
+
setFileName(file.name);
|
|
11461
|
+
const reader = new FileReader();
|
|
11462
|
+
reader.onload = () => {
|
|
11463
|
+
try {
|
|
11464
|
+
const parsed = JSON.parse(String(reader.result || ""));
|
|
11465
|
+
const inspected = inspectSurveyBundle(parsed, slugSet);
|
|
11466
|
+
if (!inspected) {
|
|
11467
|
+
setSummary(null);
|
|
11468
|
+
setErrorMsg(
|
|
11469
|
+
tr ? "Seçilen JSON dosyasında geçerli bir ContentInput anket tanımı bulunamadı." : "No valid ContentInput survey definition found in this JSON file."
|
|
11470
|
+
);
|
|
11471
|
+
return;
|
|
11472
|
+
}
|
|
11473
|
+
setSummary(inspected);
|
|
11474
|
+
setIncludeResponses(inspected.totalResponses > 0);
|
|
11475
|
+
} catch {
|
|
11476
|
+
setSummary(null);
|
|
11477
|
+
setErrorMsg(
|
|
11478
|
+
tr ? "Dosya geçerli bir JSON formatında değil." : "Invalid JSON file format."
|
|
11479
|
+
);
|
|
11480
|
+
}
|
|
11481
|
+
};
|
|
11482
|
+
reader.readAsText(file, "utf-8");
|
|
11483
|
+
};
|
|
11484
|
+
const handleImport = async () => {
|
|
11485
|
+
if (!summary) return;
|
|
11486
|
+
setImporting(true);
|
|
11487
|
+
setErrorMsg("");
|
|
11488
|
+
try {
|
|
11489
|
+
const res = await post("/content-input/survey-bundle/import", {
|
|
11490
|
+
bundle: summary.raw,
|
|
11491
|
+
conflictStrategy,
|
|
11492
|
+
includeResponses: summary.totalResponses > 0 ? includeResponses : false
|
|
11493
|
+
});
|
|
11494
|
+
const data = res?.data || {};
|
|
11495
|
+
onImported({
|
|
11496
|
+
importedCount: Number(data.importedCount || 0),
|
|
11497
|
+
importedResponsesCount: Number(data.importedResponsesCount || 0),
|
|
11498
|
+
importedSurveys: Array.isArray(data.importedSurveys) ? data.importedSurveys : []
|
|
11499
|
+
});
|
|
11500
|
+
onClose();
|
|
11501
|
+
} catch (err) {
|
|
11502
|
+
if (isRouteNotLoadedError(err)) {
|
|
11503
|
+
setErrorMsg(
|
|
11504
|
+
tr ? "Yeni sunucu rotalarının aktif olması için lütfen Strapi sunucusunu (npm run dev) bir kez yeniden başlatın." : "Please restart the Strapi server (npm run dev) once so the new backend routes take effect."
|
|
11505
|
+
);
|
|
11506
|
+
} else {
|
|
11507
|
+
setErrorMsg(
|
|
11508
|
+
err?.response?.data?.error?.message || err?.message || (tr ? "İçe aktarma başarısız oldu." : "Import failed.")
|
|
11509
|
+
);
|
|
11510
|
+
}
|
|
11511
|
+
} finally {
|
|
11512
|
+
setImporting(false);
|
|
11513
|
+
}
|
|
11514
|
+
};
|
|
11515
|
+
return createPortal(
|
|
11516
|
+
/* @__PURE__ */ jsx(
|
|
11517
|
+
"div",
|
|
11518
|
+
{
|
|
11519
|
+
className: "ci-root",
|
|
11520
|
+
style: {
|
|
11521
|
+
position: "fixed",
|
|
11522
|
+
inset: 0,
|
|
11523
|
+
background: "rgba(15, 23, 42, 0.68)",
|
|
11524
|
+
zIndex: 310,
|
|
11525
|
+
display: "flex",
|
|
11526
|
+
alignItems: "center",
|
|
11527
|
+
justifyContent: "center",
|
|
11528
|
+
padding: 16
|
|
11529
|
+
},
|
|
11530
|
+
onClick: onClose,
|
|
11531
|
+
children: /* @__PURE__ */ jsxs(
|
|
11532
|
+
"div",
|
|
11533
|
+
{
|
|
11534
|
+
style: {
|
|
11535
|
+
width: "100%",
|
|
11536
|
+
maxWidth: 590,
|
|
11537
|
+
maxHeight: "90vh",
|
|
11538
|
+
background: "#ffffff",
|
|
11539
|
+
borderRadius: 12,
|
|
11540
|
+
boxShadow: "0 24px 54px rgba(15, 23, 42, 0.4)",
|
|
11541
|
+
display: "flex",
|
|
11542
|
+
flexDirection: "column",
|
|
11543
|
+
overflow: "hidden",
|
|
11544
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
|
|
11545
|
+
},
|
|
11546
|
+
onClick: (e) => e.stopPropagation(),
|
|
11547
|
+
children: [
|
|
11548
|
+
/* @__PURE__ */ jsxs(
|
|
11549
|
+
"div",
|
|
11550
|
+
{
|
|
11551
|
+
style: {
|
|
11552
|
+
padding: "14px 18px",
|
|
11553
|
+
background: "#0f172a",
|
|
11554
|
+
color: "#ffffff",
|
|
11555
|
+
display: "flex",
|
|
11556
|
+
alignItems: "center",
|
|
11557
|
+
justifyContent: "space-between"
|
|
11558
|
+
},
|
|
11559
|
+
children: [
|
|
11560
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
11561
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "upload_file", size: 20, color: "#38bdf8" }),
|
|
11562
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 700 }, children: tr ? "JSON Paketinden Anket Canlandır / İçe Aktar" : "Import & Revive Survey from JSON Package" })
|
|
11563
|
+
] }),
|
|
11564
|
+
/* @__PURE__ */ jsx(
|
|
11565
|
+
"button",
|
|
11566
|
+
{
|
|
11567
|
+
type: "button",
|
|
11568
|
+
onClick: onClose,
|
|
11569
|
+
style: {
|
|
11570
|
+
border: "none",
|
|
11571
|
+
background: "transparent",
|
|
11572
|
+
color: "#cbd5e1",
|
|
11573
|
+
fontSize: 18,
|
|
11574
|
+
cursor: "pointer"
|
|
11575
|
+
},
|
|
11576
|
+
children: "×"
|
|
11577
|
+
}
|
|
11578
|
+
)
|
|
11579
|
+
]
|
|
11580
|
+
}
|
|
11581
|
+
),
|
|
11582
|
+
/* @__PURE__ */ jsxs(
|
|
11583
|
+
"div",
|
|
11584
|
+
{
|
|
11585
|
+
style: {
|
|
11586
|
+
padding: 18,
|
|
11587
|
+
overflowY: "auto",
|
|
11588
|
+
display: "flex",
|
|
11589
|
+
flexDirection: "column",
|
|
11590
|
+
gap: 14
|
|
11591
|
+
},
|
|
11592
|
+
children: [
|
|
11593
|
+
/* @__PURE__ */ jsxs(
|
|
11594
|
+
"div",
|
|
11595
|
+
{
|
|
11596
|
+
onClick: () => fileInputRef.current?.click(),
|
|
11597
|
+
onDragOver: (e) => {
|
|
11598
|
+
e.preventDefault();
|
|
11599
|
+
setDragOver(true);
|
|
11600
|
+
},
|
|
11601
|
+
onDragLeave: () => setDragOver(false),
|
|
11602
|
+
onDrop: (e) => {
|
|
11603
|
+
e.preventDefault();
|
|
11604
|
+
setDragOver(false);
|
|
11605
|
+
const f = e.dataTransfer.files?.[0];
|
|
11606
|
+
if (f) parseFile(f);
|
|
11607
|
+
},
|
|
11608
|
+
style: {
|
|
11609
|
+
padding: "20px 16px",
|
|
11610
|
+
borderRadius: 10,
|
|
11611
|
+
border: dragOver ? "2px dashed #2563eb" : "2px dashed #cbd5e1",
|
|
11612
|
+
background: dragOver ? "#eff6ff" : "#f8fafc",
|
|
11613
|
+
textAlign: "center",
|
|
11614
|
+
cursor: "pointer",
|
|
11615
|
+
transition: "all 0.14s ease"
|
|
11616
|
+
},
|
|
11617
|
+
children: [
|
|
11618
|
+
/* @__PURE__ */ jsx(
|
|
11619
|
+
"input",
|
|
11620
|
+
{
|
|
11621
|
+
ref: fileInputRef,
|
|
11622
|
+
type: "file",
|
|
11623
|
+
accept: ".json,application/json",
|
|
11624
|
+
style: { display: "none" },
|
|
11625
|
+
onChange: (e) => {
|
|
11626
|
+
const f = e.target.files?.[0];
|
|
11627
|
+
if (f) parseFile(f);
|
|
11628
|
+
e.target.value = "";
|
|
11629
|
+
}
|
|
11630
|
+
}
|
|
11631
|
+
),
|
|
11632
|
+
/* @__PURE__ */ jsx(
|
|
11633
|
+
MaterialIcon,
|
|
11634
|
+
{
|
|
11635
|
+
name: "folder_open",
|
|
11636
|
+
size: 28,
|
|
11637
|
+
color: dragOver ? "#2563eb" : "#64748b"
|
|
11638
|
+
}
|
|
11639
|
+
),
|
|
11640
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12.5, fontWeight: 700, color: "#0f172a", marginTop: 6 }, children: fileName ? `${tr ? "Seçilen Dosya:" : "Selected File:"} ${fileName}` : tr ? ".ci-survey.json dosyasını buraya sürükleyin veya seçmek için tıklayın" : "Drop a .ci-survey.json package here or click to browse" }),
|
|
11641
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "#64748b", marginTop: 3 }, children: tr ? "Tekil anket veya çoklu anket yedek paketlerini (Sadece Yapı / Yapı + Veri) destekler." : "Supports both single-survey and multi-survey bundles (Structure-only or Full Backup)." })
|
|
11642
|
+
]
|
|
11643
|
+
}
|
|
11644
|
+
),
|
|
11645
|
+
summary && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11646
|
+
/* @__PURE__ */ jsxs(
|
|
11647
|
+
"div",
|
|
11648
|
+
{
|
|
11649
|
+
style: {
|
|
11650
|
+
padding: 12,
|
|
11651
|
+
borderRadius: 9,
|
|
11652
|
+
background: "#f8fafc",
|
|
11653
|
+
border: "1px solid #cbd5e1",
|
|
11654
|
+
display: "flex",
|
|
11655
|
+
flexDirection: "column",
|
|
11656
|
+
gap: 8
|
|
11657
|
+
},
|
|
11658
|
+
children: [
|
|
11659
|
+
/* @__PURE__ */ jsxs(
|
|
11660
|
+
"div",
|
|
11661
|
+
{
|
|
11662
|
+
style: {
|
|
11663
|
+
display: "flex",
|
|
11664
|
+
alignItems: "center",
|
|
11665
|
+
justifyContent: "space-between",
|
|
11666
|
+
flexWrap: "wrap",
|
|
11667
|
+
gap: 6
|
|
11668
|
+
},
|
|
11669
|
+
children: [
|
|
11670
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 12, fontWeight: 800, color: "#0f172a" }, children: tr ? "Paket Ön İzlemesi" : "Package Summary" }),
|
|
11671
|
+
/* @__PURE__ */ jsx(
|
|
11672
|
+
"span",
|
|
11673
|
+
{
|
|
11674
|
+
style: {
|
|
11675
|
+
padding: "2px 8px",
|
|
11676
|
+
borderRadius: 10,
|
|
11677
|
+
fontSize: 10.5,
|
|
11678
|
+
fontWeight: 800,
|
|
11679
|
+
background: summary.totalResponses > 0 ? "#dcfce7" : "#dbeafe",
|
|
11680
|
+
color: summary.totalResponses > 0 ? "#166534" : "#1e40af"
|
|
11681
|
+
},
|
|
11682
|
+
children: summary.totalResponses > 0 ? tr ? `YAPI + ${summary.totalResponses} YANIT` : `STRUCTURE + ${summary.totalResponses} RESPONSES` : tr ? "SADECE YAPI (ŞEMA)" : "STRUCTURE ONLY"
|
|
11683
|
+
}
|
|
11684
|
+
)
|
|
11685
|
+
]
|
|
11686
|
+
}
|
|
11687
|
+
),
|
|
11688
|
+
/* @__PURE__ */ jsx(
|
|
11689
|
+
"div",
|
|
11690
|
+
{
|
|
11691
|
+
style: {
|
|
11692
|
+
display: "flex",
|
|
11693
|
+
flexDirection: "column",
|
|
11694
|
+
gap: 5,
|
|
11695
|
+
maxHeight: 150,
|
|
11696
|
+
overflowY: "auto"
|
|
11697
|
+
},
|
|
11698
|
+
children: summary.surveys.map((s, idx) => /* @__PURE__ */ jsxs(
|
|
11699
|
+
"div",
|
|
11700
|
+
{
|
|
11701
|
+
style: {
|
|
11702
|
+
padding: "7px 10px",
|
|
11703
|
+
borderRadius: 7,
|
|
11704
|
+
background: "#ffffff",
|
|
11705
|
+
border: "1px solid #e2e8f0",
|
|
11706
|
+
display: "flex",
|
|
11707
|
+
alignItems: "center",
|
|
11708
|
+
justifyContent: "space-between",
|
|
11709
|
+
gap: 8,
|
|
11710
|
+
fontSize: 11.5
|
|
11711
|
+
},
|
|
11712
|
+
children: [
|
|
11713
|
+
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
11714
|
+
/* @__PURE__ */ jsx("div", { style: { fontWeight: 700, color: "#0f172a" }, children: s.title }),
|
|
11715
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 10.5, color: "#64748b" }, children: [
|
|
11716
|
+
/* @__PURE__ */ jsx("code", { children: s.slug }),
|
|
11717
|
+
" • ",
|
|
11718
|
+
/* @__PURE__ */ jsx("code", { children: s.displayMode }),
|
|
11719
|
+
" •",
|
|
11720
|
+
" ",
|
|
11721
|
+
s.stepCount > 0 ? `${s.stepCount} ${tr ? "adım, " : "steps, "}` : "",
|
|
11722
|
+
s.questionCount,
|
|
11723
|
+
" ",
|
|
11724
|
+
tr ? "soru" : "Qs",
|
|
11725
|
+
" •",
|
|
11726
|
+
" ",
|
|
11727
|
+
/* @__PURE__ */ jsx("strong", { children: s.responseCount }),
|
|
11728
|
+
" ",
|
|
11729
|
+
tr ? "yanıt" : "resp"
|
|
11730
|
+
] })
|
|
11731
|
+
] }),
|
|
11732
|
+
/* @__PURE__ */ jsx(
|
|
11733
|
+
"span",
|
|
11734
|
+
{
|
|
11735
|
+
style: {
|
|
11736
|
+
flexShrink: 0,
|
|
11737
|
+
padding: "2px 7px",
|
|
11738
|
+
borderRadius: 8,
|
|
11739
|
+
fontSize: 10,
|
|
11740
|
+
fontWeight: 700,
|
|
11741
|
+
background: s.hasConflict ? "#fef3c7" : "#ecfdf5",
|
|
11742
|
+
color: s.hasConflict ? "#92400e" : "#047857"
|
|
11743
|
+
},
|
|
11744
|
+
children: s.hasConflict ? tr ? "Mevcut Slug" : "Slug Exists" : tr ? "Yeni Kayıt" : "New Slug"
|
|
11745
|
+
}
|
|
11746
|
+
)
|
|
11747
|
+
]
|
|
11748
|
+
},
|
|
11749
|
+
`${s.slug}-${idx}`
|
|
11750
|
+
))
|
|
11751
|
+
}
|
|
11752
|
+
)
|
|
11753
|
+
]
|
|
11754
|
+
}
|
|
11755
|
+
),
|
|
11756
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11757
|
+
/* @__PURE__ */ jsx(
|
|
11758
|
+
"div",
|
|
11759
|
+
{
|
|
11760
|
+
style: {
|
|
11761
|
+
fontSize: 11.5,
|
|
11762
|
+
fontWeight: 700,
|
|
11763
|
+
color: "#334155",
|
|
11764
|
+
marginBottom: 6
|
|
11765
|
+
},
|
|
11766
|
+
children: tr ? "Aynı Slug Mevcutsa Nasıl Davranılsın?" : "Conflict Strategy (When Slug Already Exists)"
|
|
11767
|
+
}
|
|
11768
|
+
),
|
|
11769
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
|
|
11770
|
+
/* @__PURE__ */ jsxs(
|
|
11771
|
+
"button",
|
|
11772
|
+
{
|
|
11773
|
+
type: "button",
|
|
11774
|
+
onClick: () => setConflictStrategy("duplicate"),
|
|
11775
|
+
style: {
|
|
11776
|
+
padding: "9px 10px",
|
|
11777
|
+
borderRadius: 8,
|
|
11778
|
+
border: conflictStrategy === "duplicate" ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
11779
|
+
background: conflictStrategy === "duplicate" ? "#eff6ff" : "#ffffff",
|
|
11780
|
+
textAlign: "left",
|
|
11781
|
+
cursor: "pointer"
|
|
11782
|
+
},
|
|
11783
|
+
children: [
|
|
11784
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a" }, children: tr ? "Yeni Kopya Oluştur (_copy)" : "Create New Copy (_copy)" }),
|
|
11785
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10.5, color: "#64748b", marginTop: 2 }, children: tr ? "Mevcut ankete dokunmaz, ayrı bir kopya açar." : "Keeps existing survey untouched; creates unique slug." })
|
|
11786
|
+
]
|
|
11787
|
+
}
|
|
11788
|
+
),
|
|
11789
|
+
/* @__PURE__ */ jsxs(
|
|
11790
|
+
"button",
|
|
11791
|
+
{
|
|
11792
|
+
type: "button",
|
|
11793
|
+
onClick: () => setConflictStrategy("overwrite"),
|
|
11794
|
+
style: {
|
|
11795
|
+
padding: "9px 10px",
|
|
11796
|
+
borderRadius: 8,
|
|
11797
|
+
border: conflictStrategy === "overwrite" ? "2px solid #d97706" : "1px solid #cbd5e1",
|
|
11798
|
+
background: conflictStrategy === "overwrite" ? "#fffbeb" : "#ffffff",
|
|
11799
|
+
textAlign: "left",
|
|
11800
|
+
cursor: "pointer"
|
|
11801
|
+
},
|
|
11802
|
+
children: [
|
|
11803
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a" }, children: tr ? "Mevcut Anketin Üzerine Yaz" : "Overwrite Existing Survey" }),
|
|
11804
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10.5, color: "#64748b", marginTop: 2 }, children: tr ? "Aynı slug varsa yapıyı (ve seçiliyse yanıtları) günceller." : "Updates matching slug in place (and replaces responses if checked)." })
|
|
11805
|
+
]
|
|
11806
|
+
}
|
|
11807
|
+
)
|
|
11808
|
+
] })
|
|
11809
|
+
] }),
|
|
11810
|
+
summary.totalResponses > 0 && /* @__PURE__ */ jsxs(
|
|
11811
|
+
"label",
|
|
11812
|
+
{
|
|
11813
|
+
style: {
|
|
11814
|
+
padding: "10px 12px",
|
|
11815
|
+
borderRadius: 8,
|
|
11816
|
+
background: includeResponses ? "#ecfdf5" : "#f8fafc",
|
|
11817
|
+
border: includeResponses ? "1px solid #10b981" : "1px solid #cbd5e1",
|
|
11818
|
+
display: "flex",
|
|
11819
|
+
alignItems: "center",
|
|
11820
|
+
gap: 9,
|
|
11821
|
+
cursor: "pointer"
|
|
11822
|
+
},
|
|
11823
|
+
children: [
|
|
11824
|
+
/* @__PURE__ */ jsx(
|
|
11825
|
+
"input",
|
|
11826
|
+
{
|
|
11827
|
+
type: "checkbox",
|
|
11828
|
+
checked: includeResponses,
|
|
11829
|
+
onChange: (e) => setIncludeResponses(e.target.checked)
|
|
11830
|
+
}
|
|
11831
|
+
),
|
|
11832
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11833
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12, fontWeight: 700, color: "#0f172a" }, children: tr ? `Paketteki ${summary.totalResponses} Yanıt Verisini de İçe Aktar` : `Also Import ${summary.totalResponses} Recorded Responses` }),
|
|
11834
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 10.5, color: "#475569" }, children: tr ? "İşareti kaldırırsanız bu tam yedek yalnızca temiz şema (0 yanıt) olarak kurulur." : "Uncheck to import only the clean survey schema with 0 responses." })
|
|
11835
|
+
] })
|
|
11836
|
+
]
|
|
11837
|
+
}
|
|
11838
|
+
)
|
|
11839
|
+
] }),
|
|
11840
|
+
errorMsg && /* @__PURE__ */ jsx(
|
|
11841
|
+
"div",
|
|
11842
|
+
{
|
|
11843
|
+
style: {
|
|
11844
|
+
padding: "8px 12px",
|
|
11845
|
+
borderRadius: 7,
|
|
11846
|
+
background: "#fee2e2",
|
|
11847
|
+
color: "#991b1b",
|
|
11848
|
+
fontSize: 11.5,
|
|
11849
|
+
fontWeight: 600
|
|
11850
|
+
},
|
|
11851
|
+
children: errorMsg
|
|
11852
|
+
}
|
|
11853
|
+
),
|
|
11854
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
|
|
11855
|
+
/* @__PURE__ */ jsx(
|
|
11856
|
+
"button",
|
|
11857
|
+
{
|
|
11858
|
+
type: "button",
|
|
11859
|
+
onClick: onClose,
|
|
11860
|
+
style: {
|
|
11861
|
+
padding: "8px 14px",
|
|
11862
|
+
borderRadius: 7,
|
|
11863
|
+
border: "1px solid #cbd5e1",
|
|
11864
|
+
background: "#ffffff",
|
|
11865
|
+
color: "#334155",
|
|
11866
|
+
fontSize: 12,
|
|
11867
|
+
fontWeight: 600,
|
|
11868
|
+
cursor: "pointer"
|
|
11869
|
+
},
|
|
11870
|
+
children: tr ? "Vazgeç" : "Cancel"
|
|
11871
|
+
}
|
|
11872
|
+
),
|
|
11873
|
+
/* @__PURE__ */ jsxs(
|
|
11874
|
+
"button",
|
|
11875
|
+
{
|
|
11876
|
+
type: "button",
|
|
11877
|
+
disabled: !summary || importing,
|
|
11878
|
+
onClick: handleImport,
|
|
11879
|
+
style: {
|
|
11880
|
+
padding: "8px 16px",
|
|
11881
|
+
borderRadius: 7,
|
|
11882
|
+
border: "none",
|
|
11883
|
+
background: !summary ? "#94a3b8" : "#2563eb",
|
|
11884
|
+
color: "#ffffff",
|
|
11885
|
+
fontSize: 12,
|
|
11886
|
+
fontWeight: 700,
|
|
11887
|
+
cursor: !summary ? "not-allowed" : "pointer",
|
|
11888
|
+
display: "inline-flex",
|
|
11889
|
+
alignItems: "center",
|
|
11890
|
+
gap: 6
|
|
11891
|
+
},
|
|
11892
|
+
children: [
|
|
11893
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "publish", size: 16, color: "#fff" }),
|
|
11894
|
+
/* @__PURE__ */ jsx("span", { children: importing ? tr ? "İçe Aktarılıyor..." : "Importing..." : tr ? "Anketi Canlandır / İçe Aktar" : "Import Survey Package" })
|
|
11895
|
+
]
|
|
11896
|
+
}
|
|
11897
|
+
)
|
|
11898
|
+
] })
|
|
11899
|
+
]
|
|
11900
|
+
}
|
|
11901
|
+
)
|
|
11902
|
+
]
|
|
11903
|
+
}
|
|
11904
|
+
)
|
|
11905
|
+
}
|
|
11906
|
+
),
|
|
11907
|
+
document.body
|
|
11908
|
+
);
|
|
11909
|
+
};
|
|
11910
|
+
const SurveyCleanupConfirmModal = ({
|
|
11911
|
+
open,
|
|
11912
|
+
action,
|
|
11913
|
+
uiLocale = "en",
|
|
11914
|
+
targetSurvey,
|
|
11915
|
+
onClose,
|
|
11916
|
+
onCompleted
|
|
11917
|
+
}) => {
|
|
11918
|
+
const tr = uiLocale === "tr";
|
|
11919
|
+
const { post, del } = useFetchClient();
|
|
11920
|
+
const [busy, setBusy] = useState(false);
|
|
11921
|
+
const [errorMsg, setErrorMsg] = useState("");
|
|
11922
|
+
React.useEffect(() => {
|
|
11923
|
+
if (open) {
|
|
11924
|
+
setErrorMsg("");
|
|
11925
|
+
}
|
|
11926
|
+
}, [open, action]);
|
|
11927
|
+
if (!open || !action || typeof document === "undefined") return null;
|
|
11928
|
+
const isPurgeDemo = action === "purge-demo";
|
|
11929
|
+
const isClearResp = action === "clear-responses";
|
|
11930
|
+
const respCount = targetSurvey?.responseCount ?? 0;
|
|
11931
|
+
const titleText = isPurgeDemo ? tr ? "Örnek (Dummy) Verileri Temizle" : "Purge Built-in Demo / Dummy Data" : isClearResp ? tr ? "Anket Yanıtlarını Sıfırla (Yapıyı Koru)" : "Clear Survey Responses (Keep Structure)" : tr ? "Anketi ve Yanıtlarını Kalıcı Olarak Sil" : "Delete Survey & All Responses";
|
|
11932
|
+
const bodyText = isPurgeDemo ? tr ? "Yalnızca eklentiyle gelen yerleşik vitrin verileri (showcase_dx_survey, showcase_roadmap_poll, showcase_visual_theme_poll + 525 örnek yanıt ve showcase_contact_form + 20 örnek form başvurusu) silinecektir. Sizin oluşturduğunuz özel anketlere ve formlara dokunulmaz. Ayrıca kalıcı koruma bayrağı işaretlendiği için sayfa yenilendiğinde veya sunucu yeniden başladığında dummy veriler kendiliğinden geri gelmez." : "Deletes ONLY the built-in showcase items (showcase_dx_survey, showcase_roadmap_poll, showcase_visual_theme_poll + sample responses and showcase_contact_form + sample submissions). Your custom surveys and forms remain untouched, and a persistent guard prevents demo data from auto-seeding again on reload or server restart." : isClearResp ? tr ? `"${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) anketinin tüm adımları, soruları ve ayarları korunacak; yalnızca mevcut ${respCount} katılımcı yanıtı sıfırlanacaktır. Yayına çıkmadan önce test oylarını temizlemek için idealdir.` : `All steps, questions, and settings of "${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) will be preserved, while its ${respCount} recorded response(s) will be permanently deleted.` : tr ? `"${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) anketi ve bağlı ${respCount} katılımcı yanıtı kalıcı olarak silinecektir. İsterseniz silmeden önce Dışa Aktar ile .ci-survey.json yedeği alabilirsiniz.` : `"${targetSurvey?.title || ""}" (${targetSurvey?.slug || ""}) and all ${respCount} associated response(s) will be permanently deleted.`;
|
|
11933
|
+
const confirmLabel = isPurgeDemo ? tr ? "Evet, Dummy Verileri Temizle" : "Yes, Purge Demo Data" : isClearResp ? tr ? "Evet, Yanıtları Sıfırla (0 Yap)" : "Yes, Clear Responses" : tr ? "Evet, Anketi Kalıcı Sil" : "Yes, Delete Survey";
|
|
11934
|
+
const handleConfirm = async () => {
|
|
11935
|
+
setBusy(true);
|
|
11936
|
+
setErrorMsg("");
|
|
11937
|
+
try {
|
|
11938
|
+
if (isPurgeDemo) {
|
|
11939
|
+
const res2 = await post("/content-input/surveys/purge-demo", {});
|
|
11940
|
+
onCompleted("purge-demo", res2?.data);
|
|
11941
|
+
onClose();
|
|
11942
|
+
return;
|
|
11943
|
+
}
|
|
11944
|
+
const idOrSlug = String(
|
|
11945
|
+
targetSurvey?.slug || targetSurvey?.documentId || targetSurvey?.id || ""
|
|
11946
|
+
).trim();
|
|
11947
|
+
if (!idOrSlug) {
|
|
11948
|
+
throw new Error(tr ? "Hedef anket bulunamadı." : "Target survey not found.");
|
|
11949
|
+
}
|
|
11950
|
+
if (isClearResp) {
|
|
11951
|
+
const res2 = await del(
|
|
11952
|
+
`/content-input/surveys/${encodeURIComponent(idOrSlug)}/responses`
|
|
11953
|
+
);
|
|
11954
|
+
onCompleted("clear-responses", res2?.data);
|
|
11955
|
+
onClose();
|
|
11956
|
+
return;
|
|
11957
|
+
}
|
|
11958
|
+
const res = await del(
|
|
11959
|
+
`/content-input/surveys/${encodeURIComponent(idOrSlug)}`
|
|
11960
|
+
);
|
|
11961
|
+
onCompleted("delete-survey", res?.data);
|
|
11962
|
+
onClose();
|
|
11963
|
+
} catch (err) {
|
|
11964
|
+
if (isRouteNotLoadedError(err)) {
|
|
11965
|
+
setErrorMsg(
|
|
11966
|
+
tr ? "Yeni sunucu rotalarının aktif olması için lütfen Strapi sunucusunu (npm run dev) bir kez yeniden başlatın." : "Please restart the Strapi server (npm run dev) once so the new backend routes take effect."
|
|
11967
|
+
);
|
|
11968
|
+
} else {
|
|
11969
|
+
setErrorMsg(
|
|
11970
|
+
err?.response?.data?.error?.message || err?.message || (tr ? "İşlem tamamlanamadı." : "Operation failed.")
|
|
11971
|
+
);
|
|
11972
|
+
}
|
|
11973
|
+
} finally {
|
|
11974
|
+
setBusy(false);
|
|
11975
|
+
}
|
|
11976
|
+
};
|
|
11977
|
+
return createPortal(
|
|
11978
|
+
/* @__PURE__ */ jsx(
|
|
11979
|
+
"div",
|
|
11980
|
+
{
|
|
11981
|
+
className: "ci-root",
|
|
11982
|
+
style: {
|
|
11983
|
+
position: "fixed",
|
|
11984
|
+
inset: 0,
|
|
11985
|
+
background: "rgba(15, 23, 42, 0.68)",
|
|
11986
|
+
zIndex: 320,
|
|
11987
|
+
display: "flex",
|
|
11988
|
+
alignItems: "center",
|
|
11989
|
+
justifyContent: "center",
|
|
11990
|
+
padding: 16
|
|
11991
|
+
},
|
|
11992
|
+
onClick: onClose,
|
|
11993
|
+
children: /* @__PURE__ */ jsxs(
|
|
11994
|
+
"div",
|
|
11995
|
+
{
|
|
11996
|
+
style: {
|
|
11997
|
+
width: "100%",
|
|
11998
|
+
maxWidth: 490,
|
|
11999
|
+
background: "#ffffff",
|
|
12000
|
+
borderRadius: 12,
|
|
12001
|
+
boxShadow: "0 24px 54px rgba(15, 23, 42, 0.4)",
|
|
12002
|
+
overflow: "hidden",
|
|
12003
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
|
|
12004
|
+
},
|
|
12005
|
+
onClick: (e) => e.stopPropagation(),
|
|
12006
|
+
children: [
|
|
12007
|
+
/* @__PURE__ */ jsxs(
|
|
12008
|
+
"div",
|
|
12009
|
+
{
|
|
12010
|
+
style: {
|
|
12011
|
+
padding: "14px 18px",
|
|
12012
|
+
background: isClearResp ? "#92400e" : "#991b1b",
|
|
12013
|
+
color: "#ffffff",
|
|
12014
|
+
display: "flex",
|
|
12015
|
+
alignItems: "center",
|
|
12016
|
+
justifyContent: "space-between"
|
|
12017
|
+
},
|
|
12018
|
+
children: [
|
|
12019
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
12020
|
+
/* @__PURE__ */ jsx(
|
|
12021
|
+
MaterialIcon,
|
|
12022
|
+
{
|
|
12023
|
+
name: isClearResp ? "restart_alt" : "delete_sweep",
|
|
12024
|
+
size: 20,
|
|
12025
|
+
color: "#fde68a"
|
|
12026
|
+
}
|
|
12027
|
+
),
|
|
12028
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 14, fontWeight: 700 }, children: titleText })
|
|
12029
|
+
] }),
|
|
12030
|
+
/* @__PURE__ */ jsx(
|
|
12031
|
+
"button",
|
|
12032
|
+
{
|
|
12033
|
+
type: "button",
|
|
12034
|
+
onClick: onClose,
|
|
12035
|
+
style: {
|
|
12036
|
+
border: "none",
|
|
12037
|
+
background: "transparent",
|
|
12038
|
+
color: "#fecaca",
|
|
12039
|
+
fontSize: 18,
|
|
12040
|
+
cursor: "pointer"
|
|
12041
|
+
},
|
|
12042
|
+
children: "×"
|
|
12043
|
+
}
|
|
12044
|
+
)
|
|
12045
|
+
]
|
|
12046
|
+
}
|
|
12047
|
+
),
|
|
12048
|
+
/* @__PURE__ */ jsxs("div", { style: { padding: 18, display: "flex", flexDirection: "column", gap: 14 }, children: [
|
|
12049
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 12.5, color: "#334155", lineHeight: 1.55 }, children: bodyText }),
|
|
12050
|
+
errorMsg && /* @__PURE__ */ jsx(
|
|
12051
|
+
"div",
|
|
12052
|
+
{
|
|
12053
|
+
style: {
|
|
12054
|
+
padding: "8px 12px",
|
|
12055
|
+
borderRadius: 7,
|
|
12056
|
+
background: "#fee2e2",
|
|
12057
|
+
color: "#991b1b",
|
|
12058
|
+
fontSize: 11.5,
|
|
12059
|
+
fontWeight: 600
|
|
12060
|
+
},
|
|
12061
|
+
children: errorMsg
|
|
12062
|
+
}
|
|
12063
|
+
),
|
|
12064
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
|
|
12065
|
+
/* @__PURE__ */ jsx(
|
|
12066
|
+
"button",
|
|
12067
|
+
{
|
|
12068
|
+
type: "button",
|
|
12069
|
+
onClick: onClose,
|
|
12070
|
+
style: {
|
|
12071
|
+
padding: "8px 14px",
|
|
12072
|
+
borderRadius: 7,
|
|
12073
|
+
border: "1px solid #cbd5e1",
|
|
12074
|
+
background: "#ffffff",
|
|
12075
|
+
color: "#334155",
|
|
12076
|
+
fontSize: 12,
|
|
12077
|
+
fontWeight: 600,
|
|
12078
|
+
cursor: "pointer"
|
|
12079
|
+
},
|
|
12080
|
+
children: tr ? "Vazgeç" : "Cancel"
|
|
12081
|
+
}
|
|
12082
|
+
),
|
|
12083
|
+
/* @__PURE__ */ jsx(
|
|
12084
|
+
"button",
|
|
12085
|
+
{
|
|
12086
|
+
type: "button",
|
|
12087
|
+
disabled: busy,
|
|
12088
|
+
onClick: handleConfirm,
|
|
12089
|
+
style: {
|
|
12090
|
+
padding: "8px 16px",
|
|
12091
|
+
borderRadius: 7,
|
|
12092
|
+
border: "none",
|
|
12093
|
+
background: isClearResp ? "#d97706" : "#dc2626",
|
|
12094
|
+
color: "#ffffff",
|
|
12095
|
+
fontSize: 12,
|
|
12096
|
+
fontWeight: 700,
|
|
12097
|
+
cursor: "pointer"
|
|
12098
|
+
},
|
|
12099
|
+
children: busy ? "..." : confirmLabel
|
|
12100
|
+
}
|
|
12101
|
+
)
|
|
12102
|
+
] })
|
|
12103
|
+
] })
|
|
12104
|
+
]
|
|
12105
|
+
}
|
|
12106
|
+
)
|
|
12107
|
+
}
|
|
12108
|
+
),
|
|
12109
|
+
document.body
|
|
12110
|
+
);
|
|
12111
|
+
};
|
|
12112
|
+
function normalizeMultiStepDraft(draft) {
|
|
12113
|
+
const rawSteps = Array.isArray(draft.steps) && draft.steps.length > 0 ? draft.steps : [
|
|
12114
|
+
{
|
|
12115
|
+
id: "step_1",
|
|
12116
|
+
title: { tr: "1. Adım", en: "Step 1" }
|
|
12117
|
+
}
|
|
12118
|
+
];
|
|
12119
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
12120
|
+
for (const st of rawSteps) {
|
|
12121
|
+
buckets.set(st.id, []);
|
|
12122
|
+
}
|
|
12123
|
+
const fallbackStepId = rawSteps[0].id;
|
|
12124
|
+
for (const q of draft.questions || []) {
|
|
12125
|
+
if (!q) continue;
|
|
12126
|
+
const validStepId = q.stepId && buckets.has(q.stepId) ? q.stepId : fallbackStepId;
|
|
12127
|
+
buckets.get(validStepId).push({
|
|
12128
|
+
...q,
|
|
12129
|
+
stepId: validStepId
|
|
12130
|
+
});
|
|
12131
|
+
}
|
|
12132
|
+
const orderedQuestions = rawSteps.flatMap((st) => buckets.get(st.id) || []);
|
|
12133
|
+
return {
|
|
12134
|
+
...draft,
|
|
12135
|
+
steps: rawSteps,
|
|
12136
|
+
questions: orderedQuestions
|
|
12137
|
+
};
|
|
12138
|
+
}
|
|
12139
|
+
function groupQuestionsByStep(questions, steps) {
|
|
12140
|
+
const map = /* @__PURE__ */ new Map();
|
|
12141
|
+
for (const st of steps) {
|
|
12142
|
+
map.set(st.id, []);
|
|
12143
|
+
}
|
|
12144
|
+
if (steps.length === 0) return map;
|
|
12145
|
+
const fallbackId = steps[0].id;
|
|
12146
|
+
questions.forEach((q, gIdx) => {
|
|
12147
|
+
const targetId = q.stepId && map.has(q.stepId) ? q.stepId : fallbackId;
|
|
12148
|
+
const list = map.get(targetId);
|
|
12149
|
+
list.push({
|
|
12150
|
+
question: q,
|
|
12151
|
+
globalIndex: gIdx,
|
|
12152
|
+
localIndex: list.length
|
|
12153
|
+
});
|
|
12154
|
+
});
|
|
12155
|
+
return map;
|
|
12156
|
+
}
|
|
12157
|
+
function reorderStepsInDraft(draft, sourceStepId, targetStepId, position = "before") {
|
|
12158
|
+
const normalized = normalizeMultiStepDraft(draft);
|
|
12159
|
+
const steps = normalized.steps || [];
|
|
12160
|
+
if (!sourceStepId || !targetStepId || sourceStepId === targetStepId) {
|
|
12161
|
+
return normalized;
|
|
12162
|
+
}
|
|
12163
|
+
const moving = steps.find((s) => s.id === sourceStepId);
|
|
12164
|
+
const target = steps.find((s) => s.id === targetStepId);
|
|
12165
|
+
if (!moving || !target) return normalized;
|
|
12166
|
+
const remaining = steps.filter((s) => s.id !== sourceStepId);
|
|
12167
|
+
const targetIdx = remaining.findIndex((s) => s.id === targetStepId);
|
|
12168
|
+
const insertAt = position === "after" ? targetIdx + 1 : targetIdx;
|
|
12169
|
+
remaining.splice(Math.max(0, insertAt), 0, moving);
|
|
12170
|
+
return normalizeMultiStepDraft({
|
|
12171
|
+
...normalized,
|
|
12172
|
+
steps: remaining
|
|
12173
|
+
});
|
|
12174
|
+
}
|
|
12175
|
+
function shiftStepByOffset(draft, stepId, delta) {
|
|
12176
|
+
const normalized = normalizeMultiStepDraft(draft);
|
|
12177
|
+
const steps = [...normalized.steps || []];
|
|
12178
|
+
const idx = steps.findIndex((s) => s.id === stepId);
|
|
12179
|
+
if (idx < 0) return normalized;
|
|
12180
|
+
const nextIdx = idx + delta;
|
|
12181
|
+
if (nextIdx < 0 || nextIdx >= steps.length) return normalized;
|
|
12182
|
+
const [moved] = steps.splice(idx, 1);
|
|
12183
|
+
steps.splice(nextIdx, 0, moved);
|
|
12184
|
+
return normalizeMultiStepDraft({
|
|
12185
|
+
...normalized,
|
|
12186
|
+
steps
|
|
12187
|
+
});
|
|
12188
|
+
}
|
|
12189
|
+
function moveQuestionInMultiStepDraft(draft, sourceQuestionKey, target) {
|
|
12190
|
+
const normalized = normalizeMultiStepDraft(draft);
|
|
12191
|
+
const steps = normalized.steps || [];
|
|
12192
|
+
if (steps.length === 0) return normalized;
|
|
12193
|
+
if (target.targetQuestionKey && target.targetQuestionKey === sourceQuestionKey && target.position !== "end") {
|
|
12194
|
+
return normalized;
|
|
12195
|
+
}
|
|
12196
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
12197
|
+
for (const st of steps) {
|
|
12198
|
+
buckets.set(st.id, []);
|
|
12199
|
+
}
|
|
12200
|
+
let movingQuestion = null;
|
|
12201
|
+
for (const q of normalized.questions || []) {
|
|
12202
|
+
if (q.key === sourceQuestionKey && !movingQuestion) {
|
|
12203
|
+
movingQuestion = q;
|
|
12204
|
+
continue;
|
|
12205
|
+
}
|
|
12206
|
+
const sid = q.stepId && buckets.has(q.stepId) ? q.stepId : steps[0].id;
|
|
12207
|
+
buckets.get(sid).push(q);
|
|
12208
|
+
}
|
|
12209
|
+
if (!movingQuestion) return normalized;
|
|
12210
|
+
const destStepId = buckets.has(target.stepId) ? target.stepId : steps[0].id;
|
|
12211
|
+
const updatedQuestion = {
|
|
12212
|
+
...movingQuestion,
|
|
12213
|
+
stepId: destStepId
|
|
12214
|
+
};
|
|
12215
|
+
const destBucket = buckets.get(destStepId);
|
|
12216
|
+
if (!target.targetQuestionKey || target.position === "end") {
|
|
12217
|
+
destBucket.push(updatedQuestion);
|
|
12218
|
+
} else {
|
|
12219
|
+
const tIdx = destBucket.findIndex((q) => q.key === target.targetQuestionKey);
|
|
12220
|
+
if (tIdx < 0) {
|
|
12221
|
+
destBucket.push(updatedQuestion);
|
|
12222
|
+
} else {
|
|
12223
|
+
const insertIdx = target.position === "after" ? tIdx + 1 : tIdx;
|
|
12224
|
+
destBucket.splice(insertIdx, 0, updatedQuestion);
|
|
12225
|
+
}
|
|
12226
|
+
}
|
|
12227
|
+
return {
|
|
12228
|
+
...normalized,
|
|
12229
|
+
questions: steps.flatMap((st) => buckets.get(st.id) || [])
|
|
12230
|
+
};
|
|
12231
|
+
}
|
|
12232
|
+
function insertQuestionInMultiStepDraft(draft, newQuestion, target) {
|
|
12233
|
+
const normalized = normalizeMultiStepDraft(draft);
|
|
12234
|
+
const steps = normalized.steps || [];
|
|
12235
|
+
const destStepId = steps.some((s) => s.id === target.stepId) ? target.stepId : steps[0].id;
|
|
12236
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
12237
|
+
for (const st of steps) {
|
|
12238
|
+
buckets.set(st.id, []);
|
|
12239
|
+
}
|
|
12240
|
+
for (const q of normalized.questions || []) {
|
|
12241
|
+
const sid = q.stepId && buckets.has(q.stepId) ? q.stepId : steps[0].id;
|
|
12242
|
+
buckets.get(sid).push(q);
|
|
12243
|
+
}
|
|
12244
|
+
const prepared = {
|
|
12245
|
+
...newQuestion,
|
|
12246
|
+
stepId: destStepId
|
|
12247
|
+
};
|
|
12248
|
+
const destBucket = buckets.get(destStepId);
|
|
12249
|
+
if (!target.targetQuestionKey || target.position === "end") {
|
|
12250
|
+
destBucket.push(prepared);
|
|
12251
|
+
} else {
|
|
12252
|
+
const tIdx = destBucket.findIndex((q) => q.key === target.targetQuestionKey);
|
|
12253
|
+
if (tIdx < 0) {
|
|
12254
|
+
destBucket.push(prepared);
|
|
12255
|
+
} else {
|
|
12256
|
+
const insertIdx = target.position === "after" ? tIdx + 1 : tIdx;
|
|
12257
|
+
destBucket.splice(insertIdx, 0, prepared);
|
|
12258
|
+
}
|
|
12259
|
+
}
|
|
12260
|
+
const nextQuestions = steps.flatMap((st) => buckets.get(st.id) || []);
|
|
12261
|
+
const insertedIndex = Math.max(
|
|
12262
|
+
0,
|
|
12263
|
+
nextQuestions.findIndex((q) => q.key === prepared.key)
|
|
12264
|
+
);
|
|
12265
|
+
return {
|
|
12266
|
+
draft: {
|
|
12267
|
+
...normalized,
|
|
12268
|
+
questions: nextQuestions
|
|
12269
|
+
},
|
|
12270
|
+
insertedIndex
|
|
12271
|
+
};
|
|
12272
|
+
}
|
|
12273
|
+
function reorderFlatQuestions(questions, sourceKey, targetKey, position = "before") {
|
|
12274
|
+
if (!sourceKey || !targetKey || sourceKey === targetKey) return questions;
|
|
12275
|
+
const moving = questions.find((q) => q.key === sourceKey);
|
|
12276
|
+
if (!moving) return questions;
|
|
12277
|
+
const remaining = questions.filter((q) => q.key !== sourceKey);
|
|
12278
|
+
const tIdx = remaining.findIndex((q) => q.key === targetKey);
|
|
12279
|
+
if (tIdx < 0) return questions;
|
|
12280
|
+
const insertIdx = position === "after" ? tIdx + 1 : tIdx;
|
|
12281
|
+
remaining.splice(insertIdx, 0, moving);
|
|
12282
|
+
return remaining;
|
|
12283
|
+
}
|
|
12284
|
+
function deleteStepWithQuestionReassignment(draft, stepIdToDelete) {
|
|
12285
|
+
const normalized = normalizeMultiStepDraft(draft);
|
|
12286
|
+
const steps = normalized.steps || [];
|
|
12287
|
+
if (steps.length <= 1) {
|
|
12288
|
+
return {
|
|
12289
|
+
draft: normalized,
|
|
12290
|
+
fallbackStepId: steps[0]?.id || "step_1",
|
|
12291
|
+
movedQuestionCount: 0
|
|
12292
|
+
};
|
|
12293
|
+
}
|
|
12294
|
+
const delIdx = steps.findIndex((s) => s.id === stepIdToDelete);
|
|
12295
|
+
if (delIdx < 0) {
|
|
12296
|
+
return {
|
|
12297
|
+
draft: normalized,
|
|
12298
|
+
fallbackStepId: steps[0].id,
|
|
12299
|
+
movedQuestionCount: 0
|
|
12300
|
+
};
|
|
12301
|
+
}
|
|
12302
|
+
const fallbackStep = delIdx > 0 ? steps[delIdx - 1] : steps[1];
|
|
12303
|
+
let movedQuestionCount = 0;
|
|
12304
|
+
const updatedQuestions = (normalized.questions || []).map((q) => {
|
|
12305
|
+
if (q.stepId === stepIdToDelete) {
|
|
12306
|
+
movedQuestionCount += 1;
|
|
12307
|
+
return { ...q, stepId: fallbackStep.id };
|
|
12308
|
+
}
|
|
12309
|
+
return q;
|
|
12310
|
+
});
|
|
12311
|
+
const remainingSteps = steps.filter((s) => s.id !== stepIdToDelete);
|
|
12312
|
+
const nextDraft = normalizeMultiStepDraft({
|
|
12313
|
+
...normalized,
|
|
12314
|
+
steps: remainingSteps,
|
|
12315
|
+
questions: updatedQuestions
|
|
12316
|
+
});
|
|
12317
|
+
return {
|
|
12318
|
+
draft: nextDraft,
|
|
12319
|
+
fallbackStepId: fallbackStep.id,
|
|
12320
|
+
movedQuestionCount
|
|
12321
|
+
};
|
|
12322
|
+
}
|
|
10889
12323
|
const inputStyle = {
|
|
10890
12324
|
width: "100%",
|
|
10891
12325
|
padding: "6px 9px",
|
|
@@ -10902,22 +12336,25 @@ const labelStyle = {
|
|
|
10902
12336
|
color: "#475569",
|
|
10903
12337
|
marginBottom: 4
|
|
10904
12338
|
};
|
|
12339
|
+
const TURKISH_CHAR_MAP = {
|
|
12340
|
+
ç: "c",
|
|
12341
|
+
Ç: "c",
|
|
12342
|
+
ğ: "g",
|
|
12343
|
+
Ğ: "g",
|
|
12344
|
+
ı: "i",
|
|
12345
|
+
İ: "i",
|
|
12346
|
+
ö: "o",
|
|
12347
|
+
Ö: "o",
|
|
12348
|
+
ş: "s",
|
|
12349
|
+
Ş: "s",
|
|
12350
|
+
ü: "u",
|
|
12351
|
+
Ü: "u"
|
|
12352
|
+
};
|
|
12353
|
+
function sanitizeSlugInput(input) {
|
|
12354
|
+
return String(input || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => TURKISH_CHAR_MAP[ch] || ch).toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9_-]/g, "");
|
|
12355
|
+
}
|
|
10905
12356
|
function slugifyKey(input) {
|
|
10906
|
-
|
|
10907
|
-
ç: "c",
|
|
10908
|
-
Ç: "c",
|
|
10909
|
-
ğ: "g",
|
|
10910
|
-
Ğ: "g",
|
|
10911
|
-
ı: "i",
|
|
10912
|
-
İ: "i",
|
|
10913
|
-
ö: "o",
|
|
10914
|
-
Ö: "o",
|
|
10915
|
-
ş: "s",
|
|
10916
|
-
Ş: "s",
|
|
10917
|
-
ü: "u",
|
|
10918
|
-
Ü: "u"
|
|
10919
|
-
};
|
|
10920
|
-
return String(input || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
12357
|
+
return String(input || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => TURKISH_CHAR_MAP[ch] || ch).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/_{2,}/g, "_").replace(/^[-_]+|[-_]+$/g, "");
|
|
10921
12358
|
}
|
|
10922
12359
|
const LIKERT_SCALE_PRESETS = [
|
|
10923
12360
|
{
|
|
@@ -11023,13 +12460,14 @@ const QUESTION_TYPES_CATALOG = [
|
|
|
11023
12460
|
function createBlankSurveyDraft(locale = "en") {
|
|
11024
12461
|
const tr = locale === "tr";
|
|
11025
12462
|
const ts = Date.now().toString(36).slice(-4);
|
|
12463
|
+
const initialTitle = tr ? "Yeni Müşteri Geri Bildirim Anketi" : "New Customer Feedback Survey";
|
|
11026
12464
|
return {
|
|
11027
|
-
title:
|
|
12465
|
+
title: initialTitle,
|
|
11028
12466
|
titleI18n: {
|
|
11029
12467
|
en: "New Customer Feedback Survey",
|
|
11030
12468
|
tr: "Yeni Müşteri Geri Bildirim Anketi"
|
|
11031
12469
|
},
|
|
11032
|
-
slug:
|
|
12470
|
+
slug: `${slugifyKey(initialTitle)}-${ts}`,
|
|
11033
12471
|
description: {
|
|
11034
12472
|
tr: "Görüşleriniz hizmet kalitemizi geliştirmemize yardımcı olur.",
|
|
11035
12473
|
en: "Your feedback helps us improve our service quality."
|
|
@@ -11152,27 +12590,65 @@ const SurveyStudioModal = ({
|
|
|
11152
12590
|
const { post } = useFetchClient();
|
|
11153
12591
|
const { locales: strapiLocales } = useStrapiLocales();
|
|
11154
12592
|
const [tab, setTab] = useState(initialTab);
|
|
11155
|
-
const [draft, setDraft] = useState(
|
|
11156
|
-
|
|
11157
|
-
|
|
12593
|
+
const [draft, setDraft] = useState(() => {
|
|
12594
|
+
const cloned = JSON.parse(JSON.stringify(initialSurvey));
|
|
12595
|
+
return cloned.displayMode === "multi_step" ? normalizeMultiStepDraft(cloned) : cloned;
|
|
12596
|
+
});
|
|
11158
12597
|
const [selectedQuestionIdx, setSelectedQuestionIdx] = useState(0);
|
|
12598
|
+
const [collapsedStepIds, setCollapsedStepIds] = useState({});
|
|
12599
|
+
const [openStepDescIds, setOpenStepDescIds] = useState({});
|
|
12600
|
+
const [activeStepId, setActiveStepId] = useState(
|
|
12601
|
+
() => initialSurvey.steps?.[0]?.id || "step_1"
|
|
12602
|
+
);
|
|
12603
|
+
const [stepDragReadyId, setStepDragReadyId] = useState(null);
|
|
12604
|
+
const [dropIndicator, setDropIndicator] = useState(null);
|
|
11159
12605
|
const [saving, setSaving] = useState(false);
|
|
11160
12606
|
const [statusMsg, setStatusMsg] = useState("");
|
|
12607
|
+
const [slugAutoSync, setSlugAutoSync] = useState(
|
|
12608
|
+
() => !initialSurvey.id && !initialSurvey.documentId && !initialSurvey._id
|
|
12609
|
+
);
|
|
11161
12610
|
const [optDragReadyIdx, setOptDragReadyIdx] = useState(null);
|
|
12611
|
+
const [studioExportOpen, setStudioExportOpen] = useState(false);
|
|
12612
|
+
const [studioImportOpen, setStudioImportOpen] = useState(false);
|
|
12613
|
+
const [studioCleanupAction, setStudioCleanupAction] = useState(null);
|
|
12614
|
+
const [studioAnalyticsKey, setStudioAnalyticsKey] = useState(0);
|
|
11162
12615
|
const dragRef = useRef(null);
|
|
12616
|
+
const hoverExpandTimerRef = useRef(null);
|
|
12617
|
+
const clearHoverExpandTimer = () => {
|
|
12618
|
+
if (hoverExpandTimerRef.current) {
|
|
12619
|
+
clearTimeout(hoverExpandTimerRef.current.timer);
|
|
12620
|
+
hoverExpandTimerRef.current = null;
|
|
12621
|
+
}
|
|
12622
|
+
};
|
|
11163
12623
|
useEffect(() => {
|
|
11164
12624
|
if (open) {
|
|
11165
|
-
|
|
12625
|
+
const cloned = JSON.parse(JSON.stringify(initialSurvey));
|
|
12626
|
+
const nextDraft = cloned.displayMode === "multi_step" ? normalizeMultiStepDraft(cloned) : cloned;
|
|
12627
|
+
setDraft(nextDraft);
|
|
12628
|
+
setSlugAutoSync(!cloned.id && !cloned.documentId && !cloned._id);
|
|
11166
12629
|
setSelectedQuestionIdx(0);
|
|
12630
|
+
setCollapsedStepIds({});
|
|
12631
|
+
setOpenStepDescIds({});
|
|
12632
|
+
setActiveStepId(nextDraft.steps?.[0]?.id || "step_1");
|
|
12633
|
+
setDropIndicator(null);
|
|
12634
|
+
setStepDragReadyId(null);
|
|
11167
12635
|
setTab(initialTab);
|
|
11168
12636
|
setStatusMsg("");
|
|
11169
12637
|
}
|
|
12638
|
+
return () => clearHoverExpandTimer();
|
|
11170
12639
|
}, [open, initialSurvey, initialTab]);
|
|
11171
12640
|
if (!open || typeof document === "undefined") return null;
|
|
11172
12641
|
const questions = Array.isArray(draft.questions) ? draft.questions : [];
|
|
11173
12642
|
const activeQ = questions[selectedQuestionIdx] || questions[0] || null;
|
|
11174
12643
|
const steps = Array.isArray(draft.steps) ? draft.steps : [];
|
|
11175
12644
|
const localeGridCols = `repeat(${Math.min(Math.max(strapiLocales.length, 1), 3)}, 1fr)`;
|
|
12645
|
+
const selectQuestionByKey = (nextQuestions, key) => {
|
|
12646
|
+
if (!key) return;
|
|
12647
|
+
const foundIdx = nextQuestions.findIndex((q) => q.key === key);
|
|
12648
|
+
if (foundIdx >= 0) {
|
|
12649
|
+
setSelectedQuestionIdx(foundIdx);
|
|
12650
|
+
}
|
|
12651
|
+
};
|
|
11176
12652
|
const updateActiveQuestion = (patch) => {
|
|
11177
12653
|
if (!activeQ) return;
|
|
11178
12654
|
setDraft((prev) => ({
|
|
@@ -11182,11 +12658,27 @@ const SurveyStudioModal = ({
|
|
|
11182
12658
|
)
|
|
11183
12659
|
}));
|
|
11184
12660
|
};
|
|
11185
|
-
const addQuestionOfType = (qType, insertAt) => {
|
|
11186
|
-
|
|
12661
|
+
const addQuestionOfType = (qType, insertAt, explicitStepId) => {
|
|
12662
|
+
if (draft.displayMode === "multi_step") {
|
|
12663
|
+
const targetStepId = explicitStepId || (activeStepId && steps.some((s) => s.id === activeStepId) ? activeStepId : void 0) || (activeQ?.stepId && steps.some((s) => s.id === activeQ.stepId) ? activeQ.stepId : void 0) || steps[0]?.id || "step_1";
|
|
12664
|
+
const newQ2 = buildQuestionFromType(
|
|
12665
|
+
qType,
|
|
12666
|
+
targetStepId,
|
|
12667
|
+
questions.map((q) => q.key)
|
|
12668
|
+
);
|
|
12669
|
+
const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ2, {
|
|
12670
|
+
stepId: targetStepId,
|
|
12671
|
+
position: "end"
|
|
12672
|
+
});
|
|
12673
|
+
setDraft(nextDraft);
|
|
12674
|
+
setSelectedQuestionIdx(insertedIndex);
|
|
12675
|
+
setActiveStepId(targetStepId);
|
|
12676
|
+
setCollapsedStepIds((prev) => ({ ...prev, [targetStepId]: false }));
|
|
12677
|
+
return;
|
|
12678
|
+
}
|
|
11187
12679
|
const newQ = buildQuestionFromType(
|
|
11188
12680
|
qType,
|
|
11189
|
-
|
|
12681
|
+
void 0,
|
|
11190
12682
|
questions.map((q) => q.key)
|
|
11191
12683
|
);
|
|
11192
12684
|
const nextList = [...questions];
|
|
@@ -11205,14 +12697,17 @@ const SurveyStudioModal = ({
|
|
|
11205
12697
|
setSaving(true);
|
|
11206
12698
|
setStatusMsg("");
|
|
11207
12699
|
try {
|
|
12700
|
+
const cleanFinalSlug = slugifyKey(draft.slug) || slugifyKey(draft.title) || `survey-${Date.now().toString(36).slice(-4)}`;
|
|
11208
12701
|
const payload = {
|
|
11209
12702
|
...draft,
|
|
12703
|
+
slug: cleanFinalSlug,
|
|
11210
12704
|
id: draft.documentId || draft._id || draft.id
|
|
11211
12705
|
};
|
|
11212
12706
|
const res = await post("/content-input/surveys", payload);
|
|
11213
12707
|
const saved = res?.data;
|
|
11214
12708
|
if (saved) {
|
|
11215
12709
|
setDraft(JSON.parse(JSON.stringify(saved)));
|
|
12710
|
+
setSlugAutoSync(false);
|
|
11216
12711
|
setStatusMsg(tr ? "Anket kaydedildi!" : "Survey saved!");
|
|
11217
12712
|
if (typeof window !== "undefined") {
|
|
11218
12713
|
window.dispatchEvent(new CustomEvent("ci-survey-updated", { detail: saved }));
|
|
@@ -11293,27 +12788,35 @@ const SurveyStudioModal = ({
|
|
|
11293
12788
|
children: [
|
|
11294
12789
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
|
|
11295
12790
|
/* @__PURE__ */ jsx(MaterialIcon, { name: "poll", size: 22, color: "#38bdf8" }),
|
|
11296
|
-
/* @__PURE__ */ jsxs(
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
" ",
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
12791
|
+
/* @__PURE__ */ jsxs(
|
|
12792
|
+
"div",
|
|
12793
|
+
{
|
|
12794
|
+
onClick: () => setTab("settings"),
|
|
12795
|
+
title: tr ? "Yönetim başlığını ve Survey Slug alanını düzenlemek için tıklayın" : "Click to edit Internal Title & Survey Slug",
|
|
12796
|
+
style: { cursor: "pointer" },
|
|
12797
|
+
children: [
|
|
12798
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 15, fontWeight: 700 }, children: [
|
|
12799
|
+
tr ? "Kurumsal Anket & Oylama Stüdyosu" : "Enterprise Survey & Poll Studio",
|
|
12800
|
+
" —",
|
|
12801
|
+
" ",
|
|
12802
|
+
/* @__PURE__ */ jsx("span", { style: { color: "#93c5fd", textDecoration: "underline dotted" }, children: draft.title })
|
|
12803
|
+
] }),
|
|
12804
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 11, color: "#94a3b8" }, children: [
|
|
12805
|
+
"Slug: ",
|
|
12806
|
+
/* @__PURE__ */ jsx("code", { children: draft.slug }),
|
|
12807
|
+
" • Mode: ",
|
|
12808
|
+
/* @__PURE__ */ jsx("code", { children: draft.displayMode }),
|
|
12809
|
+
" • Submit:",
|
|
12810
|
+
" ",
|
|
12811
|
+
/* @__PURE__ */ jsxs("code", { children: [
|
|
12812
|
+
"/api/content-input/surveys/",
|
|
12813
|
+
draft.slug,
|
|
12814
|
+
"/submit"
|
|
12815
|
+
] })
|
|
12816
|
+
] })
|
|
12817
|
+
]
|
|
12818
|
+
}
|
|
12819
|
+
)
|
|
11317
12820
|
] }),
|
|
11318
12821
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
11319
12822
|
statusMsg && /* @__PURE__ */ jsx(
|
|
@@ -11330,6 +12833,81 @@ const SurveyStudioModal = ({
|
|
|
11330
12833
|
children: statusMsg
|
|
11331
12834
|
}
|
|
11332
12835
|
),
|
|
12836
|
+
/* @__PURE__ */ jsxs(
|
|
12837
|
+
"button",
|
|
12838
|
+
{
|
|
12839
|
+
type: "button",
|
|
12840
|
+
onClick: () => setStudioImportOpen(true),
|
|
12841
|
+
title: tr ? ".ci-survey.json paketinden anket içe aktar" : "Import survey from .ci-survey.json bundle",
|
|
12842
|
+
style: {
|
|
12843
|
+
padding: "7px 11px",
|
|
12844
|
+
borderRadius: 6,
|
|
12845
|
+
border: "1px solid rgba(56, 189, 248, 0.45)",
|
|
12846
|
+
background: "rgba(14, 165, 233, 0.16)",
|
|
12847
|
+
color: "#e0f2fe",
|
|
12848
|
+
fontSize: 11.5,
|
|
12849
|
+
fontWeight: 700,
|
|
12850
|
+
cursor: "pointer",
|
|
12851
|
+
display: "inline-flex",
|
|
12852
|
+
alignItems: "center",
|
|
12853
|
+
gap: 5
|
|
12854
|
+
},
|
|
12855
|
+
children: [
|
|
12856
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "upload_file", size: 15, color: "#7dd3fc" }),
|
|
12857
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "İçe Aktar" : "Import" })
|
|
12858
|
+
]
|
|
12859
|
+
}
|
|
12860
|
+
),
|
|
12861
|
+
/* @__PURE__ */ jsxs(
|
|
12862
|
+
"button",
|
|
12863
|
+
{
|
|
12864
|
+
type: "button",
|
|
12865
|
+
onClick: () => setStudioExportOpen(true),
|
|
12866
|
+
title: tr ? "Bu anketi Sadece Yapı veya Yapı + Veri olarak .ci-survey.json indir" : "Export this survey as Structure or Full Backup (.ci-survey.json)",
|
|
12867
|
+
style: {
|
|
12868
|
+
padding: "7px 11px",
|
|
12869
|
+
borderRadius: 6,
|
|
12870
|
+
border: "1px solid rgba(52, 211, 153, 0.45)",
|
|
12871
|
+
background: "rgba(16, 185, 129, 0.16)",
|
|
12872
|
+
color: "#d1fae5",
|
|
12873
|
+
fontSize: 11.5,
|
|
12874
|
+
fontWeight: 700,
|
|
12875
|
+
cursor: "pointer",
|
|
12876
|
+
display: "inline-flex",
|
|
12877
|
+
alignItems: "center",
|
|
12878
|
+
gap: 5
|
|
12879
|
+
},
|
|
12880
|
+
children: [
|
|
12881
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "download", size: 15, color: "#6ee7b7" }),
|
|
12882
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "Dışa Aktar" : "Export" })
|
|
12883
|
+
]
|
|
12884
|
+
}
|
|
12885
|
+
),
|
|
12886
|
+
Boolean(draft.id || draft.documentId || draft._id) && /* @__PURE__ */ jsxs(
|
|
12887
|
+
"button",
|
|
12888
|
+
{
|
|
12889
|
+
type: "button",
|
|
12890
|
+
onClick: () => setStudioCleanupAction("clear-responses"),
|
|
12891
|
+
title: tr ? "Anket yapısını koruyarak mevcut yanıtları sıfırlar (0 yapar)" : "Clear all recorded responses while keeping survey structure",
|
|
12892
|
+
style: {
|
|
12893
|
+
padding: "7px 10px",
|
|
12894
|
+
borderRadius: 6,
|
|
12895
|
+
border: "1px solid rgba(251, 191, 36, 0.45)",
|
|
12896
|
+
background: "rgba(217, 119, 6, 0.18)",
|
|
12897
|
+
color: "#fef3c7",
|
|
12898
|
+
fontSize: 11.5,
|
|
12899
|
+
fontWeight: 700,
|
|
12900
|
+
cursor: "pointer",
|
|
12901
|
+
display: "inline-flex",
|
|
12902
|
+
alignItems: "center",
|
|
12903
|
+
gap: 5
|
|
12904
|
+
},
|
|
12905
|
+
children: [
|
|
12906
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "restart_alt", size: 15, color: "#fcd34d" }),
|
|
12907
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "Yanıt 0'la" : "Reset Resp" })
|
|
12908
|
+
]
|
|
12909
|
+
}
|
|
12910
|
+
),
|
|
11333
12911
|
/* @__PURE__ */ jsxs(
|
|
11334
12912
|
"button",
|
|
11335
12913
|
{
|
|
@@ -11540,16 +13118,22 @@ const SurveyStudioModal = ({
|
|
|
11540
13118
|
"button",
|
|
11541
13119
|
{
|
|
11542
13120
|
type: "button",
|
|
11543
|
-
onClick: () =>
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
13121
|
+
onClick: () => {
|
|
13122
|
+
setDraft((prev) => {
|
|
13123
|
+
const nextRaw = {
|
|
13124
|
+
...prev,
|
|
13125
|
+
displayMode: m.id
|
|
13126
|
+
};
|
|
13127
|
+
if (m.id === "multi_step") {
|
|
13128
|
+
const norm = normalizeMultiStepDraft(nextRaw);
|
|
13129
|
+
if (norm.steps?.[0]?.id) {
|
|
13130
|
+
setActiveStepId(norm.steps[0].id);
|
|
13131
|
+
}
|
|
13132
|
+
return norm;
|
|
11550
13133
|
}
|
|
11551
|
-
|
|
11552
|
-
|
|
13134
|
+
return nextRaw;
|
|
13135
|
+
});
|
|
13136
|
+
},
|
|
11553
13137
|
style: {
|
|
11554
13138
|
padding: "7px 8px",
|
|
11555
13139
|
borderRadius: 6,
|
|
@@ -11568,7 +13152,7 @@ const SurveyStudioModal = ({
|
|
|
11568
13152
|
]
|
|
11569
13153
|
}
|
|
11570
13154
|
),
|
|
11571
|
-
|
|
13155
|
+
/* @__PURE__ */ jsxs(
|
|
11572
13156
|
"div",
|
|
11573
13157
|
{
|
|
11574
13158
|
style: {
|
|
@@ -11585,138 +13169,36 @@ const SurveyStudioModal = ({
|
|
|
11585
13169
|
display: "flex",
|
|
11586
13170
|
alignItems: "center",
|
|
11587
13171
|
justifyContent: "space-between",
|
|
11588
|
-
|
|
13172
|
+
gap: 6,
|
|
13173
|
+
marginBottom: 6
|
|
11589
13174
|
},
|
|
11590
13175
|
children: [
|
|
11591
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, fontWeight: 700, color: "#
|
|
11592
|
-
/* @__PURE__ */
|
|
11593
|
-
"
|
|
13176
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, fontWeight: 700, color: "#334155" }, children: tr ? "Soru Tipleri Paleti (Tıklayın veya Kategoriye Sürükleyin):" : "Question Types Palette (Click or Drag into a Step):" }),
|
|
13177
|
+
draft.displayMode === "multi_step" && steps.length > 0 && /* @__PURE__ */ jsxs(
|
|
13178
|
+
"span",
|
|
11594
13179
|
{
|
|
11595
|
-
type: "button",
|
|
11596
|
-
onClick: () => {
|
|
11597
|
-
const nextIdx = steps.length + 1;
|
|
11598
|
-
setDraft((prev) => ({
|
|
11599
|
-
...prev,
|
|
11600
|
-
steps: [
|
|
11601
|
-
...prev.steps || [],
|
|
11602
|
-
{
|
|
11603
|
-
id: `step_${uid("s")}`,
|
|
11604
|
-
title: { tr: `${nextIdx}. Adım`, en: `Step ${nextIdx}` }
|
|
11605
|
-
}
|
|
11606
|
-
]
|
|
11607
|
-
}));
|
|
11608
|
-
},
|
|
11609
13180
|
style: {
|
|
11610
|
-
padding: "3px 8px",
|
|
11611
13181
|
fontSize: 10,
|
|
11612
13182
|
fontWeight: 700,
|
|
11613
|
-
|
|
11614
|
-
|
|
13183
|
+
padding: "2px 7px",
|
|
13184
|
+
borderRadius: 10,
|
|
11615
13185
|
background: "#eff6ff",
|
|
11616
|
-
color: "#1d4ed8"
|
|
11617
|
-
cursor: "pointer"
|
|
13186
|
+
color: "#1d4ed8"
|
|
11618
13187
|
},
|
|
11619
|
-
children:
|
|
13188
|
+
children: [
|
|
13189
|
+
tr ? "Hedef:" : "Target:",
|
|
13190
|
+
" ",
|
|
13191
|
+
pickTextForLocale(
|
|
13192
|
+
steps.find((s) => s.id === activeStepId)?.title || steps[0].title,
|
|
13193
|
+
uiLocale,
|
|
13194
|
+
activeStepId
|
|
13195
|
+
)
|
|
13196
|
+
]
|
|
11620
13197
|
}
|
|
11621
13198
|
)
|
|
11622
13199
|
]
|
|
11623
13200
|
}
|
|
11624
13201
|
),
|
|
11625
|
-
/* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: steps.map((st, sIdx) => {
|
|
11626
|
-
const stTitleObj = normalizeLocalizedRecord(st.title, strapiLocales);
|
|
11627
|
-
return /* @__PURE__ */ jsxs(
|
|
11628
|
-
"div",
|
|
11629
|
-
{
|
|
11630
|
-
draggable: true,
|
|
11631
|
-
onDragStart: () => {
|
|
11632
|
-
dragRef.current = { kind: "step", index: sIdx };
|
|
11633
|
-
},
|
|
11634
|
-
onDragOver: (e) => {
|
|
11635
|
-
if (dragRef.current?.kind === "step") e.preventDefault();
|
|
11636
|
-
},
|
|
11637
|
-
onDrop: (e) => {
|
|
11638
|
-
e.preventDefault();
|
|
11639
|
-
if (dragRef.current?.kind !== "step") return;
|
|
11640
|
-
const from = dragRef.current.index;
|
|
11641
|
-
dragRef.current = null;
|
|
11642
|
-
if (from === sIdx) return;
|
|
11643
|
-
const copy = [...steps];
|
|
11644
|
-
const [moved] = copy.splice(from, 1);
|
|
11645
|
-
copy.splice(sIdx, 0, moved);
|
|
11646
|
-
setDraft((prev) => ({ ...prev, steps: copy }));
|
|
11647
|
-
},
|
|
11648
|
-
style: {
|
|
11649
|
-
display: "grid",
|
|
11650
|
-
gridTemplateColumns: `20px repeat(${strapiLocales.length}, 1fr) 22px`,
|
|
11651
|
-
gap: 5,
|
|
11652
|
-
alignItems: "center",
|
|
11653
|
-
padding: "4px 6px",
|
|
11654
|
-
borderRadius: 5,
|
|
11655
|
-
background: "#f8fafc",
|
|
11656
|
-
border: "1px solid #e2e8f0"
|
|
11657
|
-
},
|
|
11658
|
-
children: [
|
|
11659
|
-
/* @__PURE__ */ jsx(MaterialIcon, { name: "drag_indicator", size: 14, color: "#64748b" }),
|
|
11660
|
-
strapiLocales.map((loc) => /* @__PURE__ */ jsx(
|
|
11661
|
-
"input",
|
|
11662
|
-
{
|
|
11663
|
-
type: "text",
|
|
11664
|
-
value: stTitleObj[loc.code] || "",
|
|
11665
|
-
onChange: (e) => {
|
|
11666
|
-
const nextSteps = steps.map(
|
|
11667
|
-
(item, i) => i === sIdx ? {
|
|
11668
|
-
...item,
|
|
11669
|
-
title: {
|
|
11670
|
-
...stTitleObj,
|
|
11671
|
-
[loc.code]: e.target.value
|
|
11672
|
-
}
|
|
11673
|
-
} : item
|
|
11674
|
-
);
|
|
11675
|
-
setDraft((prev) => ({ ...prev, steps: nextSteps }));
|
|
11676
|
-
},
|
|
11677
|
-
placeholder: `${loc.code.toUpperCase()} Step`,
|
|
11678
|
-
style: { ...inputStyle, padding: "4px 6px", fontSize: 11 }
|
|
11679
|
-
},
|
|
11680
|
-
`st-${st.id}-${loc.code}`
|
|
11681
|
-
)),
|
|
11682
|
-
/* @__PURE__ */ jsx(
|
|
11683
|
-
"button",
|
|
11684
|
-
{
|
|
11685
|
-
type: "button",
|
|
11686
|
-
disabled: steps.length <= 1,
|
|
11687
|
-
onClick: () => setDraft((prev) => ({
|
|
11688
|
-
...prev,
|
|
11689
|
-
steps: (prev.steps || []).filter((_, i) => i !== sIdx)
|
|
11690
|
-
})),
|
|
11691
|
-
style: {
|
|
11692
|
-
border: "none",
|
|
11693
|
-
background: "transparent",
|
|
11694
|
-
color: steps.length <= 1 ? "#cbd5e1" : "#dc2626",
|
|
11695
|
-
cursor: "pointer",
|
|
11696
|
-
fontSize: 13
|
|
11697
|
-
},
|
|
11698
|
-
children: "×"
|
|
11699
|
-
}
|
|
11700
|
-
)
|
|
11701
|
-
]
|
|
11702
|
-
},
|
|
11703
|
-
st.id
|
|
11704
|
-
);
|
|
11705
|
-
}) })
|
|
11706
|
-
]
|
|
11707
|
-
}
|
|
11708
|
-
),
|
|
11709
|
-
/* @__PURE__ */ jsxs(
|
|
11710
|
-
"div",
|
|
11711
|
-
{
|
|
11712
|
-
style: {
|
|
11713
|
-
padding: 10,
|
|
11714
|
-
borderRadius: 8,
|
|
11715
|
-
background: "#ffffff",
|
|
11716
|
-
border: "1px solid #cbd5e1"
|
|
11717
|
-
},
|
|
11718
|
-
children: [
|
|
11719
|
-
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "#334155", marginBottom: 6 }, children: tr ? "Soru Tipleri Paleti (Tıklayın veya Aşağıya Sürükleyin):" : "Question Types Palette (Click or Drag Below):" }),
|
|
11720
13202
|
/* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 5 }, children: QUESTION_TYPES_CATALOG.map((qt) => /* @__PURE__ */ jsxs(
|
|
11721
13203
|
"button",
|
|
11722
13204
|
{
|
|
@@ -11724,8 +13206,14 @@ const SurveyStudioModal = ({
|
|
|
11724
13206
|
draggable: true,
|
|
11725
13207
|
onDragStart: (e) => {
|
|
11726
13208
|
dragRef.current = { kind: "new-type", qType: qt.type };
|
|
13209
|
+
e.dataTransfer.effectAllowed = "copyMove";
|
|
11727
13210
|
e.dataTransfer.setData("text/plain", qt.type);
|
|
11728
13211
|
},
|
|
13212
|
+
onDragEnd: () => {
|
|
13213
|
+
dragRef.current = null;
|
|
13214
|
+
setDropIndicator(null);
|
|
13215
|
+
clearHoverExpandTimer();
|
|
13216
|
+
},
|
|
11729
13217
|
onClick: () => addQuestionOfType(qt.type),
|
|
11730
13218
|
style: {
|
|
11731
13219
|
padding: "4px 8px",
|
|
@@ -11742,182 +13230,1259 @@ const SurveyStudioModal = ({
|
|
|
11742
13230
|
tr ? qt.labelTr : qt.labelEn
|
|
11743
13231
|
]
|
|
11744
13232
|
},
|
|
11745
|
-
qt.type
|
|
11746
|
-
)) })
|
|
11747
|
-
]
|
|
11748
|
-
}
|
|
11749
|
-
),
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
13233
|
+
qt.type
|
|
13234
|
+
)) })
|
|
13235
|
+
]
|
|
13236
|
+
}
|
|
13237
|
+
),
|
|
13238
|
+
draft.displayMode === "multi_step" ? (() => {
|
|
13239
|
+
const groupedMap = groupQuestionsByStep(questions, steps);
|
|
13240
|
+
const allCollapsed = steps.length > 0 && steps.every((s) => Boolean(collapsedStepIds[s.id]));
|
|
13241
|
+
const addNewStepCategory = () => {
|
|
13242
|
+
const nextIdx = steps.length + 1;
|
|
13243
|
+
const newStepId = `step_${uid("s")}`;
|
|
13244
|
+
const dynamicStepTitles = {};
|
|
13245
|
+
for (const loc of strapiLocales) {
|
|
13246
|
+
dynamicStepTitles[loc.code] = loc.code.toLowerCase().startsWith("tr") ? `${nextIdx}. Adım` : `Step ${nextIdx}`;
|
|
13247
|
+
}
|
|
13248
|
+
if (!dynamicStepTitles.tr) dynamicStepTitles.tr = `${nextIdx}. Adım`;
|
|
13249
|
+
if (!dynamicStepTitles.en) dynamicStepTitles.en = `Step ${nextIdx}`;
|
|
13250
|
+
setDraft(
|
|
13251
|
+
(prev) => normalizeMultiStepDraft({
|
|
13252
|
+
...prev,
|
|
13253
|
+
steps: [
|
|
13254
|
+
...prev.steps || [],
|
|
13255
|
+
{
|
|
13256
|
+
id: newStepId,
|
|
13257
|
+
title: dynamicStepTitles
|
|
13258
|
+
}
|
|
13259
|
+
]
|
|
13260
|
+
})
|
|
13261
|
+
);
|
|
13262
|
+
setActiveStepId(newStepId);
|
|
13263
|
+
setCollapsedStepIds((prev) => ({ ...prev, [newStepId]: false }));
|
|
13264
|
+
};
|
|
13265
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 9 }, children: [
|
|
13266
|
+
/* @__PURE__ */ jsxs(
|
|
13267
|
+
"div",
|
|
13268
|
+
{
|
|
13269
|
+
style: {
|
|
13270
|
+
display: "flex",
|
|
13271
|
+
alignItems: "center",
|
|
13272
|
+
justifyContent: "space-between",
|
|
13273
|
+
flexWrap: "wrap",
|
|
13274
|
+
gap: 6,
|
|
13275
|
+
padding: "6px 10px",
|
|
13276
|
+
borderRadius: 8,
|
|
13277
|
+
background: "#eef2ff",
|
|
13278
|
+
border: "1px solid #c7d2fe"
|
|
13279
|
+
},
|
|
13280
|
+
children: [
|
|
13281
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
13282
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "layers", size: 15, color: "#3730a3" }),
|
|
13283
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 11.5, fontWeight: 800, color: "#1e1b4b" }, children: tr ? `Sihirbaz Kategorileri (${steps.length} Adım • ${questions.length} Soru)` : `Wizard Step Categories (${steps.length} Steps • ${questions.length} Qs)` })
|
|
13284
|
+
] }),
|
|
13285
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
|
|
13286
|
+
/* @__PURE__ */ jsx(
|
|
13287
|
+
"button",
|
|
13288
|
+
{
|
|
13289
|
+
type: "button",
|
|
13290
|
+
onClick: () => {
|
|
13291
|
+
const nextState = {};
|
|
13292
|
+
for (const s of steps) {
|
|
13293
|
+
nextState[s.id] = !allCollapsed;
|
|
13294
|
+
}
|
|
13295
|
+
setCollapsedStepIds(nextState);
|
|
13296
|
+
},
|
|
13297
|
+
style: {
|
|
13298
|
+
padding: "4px 8px",
|
|
13299
|
+
fontSize: 10.5,
|
|
13300
|
+
fontWeight: 700,
|
|
13301
|
+
borderRadius: 5,
|
|
13302
|
+
border: "1px solid #cbd5e1",
|
|
13303
|
+
background: "#ffffff",
|
|
13304
|
+
color: "#334155",
|
|
13305
|
+
cursor: "pointer"
|
|
13306
|
+
},
|
|
13307
|
+
children: allCollapsed ? tr ? "▾ Tümünü Aç" : "▾ Expand All" : tr ? "▸ Tümünü Daralt" : "▸ Collapse All"
|
|
13308
|
+
}
|
|
13309
|
+
),
|
|
13310
|
+
/* @__PURE__ */ jsx(
|
|
13311
|
+
"button",
|
|
13312
|
+
{
|
|
13313
|
+
type: "button",
|
|
13314
|
+
onClick: addNewStepCategory,
|
|
13315
|
+
style: {
|
|
13316
|
+
padding: "4px 10px",
|
|
13317
|
+
fontSize: 10.5,
|
|
13318
|
+
fontWeight: 700,
|
|
13319
|
+
borderRadius: 5,
|
|
13320
|
+
border: "none",
|
|
13321
|
+
background: "#2563eb",
|
|
13322
|
+
color: "#ffffff",
|
|
13323
|
+
cursor: "pointer"
|
|
13324
|
+
},
|
|
13325
|
+
children: tr ? "+ Yeni Adım Ekle" : "+ Add Step"
|
|
13326
|
+
}
|
|
13327
|
+
)
|
|
13328
|
+
] })
|
|
13329
|
+
]
|
|
11764
13330
|
}
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
const
|
|
11769
|
-
const
|
|
11770
|
-
const
|
|
13331
|
+
),
|
|
13332
|
+
steps.map((st, sIdx) => {
|
|
13333
|
+
const stTitleObj = normalizeLocalizedRecord(st.title, strapiLocales);
|
|
13334
|
+
const stepEntries = groupedMap.get(st.id) || [];
|
|
13335
|
+
const isCollapsed = Boolean(collapsedStepIds[st.id]);
|
|
13336
|
+
const isFocusedStep = activeStepId === st.id;
|
|
13337
|
+
const containsSelectedQ = stepEntries.some(
|
|
13338
|
+
(ent) => ent.globalIndex === selectedQuestionIdx
|
|
13339
|
+
);
|
|
13340
|
+
const stepIndicatorBefore = dropIndicator?.kind === "step" && dropIndicator.targetId === st.id && dropIndicator.position === "before";
|
|
13341
|
+
const stepIndicatorAfter = dropIndicator?.kind === "step" && dropIndicator.targetId === st.id && dropIndicator.position === "after";
|
|
13342
|
+
const isQuestionZoneHovered = dropIndicator?.kind === "step-zone" && dropIndicator.targetId === st.id;
|
|
13343
|
+
const handleDropIntoStepEnd = (item) => {
|
|
13344
|
+
const prevSelectedKey = activeQ?.key;
|
|
13345
|
+
if (item.kind === "question") {
|
|
13346
|
+
const nextDraft = moveQuestionInMultiStepDraft(
|
|
13347
|
+
draft,
|
|
13348
|
+
item.questionKey,
|
|
13349
|
+
{
|
|
13350
|
+
stepId: st.id,
|
|
13351
|
+
position: "end"
|
|
13352
|
+
}
|
|
13353
|
+
);
|
|
13354
|
+
setDraft(nextDraft);
|
|
13355
|
+
selectQuestionByKey(nextDraft.questions, item.questionKey || prevSelectedKey);
|
|
13356
|
+
setActiveStepId(st.id);
|
|
13357
|
+
setCollapsedStepIds((prev) => ({ ...prev, [st.id]: false }));
|
|
13358
|
+
} else if (item.kind === "new-type") {
|
|
13359
|
+
const newQ = buildQuestionFromType(
|
|
13360
|
+
item.qType,
|
|
13361
|
+
st.id,
|
|
13362
|
+
questions.map((q) => q.key)
|
|
13363
|
+
);
|
|
13364
|
+
const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ, {
|
|
13365
|
+
stepId: st.id,
|
|
13366
|
+
position: "end"
|
|
13367
|
+
});
|
|
13368
|
+
setDraft(nextDraft);
|
|
13369
|
+
setSelectedQuestionIdx(insertedIndex);
|
|
13370
|
+
setActiveStepId(st.id);
|
|
13371
|
+
setCollapsedStepIds((prev) => ({ ...prev, [st.id]: false }));
|
|
13372
|
+
}
|
|
13373
|
+
};
|
|
11771
13374
|
return /* @__PURE__ */ jsxs(
|
|
11772
13375
|
"div",
|
|
11773
13376
|
{
|
|
11774
|
-
draggable: true,
|
|
11775
|
-
onDragStart: (e) => {
|
|
11776
|
-
dragRef.current = { kind: "question", index: qIdx };
|
|
11777
|
-
e.dataTransfer.setData("text/plain", q.key);
|
|
11778
|
-
},
|
|
11779
|
-
onDragOver: (e) => {
|
|
11780
|
-
if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
|
|
11781
|
-
e.preventDefault();
|
|
11782
|
-
e.stopPropagation();
|
|
11783
|
-
}
|
|
11784
|
-
},
|
|
11785
|
-
onDrop: (e) => {
|
|
11786
|
-
e.preventDefault();
|
|
11787
|
-
e.stopPropagation();
|
|
11788
|
-
const item = dragRef.current;
|
|
11789
|
-
dragRef.current = null;
|
|
11790
|
-
if (!item) return;
|
|
11791
|
-
if (item.kind === "new-type") {
|
|
11792
|
-
addQuestionOfType(item.qType, qIdx);
|
|
11793
|
-
return;
|
|
11794
|
-
}
|
|
11795
|
-
if (item.kind === "question" && item.index !== qIdx) {
|
|
11796
|
-
const next = [...questions];
|
|
11797
|
-
const [moved] = next.splice(item.index, 1);
|
|
11798
|
-
next.splice(qIdx, 0, moved);
|
|
11799
|
-
setDraft((prev) => ({ ...prev, questions: next }));
|
|
11800
|
-
setSelectedQuestionIdx(qIdx);
|
|
11801
|
-
}
|
|
11802
|
-
},
|
|
11803
|
-
onClick: () => setSelectedQuestionIdx(qIdx),
|
|
11804
13377
|
style: {
|
|
11805
|
-
|
|
11806
|
-
borderRadius:
|
|
11807
|
-
border:
|
|
11808
|
-
background:
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
alignItems: "center",
|
|
11812
|
-
justifyContent: "space-between",
|
|
11813
|
-
gap: 8
|
|
13378
|
+
position: "relative",
|
|
13379
|
+
borderRadius: 10,
|
|
13380
|
+
border: isQuestionZoneHovered ? "2px dashed #2563eb" : isFocusedStep || containsSelectedQ ? "1.5px solid #60a5fa" : "1px solid #cbd5e1",
|
|
13381
|
+
background: "#ffffff",
|
|
13382
|
+
boxShadow: isFocusedStep || containsSelectedQ ? "0 2px 10px rgba(37, 99, 235, 0.08)" : "none",
|
|
13383
|
+
transition: "border-color 0.14s ease, box-shadow 0.14s ease"
|
|
11814
13384
|
},
|
|
11815
13385
|
children: [
|
|
13386
|
+
stepIndicatorBefore && /* @__PURE__ */ jsx(
|
|
13387
|
+
"div",
|
|
13388
|
+
{
|
|
13389
|
+
style: {
|
|
13390
|
+
position: "absolute",
|
|
13391
|
+
top: -5,
|
|
13392
|
+
left: 6,
|
|
13393
|
+
right: 6,
|
|
13394
|
+
height: 3,
|
|
13395
|
+
borderRadius: 3,
|
|
13396
|
+
background: "#2563eb",
|
|
13397
|
+
zIndex: 5
|
|
13398
|
+
}
|
|
13399
|
+
}
|
|
13400
|
+
),
|
|
11816
13401
|
/* @__PURE__ */ jsxs(
|
|
11817
13402
|
"div",
|
|
11818
13403
|
{
|
|
13404
|
+
draggable: stepDragReadyId === st.id,
|
|
13405
|
+
onClick: () => setActiveStepId(st.id),
|
|
13406
|
+
onDragStart: (e) => {
|
|
13407
|
+
if (stepDragReadyId !== st.id) {
|
|
13408
|
+
e.preventDefault();
|
|
13409
|
+
return;
|
|
13410
|
+
}
|
|
13411
|
+
dragRef.current = {
|
|
13412
|
+
kind: "step",
|
|
13413
|
+
index: sIdx,
|
|
13414
|
+
stepId: st.id
|
|
13415
|
+
};
|
|
13416
|
+
e.dataTransfer.effectAllowed = "move";
|
|
13417
|
+
e.dataTransfer.setData("text/plain", st.id);
|
|
13418
|
+
},
|
|
13419
|
+
onDragEnd: () => {
|
|
13420
|
+
dragRef.current = null;
|
|
13421
|
+
setStepDragReadyId(null);
|
|
13422
|
+
setDropIndicator(null);
|
|
13423
|
+
clearHoverExpandTimer();
|
|
13424
|
+
},
|
|
13425
|
+
onDragOver: (e) => {
|
|
13426
|
+
const item = dragRef.current;
|
|
13427
|
+
if (!item) return;
|
|
13428
|
+
if (item.kind === "step") {
|
|
13429
|
+
if (item.stepId === st.id) return;
|
|
13430
|
+
e.preventDefault();
|
|
13431
|
+
e.stopPropagation();
|
|
13432
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
13433
|
+
const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
|
|
13434
|
+
setDropIndicator({ kind: "step", targetId: st.id, position: pos });
|
|
13435
|
+
} else if (item.kind === "question" || item.kind === "new-type") {
|
|
13436
|
+
e.preventDefault();
|
|
13437
|
+
e.stopPropagation();
|
|
13438
|
+
setDropIndicator({ kind: "step-zone", targetId: st.id });
|
|
13439
|
+
if (isCollapsed && hoverExpandTimerRef.current?.stepId !== st.id) {
|
|
13440
|
+
clearHoverExpandTimer();
|
|
13441
|
+
hoverExpandTimerRef.current = {
|
|
13442
|
+
stepId: st.id,
|
|
13443
|
+
timer: setTimeout(() => {
|
|
13444
|
+
setCollapsedStepIds((prev) => ({
|
|
13445
|
+
...prev,
|
|
13446
|
+
[st.id]: false
|
|
13447
|
+
}));
|
|
13448
|
+
hoverExpandTimerRef.current = null;
|
|
13449
|
+
}, 380)
|
|
13450
|
+
};
|
|
13451
|
+
}
|
|
13452
|
+
}
|
|
13453
|
+
},
|
|
13454
|
+
onDragLeave: () => {
|
|
13455
|
+
clearHoverExpandTimer();
|
|
13456
|
+
},
|
|
13457
|
+
onDrop: (e) => {
|
|
13458
|
+
e.preventDefault();
|
|
13459
|
+
e.stopPropagation();
|
|
13460
|
+
clearHoverExpandTimer();
|
|
13461
|
+
const item = dragRef.current;
|
|
13462
|
+
const curInd = dropIndicator;
|
|
13463
|
+
dragRef.current = null;
|
|
13464
|
+
setStepDragReadyId(null);
|
|
13465
|
+
setDropIndicator(null);
|
|
13466
|
+
if (!item) return;
|
|
13467
|
+
if (item.kind === "step" && item.stepId !== st.id) {
|
|
13468
|
+
const prevSelectedKey = activeQ?.key;
|
|
13469
|
+
const pos = curInd?.kind === "step" && curInd.targetId === st.id ? curInd.position : "before";
|
|
13470
|
+
const nextDraft = reorderStepsInDraft(
|
|
13471
|
+
draft,
|
|
13472
|
+
item.stepId,
|
|
13473
|
+
st.id,
|
|
13474
|
+
pos
|
|
13475
|
+
);
|
|
13476
|
+
setDraft(nextDraft);
|
|
13477
|
+
selectQuestionByKey(nextDraft.questions, prevSelectedKey);
|
|
13478
|
+
return;
|
|
13479
|
+
}
|
|
13480
|
+
if (item.kind === "question" || item.kind === "new-type") {
|
|
13481
|
+
handleDropIntoStepEnd(item);
|
|
13482
|
+
}
|
|
13483
|
+
},
|
|
11819
13484
|
style: {
|
|
13485
|
+
padding: "8px 10px",
|
|
13486
|
+
borderTopLeftRadius: 9,
|
|
13487
|
+
borderTopRightRadius: 9,
|
|
13488
|
+
borderBottomLeftRadius: isCollapsed ? 9 : 0,
|
|
13489
|
+
borderBottomRightRadius: isCollapsed ? 9 : 0,
|
|
13490
|
+
borderBottom: isCollapsed ? "none" : "1px solid #e2e8f0",
|
|
13491
|
+
background: isQuestionZoneHovered ? "#dbeafe" : isFocusedStep || containsSelectedQ ? "#eff6ff" : "#f8fafc",
|
|
11820
13492
|
display: "flex",
|
|
11821
|
-
|
|
11822
|
-
gap:
|
|
11823
|
-
overflow: "hidden"
|
|
13493
|
+
flexDirection: "column",
|
|
13494
|
+
gap: 6
|
|
11824
13495
|
},
|
|
11825
13496
|
children: [
|
|
11826
|
-
/* @__PURE__ */
|
|
11827
|
-
|
|
13497
|
+
/* @__PURE__ */ jsxs(
|
|
13498
|
+
"div",
|
|
11828
13499
|
{
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
13500
|
+
style: {
|
|
13501
|
+
display: "flex",
|
|
13502
|
+
alignItems: "center",
|
|
13503
|
+
justifyContent: "space-between",
|
|
13504
|
+
gap: 6
|
|
13505
|
+
},
|
|
13506
|
+
children: [
|
|
13507
|
+
/* @__PURE__ */ jsxs(
|
|
13508
|
+
"div",
|
|
13509
|
+
{
|
|
13510
|
+
style: {
|
|
13511
|
+
display: "flex",
|
|
13512
|
+
alignItems: "center",
|
|
13513
|
+
gap: 6,
|
|
13514
|
+
minWidth: 0
|
|
13515
|
+
},
|
|
13516
|
+
children: [
|
|
13517
|
+
/* @__PURE__ */ jsx(
|
|
13518
|
+
"span",
|
|
13519
|
+
{
|
|
13520
|
+
onMouseDown: () => setStepDragReadyId(st.id),
|
|
13521
|
+
onMouseUp: () => setStepDragReadyId(null),
|
|
13522
|
+
title: tr ? "Adımı sürükleyerek sıralayın" : "Drag to reorder step category",
|
|
13523
|
+
style: {
|
|
13524
|
+
display: "inline-flex",
|
|
13525
|
+
alignItems: "center",
|
|
13526
|
+
padding: "2px 3px",
|
|
13527
|
+
borderRadius: 4,
|
|
13528
|
+
cursor: "grab",
|
|
13529
|
+
background: "#e2e8f0"
|
|
13530
|
+
},
|
|
13531
|
+
children: /* @__PURE__ */ jsx(
|
|
13532
|
+
MaterialIcon,
|
|
13533
|
+
{
|
|
13534
|
+
name: "drag_indicator",
|
|
13535
|
+
size: 15,
|
|
13536
|
+
color: "#334155"
|
|
13537
|
+
}
|
|
13538
|
+
)
|
|
13539
|
+
}
|
|
13540
|
+
),
|
|
13541
|
+
/* @__PURE__ */ jsxs(
|
|
13542
|
+
"button",
|
|
13543
|
+
{
|
|
13544
|
+
type: "button",
|
|
13545
|
+
onClick: (e) => {
|
|
13546
|
+
e.stopPropagation();
|
|
13547
|
+
setCollapsedStepIds((prev) => ({
|
|
13548
|
+
...prev,
|
|
13549
|
+
[st.id]: !prev[st.id]
|
|
13550
|
+
}));
|
|
13551
|
+
setActiveStepId(st.id);
|
|
13552
|
+
},
|
|
13553
|
+
style: {
|
|
13554
|
+
border: "none",
|
|
13555
|
+
background: "transparent",
|
|
13556
|
+
padding: "2px 4px",
|
|
13557
|
+
cursor: "pointer",
|
|
13558
|
+
fontSize: 12,
|
|
13559
|
+
fontWeight: 800,
|
|
13560
|
+
color: "#1e3a8a",
|
|
13561
|
+
display: "inline-flex",
|
|
13562
|
+
alignItems: "center",
|
|
13563
|
+
gap: 5
|
|
13564
|
+
},
|
|
13565
|
+
children: [
|
|
13566
|
+
/* @__PURE__ */ jsx("span", { children: isCollapsed ? "▸" : "▾" }),
|
|
13567
|
+
/* @__PURE__ */ jsx(
|
|
13568
|
+
"span",
|
|
13569
|
+
{
|
|
13570
|
+
style: {
|
|
13571
|
+
padding: "2px 7px",
|
|
13572
|
+
borderRadius: 6,
|
|
13573
|
+
background: "#1e3a8a",
|
|
13574
|
+
color: "#ffffff",
|
|
13575
|
+
fontSize: 10.5,
|
|
13576
|
+
fontWeight: 800
|
|
13577
|
+
},
|
|
13578
|
+
children: tr ? `Adım ${sIdx + 1}` : `Step ${sIdx + 1}`
|
|
13579
|
+
}
|
|
13580
|
+
),
|
|
13581
|
+
/* @__PURE__ */ jsx(
|
|
13582
|
+
"span",
|
|
13583
|
+
{
|
|
13584
|
+
style: {
|
|
13585
|
+
fontSize: 12,
|
|
13586
|
+
fontWeight: 700,
|
|
13587
|
+
color: "#0f172a"
|
|
13588
|
+
},
|
|
13589
|
+
children: pickTextForLocale(st.title, uiLocale, st.id)
|
|
13590
|
+
}
|
|
13591
|
+
)
|
|
13592
|
+
]
|
|
13593
|
+
}
|
|
13594
|
+
)
|
|
13595
|
+
]
|
|
13596
|
+
}
|
|
13597
|
+
),
|
|
13598
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
13599
|
+
/* @__PURE__ */ jsxs(
|
|
13600
|
+
"span",
|
|
13601
|
+
{
|
|
13602
|
+
style: {
|
|
13603
|
+
fontSize: 10.5,
|
|
13604
|
+
fontWeight: 700,
|
|
13605
|
+
padding: "2px 8px",
|
|
13606
|
+
borderRadius: 10,
|
|
13607
|
+
background: stepEntries.length > 0 ? "#dbeafe" : "#f1f5f9",
|
|
13608
|
+
color: stepEntries.length > 0 ? "#1e40af" : "#64748b"
|
|
13609
|
+
},
|
|
13610
|
+
children: [
|
|
13611
|
+
stepEntries.length,
|
|
13612
|
+
" ",
|
|
13613
|
+
tr ? "soru" : "Qs"
|
|
13614
|
+
]
|
|
13615
|
+
}
|
|
13616
|
+
),
|
|
13617
|
+
/* @__PURE__ */ jsx(
|
|
13618
|
+
"button",
|
|
13619
|
+
{
|
|
13620
|
+
type: "button",
|
|
13621
|
+
disabled: sIdx === 0,
|
|
13622
|
+
onClick: (e) => {
|
|
13623
|
+
e.stopPropagation();
|
|
13624
|
+
const prevKey = activeQ?.key;
|
|
13625
|
+
const nextDraft = shiftStepByOffset(draft, st.id, -1);
|
|
13626
|
+
setDraft(nextDraft);
|
|
13627
|
+
selectQuestionByKey(nextDraft.questions, prevKey);
|
|
13628
|
+
},
|
|
13629
|
+
title: tr ? "Kategoriyi yukarı taşı" : "Move step up",
|
|
13630
|
+
style: {
|
|
13631
|
+
border: "1px solid #cbd5e1",
|
|
13632
|
+
background: "#ffffff",
|
|
13633
|
+
color: sIdx === 0 ? "#cbd5e1" : "#334155",
|
|
13634
|
+
borderRadius: 4,
|
|
13635
|
+
padding: "1px 5px",
|
|
13636
|
+
fontSize: 11,
|
|
13637
|
+
cursor: sIdx === 0 ? "default" : "pointer"
|
|
13638
|
+
},
|
|
13639
|
+
children: "↑"
|
|
13640
|
+
}
|
|
13641
|
+
),
|
|
13642
|
+
/* @__PURE__ */ jsx(
|
|
13643
|
+
"button",
|
|
13644
|
+
{
|
|
13645
|
+
type: "button",
|
|
13646
|
+
disabled: sIdx === steps.length - 1,
|
|
13647
|
+
onClick: (e) => {
|
|
13648
|
+
e.stopPropagation();
|
|
13649
|
+
const prevKey = activeQ?.key;
|
|
13650
|
+
const nextDraft = shiftStepByOffset(draft, st.id, 1);
|
|
13651
|
+
setDraft(nextDraft);
|
|
13652
|
+
selectQuestionByKey(nextDraft.questions, prevKey);
|
|
13653
|
+
},
|
|
13654
|
+
title: tr ? "Kategoriyi aşağı taşı" : "Move step down",
|
|
13655
|
+
style: {
|
|
13656
|
+
border: "1px solid #cbd5e1",
|
|
13657
|
+
background: "#ffffff",
|
|
13658
|
+
color: sIdx === steps.length - 1 ? "#cbd5e1" : "#334155",
|
|
13659
|
+
borderRadius: 4,
|
|
13660
|
+
padding: "1px 5px",
|
|
13661
|
+
fontSize: 11,
|
|
13662
|
+
cursor: sIdx === steps.length - 1 ? "default" : "pointer"
|
|
13663
|
+
},
|
|
13664
|
+
children: "↓"
|
|
13665
|
+
}
|
|
13666
|
+
),
|
|
13667
|
+
/* @__PURE__ */ jsx(
|
|
13668
|
+
"button",
|
|
13669
|
+
{
|
|
13670
|
+
type: "button",
|
|
13671
|
+
disabled: steps.length <= 1,
|
|
13672
|
+
onClick: (e) => {
|
|
13673
|
+
e.stopPropagation();
|
|
13674
|
+
const prevKey = activeQ?.key;
|
|
13675
|
+
const res = deleteStepWithQuestionReassignment(
|
|
13676
|
+
draft,
|
|
13677
|
+
st.id
|
|
13678
|
+
);
|
|
13679
|
+
setDraft(res.draft);
|
|
13680
|
+
setActiveStepId(res.fallbackStepId);
|
|
13681
|
+
setCollapsedStepIds((prev) => ({
|
|
13682
|
+
...prev,
|
|
13683
|
+
[res.fallbackStepId]: false
|
|
13684
|
+
}));
|
|
13685
|
+
selectQuestionByKey(res.draft.questions, prevKey);
|
|
13686
|
+
if (res.movedQuestionCount > 0) {
|
|
13687
|
+
setStatusMsg(
|
|
13688
|
+
tr ? `${res.movedQuestionCount} soru komşu adıma aktarıldı.` : `${res.movedQuestionCount} question(s) moved to adjacent step.`
|
|
13689
|
+
);
|
|
13690
|
+
}
|
|
13691
|
+
},
|
|
13692
|
+
title: tr ? "Adımı sil (içindeki sorular komşu adıma aktarılır)" : "Delete step (reassigns questions safely)",
|
|
13693
|
+
style: {
|
|
13694
|
+
border: "none",
|
|
13695
|
+
background: "transparent",
|
|
13696
|
+
color: steps.length <= 1 ? "#cbd5e1" : "#dc2626",
|
|
13697
|
+
cursor: steps.length <= 1 ? "default" : "pointer",
|
|
13698
|
+
fontSize: 14,
|
|
13699
|
+
fontWeight: 700,
|
|
13700
|
+
padding: "0 4px"
|
|
13701
|
+
},
|
|
13702
|
+
children: "×"
|
|
13703
|
+
}
|
|
13704
|
+
)
|
|
13705
|
+
] })
|
|
13706
|
+
]
|
|
11832
13707
|
}
|
|
11833
13708
|
),
|
|
11834
|
-
|
|
11835
|
-
|
|
13709
|
+
!isCollapsed && (() => {
|
|
13710
|
+
const stDescObj = normalizeLocalizedRecord(
|
|
13711
|
+
st.description,
|
|
13712
|
+
strapiLocales
|
|
13713
|
+
);
|
|
13714
|
+
const hasFilledDesc = Object.values(stDescObj).some(
|
|
13715
|
+
(val) => String(val || "").trim().length > 0
|
|
13716
|
+
);
|
|
13717
|
+
const showStepDesc = openStepDescIds[st.id] !== void 0 ? openStepDescIds[st.id] : hasFilledDesc;
|
|
13718
|
+
const stepLocaleCols = `repeat(${Math.min(
|
|
13719
|
+
Math.max(strapiLocales.length, 1),
|
|
13720
|
+
2
|
|
13721
|
+
)}, minmax(0, 1fr))`;
|
|
13722
|
+
return /* @__PURE__ */ jsxs(
|
|
11836
13723
|
"div",
|
|
11837
13724
|
{
|
|
13725
|
+
onMouseDown: (e) => {
|
|
13726
|
+
e.stopPropagation();
|
|
13727
|
+
setStepDragReadyId(null);
|
|
13728
|
+
},
|
|
13729
|
+
onClick: (e) => e.stopPropagation(),
|
|
11838
13730
|
style: {
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
whiteSpace: "nowrap",
|
|
11843
|
-
overflow: "hidden",
|
|
11844
|
-
textOverflow: "ellipsis"
|
|
13731
|
+
display: "flex",
|
|
13732
|
+
flexDirection: "column",
|
|
13733
|
+
gap: 6
|
|
11845
13734
|
},
|
|
11846
13735
|
children: [
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
11851
|
-
|
|
13736
|
+
/* @__PURE__ */ jsx(
|
|
13737
|
+
"div",
|
|
13738
|
+
{
|
|
13739
|
+
style: {
|
|
13740
|
+
display: "grid",
|
|
13741
|
+
gridTemplateColumns: stepLocaleCols,
|
|
13742
|
+
gap: 5
|
|
13743
|
+
},
|
|
13744
|
+
children: strapiLocales.map((loc) => /* @__PURE__ */ jsxs(
|
|
13745
|
+
"div",
|
|
13746
|
+
{
|
|
13747
|
+
style: {
|
|
13748
|
+
display: "flex",
|
|
13749
|
+
alignItems: "stretch",
|
|
13750
|
+
borderRadius: 6,
|
|
13751
|
+
border: "1px solid #cbd5e1",
|
|
13752
|
+
background: "#ffffff",
|
|
13753
|
+
overflow: "hidden"
|
|
13754
|
+
},
|
|
13755
|
+
children: [
|
|
13756
|
+
/* @__PURE__ */ jsx(
|
|
13757
|
+
"span",
|
|
13758
|
+
{
|
|
13759
|
+
title: loc.name || loc.code,
|
|
13760
|
+
style: {
|
|
13761
|
+
padding: "0 7px",
|
|
13762
|
+
background: loc.isDefault ? "#dbeafe" : "#f1f5f9",
|
|
13763
|
+
color: loc.isDefault ? "#1e40af" : "#334155",
|
|
13764
|
+
fontSize: 10,
|
|
13765
|
+
fontWeight: 800,
|
|
13766
|
+
borderRight: "1px solid #cbd5e1",
|
|
13767
|
+
display: "inline-flex",
|
|
13768
|
+
alignItems: "center",
|
|
13769
|
+
flexShrink: 0
|
|
13770
|
+
},
|
|
13771
|
+
children: loc.code.toUpperCase()
|
|
13772
|
+
}
|
|
13773
|
+
),
|
|
13774
|
+
/* @__PURE__ */ jsx(
|
|
13775
|
+
"input",
|
|
13776
|
+
{
|
|
13777
|
+
type: "text",
|
|
13778
|
+
value: stTitleObj[loc.code] || "",
|
|
13779
|
+
onChange: (e) => {
|
|
13780
|
+
const nextSteps = steps.map(
|
|
13781
|
+
(item, i) => i === sIdx ? {
|
|
13782
|
+
...item,
|
|
13783
|
+
title: {
|
|
13784
|
+
...stTitleObj,
|
|
13785
|
+
[loc.code]: e.target.value
|
|
13786
|
+
}
|
|
13787
|
+
} : item
|
|
13788
|
+
);
|
|
13789
|
+
setDraft((prev) => ({
|
|
13790
|
+
...prev,
|
|
13791
|
+
steps: nextSteps
|
|
13792
|
+
}));
|
|
13793
|
+
},
|
|
13794
|
+
placeholder: tr ? "Kategori Başlığı" : "Step Title",
|
|
13795
|
+
style: {
|
|
13796
|
+
flex: 1,
|
|
13797
|
+
minWidth: 0,
|
|
13798
|
+
border: "none",
|
|
13799
|
+
outline: "none",
|
|
13800
|
+
padding: "4px 7px",
|
|
13801
|
+
fontSize: 11,
|
|
13802
|
+
color: "#0f172a",
|
|
13803
|
+
background: "transparent"
|
|
13804
|
+
}
|
|
13805
|
+
}
|
|
13806
|
+
)
|
|
13807
|
+
]
|
|
13808
|
+
},
|
|
13809
|
+
`st-${st.id}-${loc.code}`
|
|
13810
|
+
))
|
|
13811
|
+
}
|
|
13812
|
+
),
|
|
13813
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsxs(
|
|
13814
|
+
"button",
|
|
13815
|
+
{
|
|
13816
|
+
type: "button",
|
|
13817
|
+
onClick: () => setOpenStepDescIds((prev) => ({
|
|
13818
|
+
...prev,
|
|
13819
|
+
[st.id]: !showStepDesc
|
|
13820
|
+
})),
|
|
13821
|
+
style: {
|
|
13822
|
+
border: "none",
|
|
13823
|
+
background: "transparent",
|
|
13824
|
+
padding: "1px 2px",
|
|
13825
|
+
fontSize: 10.5,
|
|
13826
|
+
fontWeight: 700,
|
|
13827
|
+
color: showStepDesc ? "#1d4ed8" : "#64748b",
|
|
13828
|
+
cursor: "pointer",
|
|
13829
|
+
display: "inline-flex",
|
|
13830
|
+
alignItems: "center",
|
|
13831
|
+
gap: 4
|
|
13832
|
+
},
|
|
13833
|
+
children: [
|
|
13834
|
+
/* @__PURE__ */ jsx("span", { children: showStepDesc ? "▾" : "+" }),
|
|
13835
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "Kategori Alt Açıklaması (Opsiyonel)" : "Step Subtitle / Description (Optional)" })
|
|
13836
|
+
]
|
|
13837
|
+
}
|
|
13838
|
+
) }),
|
|
13839
|
+
showStepDesc && /* @__PURE__ */ jsx(
|
|
13840
|
+
"div",
|
|
13841
|
+
{
|
|
13842
|
+
style: {
|
|
13843
|
+
display: "grid",
|
|
13844
|
+
gridTemplateColumns: stepLocaleCols,
|
|
13845
|
+
gap: 5
|
|
13846
|
+
},
|
|
13847
|
+
children: strapiLocales.map((loc) => /* @__PURE__ */ jsxs(
|
|
13848
|
+
"div",
|
|
13849
|
+
{
|
|
13850
|
+
style: {
|
|
13851
|
+
display: "flex",
|
|
13852
|
+
alignItems: "stretch",
|
|
13853
|
+
borderRadius: 6,
|
|
13854
|
+
border: "1px dashed #cbd5e1",
|
|
13855
|
+
background: "#f8fafc",
|
|
13856
|
+
overflow: "hidden"
|
|
13857
|
+
},
|
|
13858
|
+
children: [
|
|
13859
|
+
/* @__PURE__ */ jsx(
|
|
13860
|
+
"span",
|
|
13861
|
+
{
|
|
13862
|
+
style: {
|
|
13863
|
+
padding: "0 6px",
|
|
13864
|
+
background: "#e2e8f0",
|
|
13865
|
+
color: "#475569",
|
|
13866
|
+
fontSize: 9.5,
|
|
13867
|
+
fontWeight: 800,
|
|
13868
|
+
borderRight: "1px solid #cbd5e1",
|
|
13869
|
+
display: "inline-flex",
|
|
13870
|
+
alignItems: "center",
|
|
13871
|
+
flexShrink: 0
|
|
13872
|
+
},
|
|
13873
|
+
children: loc.code.toUpperCase()
|
|
13874
|
+
}
|
|
13875
|
+
),
|
|
13876
|
+
/* @__PURE__ */ jsx(
|
|
13877
|
+
"input",
|
|
13878
|
+
{
|
|
13879
|
+
type: "text",
|
|
13880
|
+
value: stDescObj[loc.code] || "",
|
|
13881
|
+
onChange: (e) => {
|
|
13882
|
+
const nextSteps = steps.map(
|
|
13883
|
+
(item, i) => i === sIdx ? {
|
|
13884
|
+
...item,
|
|
13885
|
+
description: {
|
|
13886
|
+
...stDescObj,
|
|
13887
|
+
[loc.code]: e.target.value
|
|
13888
|
+
}
|
|
13889
|
+
} : item
|
|
13890
|
+
);
|
|
13891
|
+
setDraft((prev) => ({
|
|
13892
|
+
...prev,
|
|
13893
|
+
steps: nextSteps
|
|
13894
|
+
}));
|
|
13895
|
+
},
|
|
13896
|
+
placeholder: tr ? "Opsiyonel alt açıklama..." : "Optional step description...",
|
|
13897
|
+
style: {
|
|
13898
|
+
flex: 1,
|
|
13899
|
+
minWidth: 0,
|
|
13900
|
+
border: "none",
|
|
13901
|
+
outline: "none",
|
|
13902
|
+
padding: "4px 7px",
|
|
13903
|
+
fontSize: 10.5,
|
|
13904
|
+
color: "#334155",
|
|
13905
|
+
background: "transparent"
|
|
13906
|
+
}
|
|
13907
|
+
}
|
|
13908
|
+
)
|
|
13909
|
+
]
|
|
13910
|
+
},
|
|
13911
|
+
`stdesc-${st.id}-${loc.code}`
|
|
13912
|
+
))
|
|
13913
|
+
}
|
|
13914
|
+
)
|
|
11852
13915
|
]
|
|
11853
13916
|
}
|
|
11854
|
-
)
|
|
11855
|
-
|
|
13917
|
+
);
|
|
13918
|
+
})()
|
|
13919
|
+
]
|
|
13920
|
+
}
|
|
13921
|
+
),
|
|
13922
|
+
!isCollapsed && /* @__PURE__ */ jsxs(
|
|
13923
|
+
"div",
|
|
13924
|
+
{
|
|
13925
|
+
onDragOver: (e) => {
|
|
13926
|
+
const item = dragRef.current;
|
|
13927
|
+
if (item?.kind === "question" || item?.kind === "new-type") {
|
|
13928
|
+
e.preventDefault();
|
|
13929
|
+
setDropIndicator({ kind: "step-zone", targetId: st.id });
|
|
13930
|
+
}
|
|
13931
|
+
},
|
|
13932
|
+
onDrop: (e) => {
|
|
13933
|
+
const item = dragRef.current;
|
|
13934
|
+
if (item?.kind === "question" || item?.kind === "new-type") {
|
|
13935
|
+
e.preventDefault();
|
|
13936
|
+
e.stopPropagation();
|
|
13937
|
+
dragRef.current = null;
|
|
13938
|
+
setDropIndicator(null);
|
|
13939
|
+
handleDropIntoStepEnd(item);
|
|
13940
|
+
}
|
|
13941
|
+
},
|
|
13942
|
+
style: {
|
|
13943
|
+
padding: 9,
|
|
13944
|
+
display: "flex",
|
|
13945
|
+
flexDirection: "column",
|
|
13946
|
+
gap: 6,
|
|
13947
|
+
background: isQuestionZoneHovered ? "#f0f9ff" : "#ffffff",
|
|
13948
|
+
borderBottomLeftRadius: 9,
|
|
13949
|
+
borderBottomRightRadius: 9
|
|
13950
|
+
},
|
|
13951
|
+
children: [
|
|
13952
|
+
stepEntries.length === 0 ? /* @__PURE__ */ jsx(
|
|
13953
|
+
"div",
|
|
13954
|
+
{
|
|
13955
|
+
style: {
|
|
13956
|
+
padding: "14px 10px",
|
|
13957
|
+
borderRadius: 7,
|
|
13958
|
+
border: "1.5 dashed #cbd5e1",
|
|
13959
|
+
borderStyle: "dashed",
|
|
13960
|
+
background: "#f8fafc",
|
|
13961
|
+
textAlign: "center",
|
|
13962
|
+
fontSize: 11,
|
|
13963
|
+
color: "#64748b"
|
|
13964
|
+
},
|
|
13965
|
+
children: tr ? "Bu adımda henüz soru yok — Yukarıdan soru tipi sürükleyin veya başka bir adımdan soru taşıyın." : "No questions in this step yet — Drag a question here from another step or from the palette above."
|
|
13966
|
+
}
|
|
13967
|
+
) : stepEntries.map(({ question: q, globalIndex: qIdx, localIndex }) => {
|
|
13968
|
+
const selected = qIdx === selectedQuestionIdx;
|
|
13969
|
+
const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
|
|
13970
|
+
const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
|
|
13971
|
+
const qIndBefore = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "before";
|
|
13972
|
+
const qIndAfter = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "after";
|
|
13973
|
+
return /* @__PURE__ */ jsxs(
|
|
11856
13974
|
"div",
|
|
11857
13975
|
{
|
|
13976
|
+
draggable: true,
|
|
13977
|
+
onDragStart: (e) => {
|
|
13978
|
+
e.stopPropagation();
|
|
13979
|
+
dragRef.current = {
|
|
13980
|
+
kind: "question",
|
|
13981
|
+
index: qIdx,
|
|
13982
|
+
questionKey: q.key,
|
|
13983
|
+
fromStepId: st.id
|
|
13984
|
+
};
|
|
13985
|
+
e.dataTransfer.effectAllowed = "move";
|
|
13986
|
+
e.dataTransfer.setData("text/plain", q.key);
|
|
13987
|
+
},
|
|
13988
|
+
onDragEnd: () => {
|
|
13989
|
+
dragRef.current = null;
|
|
13990
|
+
setDropIndicator(null);
|
|
13991
|
+
clearHoverExpandTimer();
|
|
13992
|
+
},
|
|
13993
|
+
onDragOver: (e) => {
|
|
13994
|
+
const item = dragRef.current;
|
|
13995
|
+
if (item?.kind === "question" || item?.kind === "new-type") {
|
|
13996
|
+
e.preventDefault();
|
|
13997
|
+
e.stopPropagation();
|
|
13998
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
13999
|
+
const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
|
|
14000
|
+
setDropIndicator({
|
|
14001
|
+
kind: "question",
|
|
14002
|
+
targetId: q.key,
|
|
14003
|
+
position: pos
|
|
14004
|
+
});
|
|
14005
|
+
}
|
|
14006
|
+
},
|
|
14007
|
+
onDrop: (e) => {
|
|
14008
|
+
e.preventDefault();
|
|
14009
|
+
e.stopPropagation();
|
|
14010
|
+
const item = dragRef.current;
|
|
14011
|
+
const curInd = dropIndicator;
|
|
14012
|
+
dragRef.current = null;
|
|
14013
|
+
setDropIndicator(null);
|
|
14014
|
+
if (!item) return;
|
|
14015
|
+
const pos = curInd?.kind === "question" && curInd.targetId === q.key ? curInd.position : "before";
|
|
14016
|
+
if (item.kind === "new-type") {
|
|
14017
|
+
const newQ = buildQuestionFromType(
|
|
14018
|
+
item.qType,
|
|
14019
|
+
st.id,
|
|
14020
|
+
questions.map((x) => x.key)
|
|
14021
|
+
);
|
|
14022
|
+
const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ, {
|
|
14023
|
+
stepId: st.id,
|
|
14024
|
+
targetQuestionKey: q.key,
|
|
14025
|
+
position: pos
|
|
14026
|
+
});
|
|
14027
|
+
setDraft(nextDraft);
|
|
14028
|
+
setSelectedQuestionIdx(insertedIndex);
|
|
14029
|
+
setActiveStepId(st.id);
|
|
14030
|
+
return;
|
|
14031
|
+
}
|
|
14032
|
+
if (item.kind === "question") {
|
|
14033
|
+
const nextDraft = moveQuestionInMultiStepDraft(
|
|
14034
|
+
draft,
|
|
14035
|
+
item.questionKey,
|
|
14036
|
+
{
|
|
14037
|
+
stepId: st.id,
|
|
14038
|
+
targetQuestionKey: q.key,
|
|
14039
|
+
position: pos
|
|
14040
|
+
}
|
|
14041
|
+
);
|
|
14042
|
+
setDraft(nextDraft);
|
|
14043
|
+
selectQuestionByKey(
|
|
14044
|
+
nextDraft.questions,
|
|
14045
|
+
item.questionKey
|
|
14046
|
+
);
|
|
14047
|
+
setActiveStepId(st.id);
|
|
14048
|
+
}
|
|
14049
|
+
},
|
|
14050
|
+
onClick: (e) => {
|
|
14051
|
+
e.stopPropagation();
|
|
14052
|
+
setSelectedQuestionIdx(qIdx);
|
|
14053
|
+
setActiveStepId(st.id);
|
|
14054
|
+
},
|
|
11858
14055
|
style: {
|
|
14056
|
+
position: "relative",
|
|
14057
|
+
padding: "8px 10px",
|
|
14058
|
+
borderRadius: 7,
|
|
14059
|
+
border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
14060
|
+
background: selected ? "#eff6ff" : "#f8fafc",
|
|
14061
|
+
cursor: "grab",
|
|
11859
14062
|
display: "flex",
|
|
11860
14063
|
alignItems: "center",
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
color: "#64748b",
|
|
11864
|
-
marginTop: 2
|
|
14064
|
+
justifyContent: "space-between",
|
|
14065
|
+
gap: 8
|
|
11865
14066
|
},
|
|
11866
14067
|
children: [
|
|
11867
|
-
/* @__PURE__ */ jsx(
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
14068
|
+
qIndBefore && /* @__PURE__ */ jsx(
|
|
14069
|
+
"div",
|
|
14070
|
+
{
|
|
14071
|
+
style: {
|
|
14072
|
+
position: "absolute",
|
|
14073
|
+
top: -4,
|
|
14074
|
+
left: 4,
|
|
14075
|
+
right: 4,
|
|
14076
|
+
height: 2.5,
|
|
14077
|
+
borderRadius: 2,
|
|
14078
|
+
background: "#2563eb",
|
|
14079
|
+
zIndex: 4
|
|
14080
|
+
}
|
|
14081
|
+
}
|
|
14082
|
+
),
|
|
14083
|
+
/* @__PURE__ */ jsxs(
|
|
14084
|
+
"div",
|
|
14085
|
+
{
|
|
14086
|
+
style: {
|
|
14087
|
+
display: "flex",
|
|
14088
|
+
alignItems: "center",
|
|
14089
|
+
gap: 7,
|
|
14090
|
+
overflow: "hidden"
|
|
14091
|
+
},
|
|
14092
|
+
children: [
|
|
14093
|
+
/* @__PURE__ */ jsx(
|
|
14094
|
+
MaterialIcon,
|
|
14095
|
+
{
|
|
14096
|
+
name: "drag_indicator",
|
|
14097
|
+
size: 15,
|
|
14098
|
+
color: selected ? "#2563eb" : "#94a3b8"
|
|
14099
|
+
}
|
|
14100
|
+
),
|
|
14101
|
+
/* @__PURE__ */ jsxs("div", { style: { overflow: "hidden" }, children: [
|
|
14102
|
+
/* @__PURE__ */ jsxs(
|
|
14103
|
+
"div",
|
|
14104
|
+
{
|
|
14105
|
+
style: {
|
|
14106
|
+
fontSize: 12,
|
|
14107
|
+
fontWeight: 700,
|
|
14108
|
+
color: "#0f172a",
|
|
14109
|
+
whiteSpace: "nowrap",
|
|
14110
|
+
overflow: "hidden",
|
|
14111
|
+
textOverflow: "ellipsis"
|
|
14112
|
+
},
|
|
14113
|
+
children: [
|
|
14114
|
+
/* @__PURE__ */ jsxs(
|
|
14115
|
+
"span",
|
|
14116
|
+
{
|
|
14117
|
+
style: {
|
|
14118
|
+
color: "#2563eb",
|
|
14119
|
+
marginRight: 4,
|
|
14120
|
+
fontSize: 11
|
|
14121
|
+
},
|
|
14122
|
+
children: [
|
|
14123
|
+
sIdx + 1,
|
|
14124
|
+
".",
|
|
14125
|
+
localIndex + 1
|
|
14126
|
+
]
|
|
14127
|
+
}
|
|
14128
|
+
),
|
|
14129
|
+
qTitle,
|
|
14130
|
+
" ",
|
|
14131
|
+
q.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626" }, children: "*" })
|
|
14132
|
+
]
|
|
14133
|
+
}
|
|
14134
|
+
),
|
|
14135
|
+
/* @__PURE__ */ jsxs(
|
|
14136
|
+
"div",
|
|
14137
|
+
{
|
|
14138
|
+
style: {
|
|
14139
|
+
display: "flex",
|
|
14140
|
+
alignItems: "center",
|
|
14141
|
+
gap: 6,
|
|
14142
|
+
fontSize: 10,
|
|
14143
|
+
color: "#64748b",
|
|
14144
|
+
marginTop: 2
|
|
14145
|
+
},
|
|
14146
|
+
children: [
|
|
14147
|
+
/* @__PURE__ */ jsx("code", { children: q.key }),
|
|
14148
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
14149
|
+
"• ",
|
|
14150
|
+
q.type
|
|
14151
|
+
] }),
|
|
14152
|
+
hasCond && /* @__PURE__ */ jsx(
|
|
14153
|
+
"span",
|
|
14154
|
+
{
|
|
14155
|
+
style: {
|
|
14156
|
+
padding: "1px 5px",
|
|
14157
|
+
borderRadius: 4,
|
|
14158
|
+
background: "#fef3c7",
|
|
14159
|
+
color: "#92400e",
|
|
14160
|
+
fontWeight: 700
|
|
14161
|
+
},
|
|
14162
|
+
children: tr ? "Koşullu" : "Skip Logic"
|
|
14163
|
+
}
|
|
14164
|
+
)
|
|
14165
|
+
]
|
|
14166
|
+
}
|
|
14167
|
+
)
|
|
14168
|
+
] })
|
|
14169
|
+
]
|
|
14170
|
+
}
|
|
14171
|
+
),
|
|
14172
|
+
/* @__PURE__ */ jsx(
|
|
14173
|
+
"button",
|
|
11878
14174
|
{
|
|
14175
|
+
type: "button",
|
|
14176
|
+
onClick: (e) => {
|
|
14177
|
+
e.stopPropagation();
|
|
14178
|
+
removeQuestion(qIdx);
|
|
14179
|
+
},
|
|
11879
14180
|
style: {
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
14181
|
+
border: "none",
|
|
14182
|
+
background: "transparent",
|
|
14183
|
+
color: "#dc2626",
|
|
14184
|
+
cursor: "pointer",
|
|
14185
|
+
fontSize: 15
|
|
11885
14186
|
},
|
|
11886
|
-
|
|
14187
|
+
title: tr ? "Soruyu sil" : "Delete question",
|
|
14188
|
+
children: "×"
|
|
14189
|
+
}
|
|
14190
|
+
),
|
|
14191
|
+
qIndAfter && /* @__PURE__ */ jsx(
|
|
14192
|
+
"div",
|
|
14193
|
+
{
|
|
14194
|
+
style: {
|
|
14195
|
+
position: "absolute",
|
|
14196
|
+
bottom: -4,
|
|
14197
|
+
left: 4,
|
|
14198
|
+
right: 4,
|
|
14199
|
+
height: 2.5,
|
|
14200
|
+
borderRadius: 2,
|
|
14201
|
+
background: "#2563eb",
|
|
14202
|
+
zIndex: 4
|
|
14203
|
+
}
|
|
11887
14204
|
}
|
|
11888
14205
|
)
|
|
11889
14206
|
]
|
|
11890
|
-
}
|
|
11891
|
-
|
|
11892
|
-
|
|
14207
|
+
},
|
|
14208
|
+
q.key || qIdx
|
|
14209
|
+
);
|
|
14210
|
+
}),
|
|
14211
|
+
/* @__PURE__ */ jsxs(
|
|
14212
|
+
"button",
|
|
14213
|
+
{
|
|
14214
|
+
type: "button",
|
|
14215
|
+
onClick: (e) => {
|
|
14216
|
+
e.stopPropagation();
|
|
14217
|
+
addQuestionOfType("single_choice", void 0, st.id);
|
|
14218
|
+
},
|
|
14219
|
+
style: {
|
|
14220
|
+
marginTop: 2,
|
|
14221
|
+
padding: "5px 8px",
|
|
14222
|
+
borderRadius: 6,
|
|
14223
|
+
border: "1px dashed #93c5fd",
|
|
14224
|
+
background: "#f8fafc",
|
|
14225
|
+
color: "#1d4ed8",
|
|
14226
|
+
fontSize: 10.5,
|
|
14227
|
+
fontWeight: 700,
|
|
14228
|
+
cursor: "pointer"
|
|
14229
|
+
},
|
|
14230
|
+
children: [
|
|
14231
|
+
"+ ",
|
|
14232
|
+
tr ? "Bu Adıma Soru Ekle" : "Add Question to This Step"
|
|
14233
|
+
]
|
|
14234
|
+
}
|
|
14235
|
+
)
|
|
11893
14236
|
]
|
|
11894
14237
|
}
|
|
11895
14238
|
),
|
|
11896
|
-
/* @__PURE__ */ jsx(
|
|
11897
|
-
"
|
|
14239
|
+
stepIndicatorAfter && /* @__PURE__ */ jsx(
|
|
14240
|
+
"div",
|
|
11898
14241
|
{
|
|
11899
|
-
type: "button",
|
|
11900
|
-
onClick: (e) => {
|
|
11901
|
-
e.stopPropagation();
|
|
11902
|
-
removeQuestion(qIdx);
|
|
11903
|
-
},
|
|
11904
14242
|
style: {
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
14243
|
+
position: "absolute",
|
|
14244
|
+
bottom: -5,
|
|
14245
|
+
left: 6,
|
|
14246
|
+
right: 6,
|
|
14247
|
+
height: 3,
|
|
14248
|
+
borderRadius: 3,
|
|
14249
|
+
background: "#2563eb",
|
|
14250
|
+
zIndex: 5
|
|
14251
|
+
}
|
|
11913
14252
|
}
|
|
11914
14253
|
)
|
|
11915
14254
|
]
|
|
11916
14255
|
},
|
|
11917
|
-
|
|
14256
|
+
st.id
|
|
11918
14257
|
);
|
|
11919
14258
|
})
|
|
11920
|
-
}
|
|
14259
|
+
] });
|
|
14260
|
+
})() : (
|
|
14261
|
+
/* SINGLE-PAGE / QUICK-POLL FLAT DRAGGABLE QUESTIONS LIST */
|
|
14262
|
+
/* @__PURE__ */ jsx(
|
|
14263
|
+
"div",
|
|
14264
|
+
{
|
|
14265
|
+
onDragOver: (e) => {
|
|
14266
|
+
if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
|
|
14267
|
+
e.preventDefault();
|
|
14268
|
+
}
|
|
14269
|
+
},
|
|
14270
|
+
onDrop: (e) => {
|
|
14271
|
+
e.preventDefault();
|
|
14272
|
+
if (dragRef.current?.kind === "new-type") {
|
|
14273
|
+
const t = dragRef.current.qType;
|
|
14274
|
+
dragRef.current = null;
|
|
14275
|
+
setDropIndicator(null);
|
|
14276
|
+
addQuestionOfType(t);
|
|
14277
|
+
}
|
|
14278
|
+
},
|
|
14279
|
+
style: { display: "flex", flexDirection: "column", gap: 7 },
|
|
14280
|
+
children: questions.map((q, qIdx) => {
|
|
14281
|
+
const selected = qIdx === selectedQuestionIdx;
|
|
14282
|
+
const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
|
|
14283
|
+
const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
|
|
14284
|
+
const qIndBefore = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "before";
|
|
14285
|
+
const qIndAfter = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "after";
|
|
14286
|
+
return /* @__PURE__ */ jsxs(
|
|
14287
|
+
"div",
|
|
14288
|
+
{
|
|
14289
|
+
draggable: true,
|
|
14290
|
+
onDragStart: (e) => {
|
|
14291
|
+
dragRef.current = {
|
|
14292
|
+
kind: "question",
|
|
14293
|
+
index: qIdx,
|
|
14294
|
+
questionKey: q.key
|
|
14295
|
+
};
|
|
14296
|
+
e.dataTransfer.setData("text/plain", q.key);
|
|
14297
|
+
},
|
|
14298
|
+
onDragEnd: () => {
|
|
14299
|
+
dragRef.current = null;
|
|
14300
|
+
setDropIndicator(null);
|
|
14301
|
+
},
|
|
14302
|
+
onDragOver: (e) => {
|
|
14303
|
+
if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
|
|
14304
|
+
e.preventDefault();
|
|
14305
|
+
e.stopPropagation();
|
|
14306
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
14307
|
+
const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
|
|
14308
|
+
setDropIndicator({
|
|
14309
|
+
kind: "question",
|
|
14310
|
+
targetId: q.key,
|
|
14311
|
+
position: pos
|
|
14312
|
+
});
|
|
14313
|
+
}
|
|
14314
|
+
},
|
|
14315
|
+
onDrop: (e) => {
|
|
14316
|
+
e.preventDefault();
|
|
14317
|
+
e.stopPropagation();
|
|
14318
|
+
const item = dragRef.current;
|
|
14319
|
+
const curInd = dropIndicator;
|
|
14320
|
+
dragRef.current = null;
|
|
14321
|
+
setDropIndicator(null);
|
|
14322
|
+
if (!item) return;
|
|
14323
|
+
const pos = curInd?.kind === "question" && curInd.targetId === q.key ? curInd.position : "before";
|
|
14324
|
+
if (item.kind === "new-type") {
|
|
14325
|
+
const insIdx = pos === "after" ? qIdx + 1 : qIdx;
|
|
14326
|
+
addQuestionOfType(item.qType, insIdx);
|
|
14327
|
+
return;
|
|
14328
|
+
}
|
|
14329
|
+
if (item.kind === "question" && item.questionKey !== q.key) {
|
|
14330
|
+
const next = reorderFlatQuestions(
|
|
14331
|
+
questions,
|
|
14332
|
+
item.questionKey,
|
|
14333
|
+
q.key,
|
|
14334
|
+
pos
|
|
14335
|
+
);
|
|
14336
|
+
setDraft((prev) => ({ ...prev, questions: next }));
|
|
14337
|
+
selectQuestionByKey(next, item.questionKey);
|
|
14338
|
+
}
|
|
14339
|
+
},
|
|
14340
|
+
onClick: () => setSelectedQuestionIdx(qIdx),
|
|
14341
|
+
style: {
|
|
14342
|
+
position: "relative",
|
|
14343
|
+
padding: "9px 10px",
|
|
14344
|
+
borderRadius: 8,
|
|
14345
|
+
border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
14346
|
+
background: selected ? "#eff6ff" : "#ffffff",
|
|
14347
|
+
cursor: "grab",
|
|
14348
|
+
display: "flex",
|
|
14349
|
+
alignItems: "center",
|
|
14350
|
+
justifyContent: "space-between",
|
|
14351
|
+
gap: 8
|
|
14352
|
+
},
|
|
14353
|
+
children: [
|
|
14354
|
+
qIndBefore && /* @__PURE__ */ jsx(
|
|
14355
|
+
"div",
|
|
14356
|
+
{
|
|
14357
|
+
style: {
|
|
14358
|
+
position: "absolute",
|
|
14359
|
+
top: -4,
|
|
14360
|
+
left: 4,
|
|
14361
|
+
right: 4,
|
|
14362
|
+
height: 2.5,
|
|
14363
|
+
borderRadius: 2,
|
|
14364
|
+
background: "#2563eb",
|
|
14365
|
+
zIndex: 4
|
|
14366
|
+
}
|
|
14367
|
+
}
|
|
14368
|
+
),
|
|
14369
|
+
/* @__PURE__ */ jsxs(
|
|
14370
|
+
"div",
|
|
14371
|
+
{
|
|
14372
|
+
style: {
|
|
14373
|
+
display: "flex",
|
|
14374
|
+
alignItems: "center",
|
|
14375
|
+
gap: 7,
|
|
14376
|
+
overflow: "hidden"
|
|
14377
|
+
},
|
|
14378
|
+
children: [
|
|
14379
|
+
/* @__PURE__ */ jsx(
|
|
14380
|
+
MaterialIcon,
|
|
14381
|
+
{
|
|
14382
|
+
name: "drag_indicator",
|
|
14383
|
+
size: 16,
|
|
14384
|
+
color: selected ? "#2563eb" : "#94a3b8"
|
|
14385
|
+
}
|
|
14386
|
+
),
|
|
14387
|
+
/* @__PURE__ */ jsxs("div", { style: { overflow: "hidden" }, children: [
|
|
14388
|
+
/* @__PURE__ */ jsxs(
|
|
14389
|
+
"div",
|
|
14390
|
+
{
|
|
14391
|
+
style: {
|
|
14392
|
+
fontSize: 12,
|
|
14393
|
+
fontWeight: 700,
|
|
14394
|
+
color: "#0f172a",
|
|
14395
|
+
whiteSpace: "nowrap",
|
|
14396
|
+
overflow: "hidden",
|
|
14397
|
+
textOverflow: "ellipsis"
|
|
14398
|
+
},
|
|
14399
|
+
children: [
|
|
14400
|
+
qIdx + 1,
|
|
14401
|
+
". ",
|
|
14402
|
+
qTitle,
|
|
14403
|
+
" ",
|
|
14404
|
+
q.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626" }, children: "*" })
|
|
14405
|
+
]
|
|
14406
|
+
}
|
|
14407
|
+
),
|
|
14408
|
+
/* @__PURE__ */ jsxs(
|
|
14409
|
+
"div",
|
|
14410
|
+
{
|
|
14411
|
+
style: {
|
|
14412
|
+
display: "flex",
|
|
14413
|
+
alignItems: "center",
|
|
14414
|
+
gap: 6,
|
|
14415
|
+
fontSize: 10,
|
|
14416
|
+
color: "#64748b",
|
|
14417
|
+
marginTop: 2
|
|
14418
|
+
},
|
|
14419
|
+
children: [
|
|
14420
|
+
/* @__PURE__ */ jsx("code", { children: q.key }),
|
|
14421
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
14422
|
+
"• ",
|
|
14423
|
+
q.type
|
|
14424
|
+
] }),
|
|
14425
|
+
hasCond && /* @__PURE__ */ jsx(
|
|
14426
|
+
"span",
|
|
14427
|
+
{
|
|
14428
|
+
style: {
|
|
14429
|
+
padding: "1px 5px",
|
|
14430
|
+
borderRadius: 4,
|
|
14431
|
+
background: "#fef3c7",
|
|
14432
|
+
color: "#92400e",
|
|
14433
|
+
fontWeight: 700
|
|
14434
|
+
},
|
|
14435
|
+
children: tr ? "Koşullu" : "Skip Logic"
|
|
14436
|
+
}
|
|
14437
|
+
)
|
|
14438
|
+
]
|
|
14439
|
+
}
|
|
14440
|
+
)
|
|
14441
|
+
] })
|
|
14442
|
+
]
|
|
14443
|
+
}
|
|
14444
|
+
),
|
|
14445
|
+
/* @__PURE__ */ jsx(
|
|
14446
|
+
"button",
|
|
14447
|
+
{
|
|
14448
|
+
type: "button",
|
|
14449
|
+
onClick: (e) => {
|
|
14450
|
+
e.stopPropagation();
|
|
14451
|
+
removeQuestion(qIdx);
|
|
14452
|
+
},
|
|
14453
|
+
style: {
|
|
14454
|
+
border: "none",
|
|
14455
|
+
background: "transparent",
|
|
14456
|
+
color: "#dc2626",
|
|
14457
|
+
cursor: "pointer",
|
|
14458
|
+
fontSize: 15
|
|
14459
|
+
},
|
|
14460
|
+
title: tr ? "Soruyu sil" : "Delete question",
|
|
14461
|
+
children: "×"
|
|
14462
|
+
}
|
|
14463
|
+
),
|
|
14464
|
+
qIndAfter && /* @__PURE__ */ jsx(
|
|
14465
|
+
"div",
|
|
14466
|
+
{
|
|
14467
|
+
style: {
|
|
14468
|
+
position: "absolute",
|
|
14469
|
+
bottom: -4,
|
|
14470
|
+
left: 4,
|
|
14471
|
+
right: 4,
|
|
14472
|
+
height: 2.5,
|
|
14473
|
+
borderRadius: 2,
|
|
14474
|
+
background: "#2563eb",
|
|
14475
|
+
zIndex: 4
|
|
14476
|
+
}
|
|
14477
|
+
}
|
|
14478
|
+
)
|
|
14479
|
+
]
|
|
14480
|
+
},
|
|
14481
|
+
q.key || qIdx
|
|
14482
|
+
);
|
|
14483
|
+
})
|
|
14484
|
+
}
|
|
14485
|
+
)
|
|
11921
14486
|
)
|
|
11922
14487
|
]
|
|
11923
14488
|
}
|
|
@@ -11985,7 +14550,10 @@ const SurveyStudioModal = ({
|
|
|
11985
14550
|
type: "text",
|
|
11986
14551
|
value: activeQ.key,
|
|
11987
14552
|
onChange: (e) => updateActiveQuestion({
|
|
11988
|
-
key:
|
|
14553
|
+
key: sanitizeSlugInput(e.target.value)
|
|
14554
|
+
}),
|
|
14555
|
+
onBlur: (e) => updateActiveQuestion({
|
|
14556
|
+
key: slugifyKey(e.target.value) || `q_${activeQ.type}_${selectedQuestionIdx + 1}`
|
|
11989
14557
|
}),
|
|
11990
14558
|
style: { ...inputStyle, fontFamily: "monospace" }
|
|
11991
14559
|
}
|
|
@@ -12009,7 +14577,17 @@ const SurveyStudioModal = ({
|
|
|
12009
14577
|
"select",
|
|
12010
14578
|
{
|
|
12011
14579
|
value: activeQ.stepId || steps[0]?.id || "",
|
|
12012
|
-
onChange: (e) =>
|
|
14580
|
+
onChange: (e) => {
|
|
14581
|
+
const nextStepId = e.target.value;
|
|
14582
|
+
const nextDraft = moveQuestionInMultiStepDraft(draft, activeQ.key, {
|
|
14583
|
+
stepId: nextStepId,
|
|
14584
|
+
position: "end"
|
|
14585
|
+
});
|
|
14586
|
+
setDraft(nextDraft);
|
|
14587
|
+
selectQuestionByKey(nextDraft.questions, activeQ.key);
|
|
14588
|
+
setActiveStepId(nextStepId);
|
|
14589
|
+
setCollapsedStepIds((prev) => ({ ...prev, [nextStepId]: false }));
|
|
14590
|
+
},
|
|
12013
14591
|
style: inputStyle,
|
|
12014
14592
|
children: steps.map((st) => /* @__PURE__ */ jsx("option", { value: st.id, children: pickTextForLocale(st.title, uiLocale, st.id) }, st.id))
|
|
12015
14593
|
}
|
|
@@ -12275,7 +14853,16 @@ const SurveyStudioModal = ({
|
|
|
12275
14853
|
value: opt.id,
|
|
12276
14854
|
onChange: (e) => {
|
|
12277
14855
|
const next = opts.map(
|
|
12278
|
-
(x, i) => i === oIdx ? { ...x, id:
|
|
14856
|
+
(x, i) => i === oIdx ? { ...x, id: sanitizeSlugInput(e.target.value) } : x
|
|
14857
|
+
);
|
|
14858
|
+
saveOpts(next);
|
|
14859
|
+
},
|
|
14860
|
+
onBlur: (e) => {
|
|
14861
|
+
const next = opts.map(
|
|
14862
|
+
(x, i) => i === oIdx ? {
|
|
14863
|
+
...x,
|
|
14864
|
+
id: slugifyKey(e.target.value) || `opt_${oIdx + 1}`
|
|
14865
|
+
} : x
|
|
12279
14866
|
);
|
|
12280
14867
|
saveOpts(next);
|
|
12281
14868
|
},
|
|
@@ -12343,7 +14930,7 @@ const SurveyStudioModal = ({
|
|
|
12343
14930
|
) })
|
|
12344
14931
|
]
|
|
12345
14932
|
},
|
|
12346
|
-
|
|
14933
|
+
oIdx
|
|
12347
14934
|
);
|
|
12348
14935
|
}),
|
|
12349
14936
|
/* @__PURE__ */ jsx(
|
|
@@ -12847,7 +15434,16 @@ const SurveyStudioModal = ({
|
|
|
12847
15434
|
value: r.id,
|
|
12848
15435
|
onChange: (e) => {
|
|
12849
15436
|
const next = mRows.map(
|
|
12850
|
-
(x, i) => i === rIdx ? { ...x, id:
|
|
15437
|
+
(x, i) => i === rIdx ? { ...x, id: sanitizeSlugInput(e.target.value) } : x
|
|
15438
|
+
);
|
|
15439
|
+
updateActiveQuestion({ matrixRows: next });
|
|
15440
|
+
},
|
|
15441
|
+
onBlur: (e) => {
|
|
15442
|
+
const next = mRows.map(
|
|
15443
|
+
(x, i) => i === rIdx ? {
|
|
15444
|
+
...x,
|
|
15445
|
+
id: slugifyKey(e.target.value) || `row_${rIdx + 1}`
|
|
15446
|
+
} : x
|
|
12851
15447
|
);
|
|
12852
15448
|
updateActiveQuestion({ matrixRows: next });
|
|
12853
15449
|
},
|
|
@@ -12890,7 +15486,7 @@ const SurveyStudioModal = ({
|
|
|
12890
15486
|
)
|
|
12891
15487
|
]
|
|
12892
15488
|
},
|
|
12893
|
-
|
|
15489
|
+
rIdx
|
|
12894
15490
|
);
|
|
12895
15491
|
})
|
|
12896
15492
|
] }),
|
|
@@ -12958,7 +15554,16 @@ const SurveyStudioModal = ({
|
|
|
12958
15554
|
value: c.id,
|
|
12959
15555
|
onChange: (e) => {
|
|
12960
15556
|
const next = mCols.map(
|
|
12961
|
-
(x, i) => i === cIdx ? { ...x, id:
|
|
15557
|
+
(x, i) => i === cIdx ? { ...x, id: sanitizeSlugInput(e.target.value) } : x
|
|
15558
|
+
);
|
|
15559
|
+
updateActiveQuestion({ matrixColumns: next });
|
|
15560
|
+
},
|
|
15561
|
+
onBlur: (e) => {
|
|
15562
|
+
const next = mCols.map(
|
|
15563
|
+
(x, i) => i === cIdx ? {
|
|
15564
|
+
...x,
|
|
15565
|
+
id: slugifyKey(e.target.value) || `col_${cIdx + 1}`
|
|
15566
|
+
} : x
|
|
12962
15567
|
);
|
|
12963
15568
|
updateActiveQuestion({ matrixColumns: next });
|
|
12964
15569
|
},
|
|
@@ -13001,7 +15606,7 @@ const SurveyStudioModal = ({
|
|
|
13001
15606
|
)
|
|
13002
15607
|
]
|
|
13003
15608
|
},
|
|
13004
|
-
|
|
15609
|
+
cIdx
|
|
13005
15610
|
);
|
|
13006
15611
|
})
|
|
13007
15612
|
] })
|
|
@@ -13225,25 +15830,102 @@ const SurveyStudioModal = ({
|
|
|
13225
15830
|
/* @__PURE__ */ jsx("div", { style: { fontSize: 13, fontWeight: 700, color: "#0f172a" }, children: tr ? "Anket Kimliği & Çok Dilli Başlıklar" : "Survey Identity & Localized Titles" }),
|
|
13226
15831
|
/* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 10 }, children: [
|
|
13227
15832
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
13228
|
-
/* @__PURE__ */ jsx("label", { style: labelStyle, children: tr ? "Yönetim Başlığı" : "Internal Title" }),
|
|
15833
|
+
/* @__PURE__ */ jsx("label", { style: labelStyle, children: tr ? "Yönetim Başlığı (Internal Title)" : "Survey Internal Title" }),
|
|
13229
15834
|
/* @__PURE__ */ jsx(
|
|
13230
15835
|
"input",
|
|
13231
15836
|
{
|
|
13232
15837
|
type: "text",
|
|
13233
15838
|
value: draft.title,
|
|
13234
|
-
onChange: (e) =>
|
|
15839
|
+
onChange: (e) => {
|
|
15840
|
+
const nextTitle = e.target.value;
|
|
15841
|
+
setDraft((prev) => ({
|
|
15842
|
+
...prev,
|
|
15843
|
+
title: nextTitle,
|
|
15844
|
+
...slugAutoSync ? { slug: slugifyKey(nextTitle) } : {}
|
|
15845
|
+
}));
|
|
15846
|
+
},
|
|
15847
|
+
placeholder: tr ? "Örn: 2026 Müşteri Nabzı Anketi" : "e.g. 2026 Customer Pulse Survey",
|
|
13235
15848
|
style: inputStyle
|
|
13236
15849
|
}
|
|
13237
15850
|
)
|
|
13238
15851
|
] }),
|
|
13239
15852
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
13240
|
-
/* @__PURE__ */
|
|
15853
|
+
/* @__PURE__ */ jsxs(
|
|
15854
|
+
"div",
|
|
15855
|
+
{
|
|
15856
|
+
style: {
|
|
15857
|
+
display: "flex",
|
|
15858
|
+
alignItems: "center",
|
|
15859
|
+
justifyContent: "space-between",
|
|
15860
|
+
gap: 6,
|
|
15861
|
+
marginBottom: 4
|
|
15862
|
+
},
|
|
15863
|
+
children: [
|
|
15864
|
+
/* @__PURE__ */ jsxs("label", { style: { ...labelStyle, marginBottom: 0 }, children: [
|
|
15865
|
+
"Survey Slug",
|
|
15866
|
+
" ",
|
|
15867
|
+
/* @__PURE__ */ jsx(
|
|
15868
|
+
"span",
|
|
15869
|
+
{
|
|
15870
|
+
style: {
|
|
15871
|
+
fontSize: 9.5,
|
|
15872
|
+
fontWeight: 700,
|
|
15873
|
+
padding: "1px 6px",
|
|
15874
|
+
borderRadius: 8,
|
|
15875
|
+
marginLeft: 4,
|
|
15876
|
+
background: slugAutoSync ? "#dbeafe" : "#f1f5f9",
|
|
15877
|
+
color: slugAutoSync ? "#1e40af" : "#475569"
|
|
15878
|
+
},
|
|
15879
|
+
children: slugAutoSync ? tr ? "Otomatik" : "Auto" : tr ? "Özel" : "Custom"
|
|
15880
|
+
}
|
|
15881
|
+
)
|
|
15882
|
+
] }),
|
|
15883
|
+
/* @__PURE__ */ jsx(
|
|
15884
|
+
"button",
|
|
15885
|
+
{
|
|
15886
|
+
type: "button",
|
|
15887
|
+
onClick: () => {
|
|
15888
|
+
const generated = slugifyKey(draft.title);
|
|
15889
|
+
setDraft((prev) => ({
|
|
15890
|
+
...prev,
|
|
15891
|
+
slug: generated || prev.slug
|
|
15892
|
+
}));
|
|
15893
|
+
setSlugAutoSync(true);
|
|
15894
|
+
},
|
|
15895
|
+
title: tr ? "Yönetim Başlığından (Internal Title) otomatik slug üret ve senkronla" : "Generate slug from Internal Title and keep synced",
|
|
15896
|
+
style: {
|
|
15897
|
+
padding: "1px 7px",
|
|
15898
|
+
borderRadius: 5,
|
|
15899
|
+
border: "1px solid #93c5fd",
|
|
15900
|
+
background: "#eff6ff",
|
|
15901
|
+
color: "#1d4ed8",
|
|
15902
|
+
fontSize: 10,
|
|
15903
|
+
fontWeight: 700,
|
|
15904
|
+
cursor: "pointer"
|
|
15905
|
+
},
|
|
15906
|
+
children: tr ? "↻ Başlıktan Üret" : "↻ From Title"
|
|
15907
|
+
}
|
|
15908
|
+
)
|
|
15909
|
+
]
|
|
15910
|
+
}
|
|
15911
|
+
),
|
|
13241
15912
|
/* @__PURE__ */ jsx(
|
|
13242
15913
|
"input",
|
|
13243
15914
|
{
|
|
13244
15915
|
type: "text",
|
|
13245
15916
|
value: draft.slug,
|
|
13246
|
-
onChange: (e) =>
|
|
15917
|
+
onChange: (e) => {
|
|
15918
|
+
setSlugAutoSync(false);
|
|
15919
|
+
setDraft((prev) => ({
|
|
15920
|
+
...prev,
|
|
15921
|
+
slug: sanitizeSlugInput(e.target.value)
|
|
15922
|
+
}));
|
|
15923
|
+
},
|
|
15924
|
+
onBlur: (e) => {
|
|
15925
|
+
const cleaned = slugifyKey(e.target.value) || slugifyKey(draft.title) || `survey-${Date.now().toString(36).slice(-4)}`;
|
|
15926
|
+
setDraft((prev) => ({ ...prev, slug: cleaned }));
|
|
15927
|
+
},
|
|
15928
|
+
placeholder: "ornek-anket_2026",
|
|
13247
15929
|
style: { ...inputStyle, fontFamily: "monospace" }
|
|
13248
15930
|
}
|
|
13249
15931
|
)
|
|
@@ -13540,7 +16222,72 @@ const SurveyStudioModal = ({
|
|
|
13540
16222
|
strapiLocales
|
|
13541
16223
|
}
|
|
13542
16224
|
),
|
|
13543
|
-
tab === "analytics" && /* @__PURE__ */ jsx("div", { style: { flex: 1, padding: 20, overflowY: "auto", background: "#f8fafc" }, children: /* @__PURE__ */ jsx(
|
|
16225
|
+
tab === "analytics" && /* @__PURE__ */ jsx("div", { style: { flex: 1, padding: 20, overflowY: "auto", background: "#f8fafc" }, children: /* @__PURE__ */ jsx(
|
|
16226
|
+
SurveyAnalyticsView,
|
|
16227
|
+
{
|
|
16228
|
+
surveySlugOrId: draft.slug,
|
|
16229
|
+
uiLocale
|
|
16230
|
+
},
|
|
16231
|
+
`${draft.slug}-${studioAnalyticsKey}`
|
|
16232
|
+
) }),
|
|
16233
|
+
/* @__PURE__ */ jsx(
|
|
16234
|
+
SurveyExportModal,
|
|
16235
|
+
{
|
|
16236
|
+
open: studioExportOpen,
|
|
16237
|
+
uiLocale,
|
|
16238
|
+
targetSurvey: draft,
|
|
16239
|
+
allowAllSurveys: false,
|
|
16240
|
+
isUnsavedDraft: !draft.id && !draft.documentId && !draft._id,
|
|
16241
|
+
onClose: () => setStudioExportOpen(false)
|
|
16242
|
+
}
|
|
16243
|
+
),
|
|
16244
|
+
/* @__PURE__ */ jsx(
|
|
16245
|
+
SurveyImportModal,
|
|
16246
|
+
{
|
|
16247
|
+
open: studioImportOpen,
|
|
16248
|
+
uiLocale,
|
|
16249
|
+
existingSlugs: draft.slug ? [draft.slug] : [],
|
|
16250
|
+
onClose: () => setStudioImportOpen(false),
|
|
16251
|
+
onImported: (res) => {
|
|
16252
|
+
const first = res.importedSurveys?.[0];
|
|
16253
|
+
if (first) {
|
|
16254
|
+
const nextDraft = first.displayMode === "multi_step" ? normalizeMultiStepDraft(JSON.parse(JSON.stringify(first))) : JSON.parse(JSON.stringify(first));
|
|
16255
|
+
setDraft(nextDraft);
|
|
16256
|
+
setSelectedQuestionIdx(0);
|
|
16257
|
+
setActiveStepId(nextDraft.steps?.[0]?.id || "step_1");
|
|
16258
|
+
setStudioAnalyticsKey((k) => k + 1);
|
|
16259
|
+
setStatusMsg(
|
|
16260
|
+
tr ? `İçe aktarıldı (${res.importedResponsesCount} yanıt)!` : `Imported (${res.importedResponsesCount} responses)!`
|
|
16261
|
+
);
|
|
16262
|
+
if (typeof window !== "undefined") {
|
|
16263
|
+
window.dispatchEvent(new CustomEvent("ci-survey-updated", { detail: first }));
|
|
16264
|
+
}
|
|
16265
|
+
onSaved?.(first);
|
|
16266
|
+
}
|
|
16267
|
+
}
|
|
16268
|
+
}
|
|
16269
|
+
),
|
|
16270
|
+
/* @__PURE__ */ jsx(
|
|
16271
|
+
SurveyCleanupConfirmModal,
|
|
16272
|
+
{
|
|
16273
|
+
open: Boolean(studioCleanupAction),
|
|
16274
|
+
action: studioCleanupAction,
|
|
16275
|
+
uiLocale,
|
|
16276
|
+
targetSurvey: draft,
|
|
16277
|
+
onClose: () => setStudioCleanupAction(null),
|
|
16278
|
+
onCompleted: (act, payload) => {
|
|
16279
|
+
if (act === "clear-responses") {
|
|
16280
|
+
const updatedDraft = { ...draft, responseCount: 0, npsScore: null };
|
|
16281
|
+
setDraft(updatedDraft);
|
|
16282
|
+
setStudioAnalyticsKey((k) => k + 1);
|
|
16283
|
+
setStatusMsg(
|
|
16284
|
+
tr ? `${payload?.deletedCount || 0} yanıt sıfırlandı.` : `Cleared ${payload?.deletedCount || 0} response(s).`
|
|
16285
|
+
);
|
|
16286
|
+
onSaved?.(updatedDraft);
|
|
16287
|
+
}
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16290
|
+
)
|
|
13544
16291
|
]
|
|
13545
16292
|
}
|
|
13546
16293
|
)
|
|
@@ -13601,13 +16348,13 @@ const SurveyWidgetEditor = ({ widget, onChange }) => {
|
|
|
13601
16348
|
/* @__PURE__ */ jsx(
|
|
13602
16349
|
"select",
|
|
13603
16350
|
{
|
|
13604
|
-
value: matchedSurvey?.slug || selectedRef,
|
|
16351
|
+
value: matchedSurvey?.slug || (surveysList.length > 0 ? selectedRef : ""),
|
|
13605
16352
|
onChange: (e) => {
|
|
13606
16353
|
const chosen = surveysList.find((s) => s.slug === e.target.value);
|
|
13607
16354
|
if (chosen) bindSurveyToWidget(chosen);
|
|
13608
16355
|
},
|
|
13609
16356
|
style: inputStyle,
|
|
13610
|
-
children: surveysList.map((s) => /* @__PURE__ */ jsxs("option", { value: s.slug, children: [
|
|
16357
|
+
children: surveysList.length === 0 ? /* @__PURE__ */ jsx("option", { value: "", children: tr ? "Henüz kayıtlı anket yok — Yeni yaratın veya JSON yükleyin" : "No surveys yet — Create new or Import JSON" }) : surveysList.map((s) => /* @__PURE__ */ jsxs("option", { value: s.slug, children: [
|
|
13611
16358
|
pickTextForLocale(s.titleI18n, locale, s.title),
|
|
13612
16359
|
" (",
|
|
13613
16360
|
s.responseCount ?? 0,
|
|
@@ -13821,9 +16568,12 @@ export {
|
|
|
13821
16568
|
pickTextForLocale as N,
|
|
13822
16569
|
SurveyAnalyticsView as O,
|
|
13823
16570
|
SurveyStudioModal as P,
|
|
13824
|
-
|
|
16571
|
+
SurveyExportModal as Q,
|
|
13825
16572
|
ROW_PRESETS as R,
|
|
13826
16573
|
StrapiMediaPicker as S,
|
|
16574
|
+
SurveyImportModal as T,
|
|
16575
|
+
SurveyCleanupConfirmModal as U,
|
|
16576
|
+
persistLocale as V,
|
|
13827
16577
|
WIDGET_DEFINITIONS as W,
|
|
13828
16578
|
ZOOM_OPTIONS as Z,
|
|
13829
16579
|
useEditorTranslator as a,
|