@ozguraltan/strapi-content-input 1.0.23 → 1.0.24
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-ByOrVZCl.js} +372 -7
- package/dist/admin/{AnalyticsHubPage-Dvpx3KsP.mjs → AnalyticsHubPage-O-7pF2E5.mjs} +372 -7
- package/dist/admin/{ContentInputField-C2kmtUwD.mjs → ContentInputField-BoZHf0Ka.mjs} +2 -2
- package/dist/admin/{ContentInputField-CjxYYEps.js → ContentInputField-DK97AIG0.js} +2 -2
- package/dist/admin/{SurveyWidgetEditor-DOYxWop9.js → SurveyWidgetEditor-D3KiAotu.js} +2927 -302
- package/dist/admin/{SurveyWidgetEditor-DMWOkHUt.mjs → SurveyWidgetEditor-Y5BR-NWE.mjs} +2928 -304
- package/dist/admin/{index-AePRA0IB.mjs → index-C5Uj5YV9.mjs} +2 -2
- package/dist/admin/{index-B9C8Qrfd.js → index-CHtB_Fa5.js} +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 +613 -20
- package/dist/server/index.mjs +613 -20
- 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-C5Uj5YV9.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",
|
|
@@ -11152,27 +12586,61 @@ const SurveyStudioModal = ({
|
|
|
11152
12586
|
const { post } = useFetchClient();
|
|
11153
12587
|
const { locales: strapiLocales } = useStrapiLocales();
|
|
11154
12588
|
const [tab, setTab] = useState(initialTab);
|
|
11155
|
-
const [draft, setDraft] = useState(
|
|
11156
|
-
|
|
11157
|
-
|
|
12589
|
+
const [draft, setDraft] = useState(() => {
|
|
12590
|
+
const cloned = JSON.parse(JSON.stringify(initialSurvey));
|
|
12591
|
+
return cloned.displayMode === "multi_step" ? normalizeMultiStepDraft(cloned) : cloned;
|
|
12592
|
+
});
|
|
11158
12593
|
const [selectedQuestionIdx, setSelectedQuestionIdx] = useState(0);
|
|
12594
|
+
const [collapsedStepIds, setCollapsedStepIds] = useState({});
|
|
12595
|
+
const [openStepDescIds, setOpenStepDescIds] = useState({});
|
|
12596
|
+
const [activeStepId, setActiveStepId] = useState(
|
|
12597
|
+
() => initialSurvey.steps?.[0]?.id || "step_1"
|
|
12598
|
+
);
|
|
12599
|
+
const [stepDragReadyId, setStepDragReadyId] = useState(null);
|
|
12600
|
+
const [dropIndicator, setDropIndicator] = useState(null);
|
|
11159
12601
|
const [saving, setSaving] = useState(false);
|
|
11160
12602
|
const [statusMsg, setStatusMsg] = useState("");
|
|
11161
12603
|
const [optDragReadyIdx, setOptDragReadyIdx] = useState(null);
|
|
12604
|
+
const [studioExportOpen, setStudioExportOpen] = useState(false);
|
|
12605
|
+
const [studioImportOpen, setStudioImportOpen] = useState(false);
|
|
12606
|
+
const [studioCleanupAction, setStudioCleanupAction] = useState(null);
|
|
12607
|
+
const [studioAnalyticsKey, setStudioAnalyticsKey] = useState(0);
|
|
11162
12608
|
const dragRef = useRef(null);
|
|
12609
|
+
const hoverExpandTimerRef = useRef(null);
|
|
12610
|
+
const clearHoverExpandTimer = () => {
|
|
12611
|
+
if (hoverExpandTimerRef.current) {
|
|
12612
|
+
clearTimeout(hoverExpandTimerRef.current.timer);
|
|
12613
|
+
hoverExpandTimerRef.current = null;
|
|
12614
|
+
}
|
|
12615
|
+
};
|
|
11163
12616
|
useEffect(() => {
|
|
11164
12617
|
if (open) {
|
|
11165
|
-
|
|
12618
|
+
const cloned = JSON.parse(JSON.stringify(initialSurvey));
|
|
12619
|
+
const nextDraft = cloned.displayMode === "multi_step" ? normalizeMultiStepDraft(cloned) : cloned;
|
|
12620
|
+
setDraft(nextDraft);
|
|
11166
12621
|
setSelectedQuestionIdx(0);
|
|
12622
|
+
setCollapsedStepIds({});
|
|
12623
|
+
setOpenStepDescIds({});
|
|
12624
|
+
setActiveStepId(nextDraft.steps?.[0]?.id || "step_1");
|
|
12625
|
+
setDropIndicator(null);
|
|
12626
|
+
setStepDragReadyId(null);
|
|
11167
12627
|
setTab(initialTab);
|
|
11168
12628
|
setStatusMsg("");
|
|
11169
12629
|
}
|
|
12630
|
+
return () => clearHoverExpandTimer();
|
|
11170
12631
|
}, [open, initialSurvey, initialTab]);
|
|
11171
12632
|
if (!open || typeof document === "undefined") return null;
|
|
11172
12633
|
const questions = Array.isArray(draft.questions) ? draft.questions : [];
|
|
11173
12634
|
const activeQ = questions[selectedQuestionIdx] || questions[0] || null;
|
|
11174
12635
|
const steps = Array.isArray(draft.steps) ? draft.steps : [];
|
|
11175
12636
|
const localeGridCols = `repeat(${Math.min(Math.max(strapiLocales.length, 1), 3)}, 1fr)`;
|
|
12637
|
+
const selectQuestionByKey = (nextQuestions, key) => {
|
|
12638
|
+
if (!key) return;
|
|
12639
|
+
const foundIdx = nextQuestions.findIndex((q) => q.key === key);
|
|
12640
|
+
if (foundIdx >= 0) {
|
|
12641
|
+
setSelectedQuestionIdx(foundIdx);
|
|
12642
|
+
}
|
|
12643
|
+
};
|
|
11176
12644
|
const updateActiveQuestion = (patch) => {
|
|
11177
12645
|
if (!activeQ) return;
|
|
11178
12646
|
setDraft((prev) => ({
|
|
@@ -11182,11 +12650,27 @@ const SurveyStudioModal = ({
|
|
|
11182
12650
|
)
|
|
11183
12651
|
}));
|
|
11184
12652
|
};
|
|
11185
|
-
const addQuestionOfType = (qType, insertAt) => {
|
|
11186
|
-
|
|
12653
|
+
const addQuestionOfType = (qType, insertAt, explicitStepId) => {
|
|
12654
|
+
if (draft.displayMode === "multi_step") {
|
|
12655
|
+
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";
|
|
12656
|
+
const newQ2 = buildQuestionFromType(
|
|
12657
|
+
qType,
|
|
12658
|
+
targetStepId,
|
|
12659
|
+
questions.map((q) => q.key)
|
|
12660
|
+
);
|
|
12661
|
+
const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ2, {
|
|
12662
|
+
stepId: targetStepId,
|
|
12663
|
+
position: "end"
|
|
12664
|
+
});
|
|
12665
|
+
setDraft(nextDraft);
|
|
12666
|
+
setSelectedQuestionIdx(insertedIndex);
|
|
12667
|
+
setActiveStepId(targetStepId);
|
|
12668
|
+
setCollapsedStepIds((prev) => ({ ...prev, [targetStepId]: false }));
|
|
12669
|
+
return;
|
|
12670
|
+
}
|
|
11187
12671
|
const newQ = buildQuestionFromType(
|
|
11188
12672
|
qType,
|
|
11189
|
-
|
|
12673
|
+
void 0,
|
|
11190
12674
|
questions.map((q) => q.key)
|
|
11191
12675
|
);
|
|
11192
12676
|
const nextList = [...questions];
|
|
@@ -11330,6 +12814,81 @@ const SurveyStudioModal = ({
|
|
|
11330
12814
|
children: statusMsg
|
|
11331
12815
|
}
|
|
11332
12816
|
),
|
|
12817
|
+
/* @__PURE__ */ jsxs(
|
|
12818
|
+
"button",
|
|
12819
|
+
{
|
|
12820
|
+
type: "button",
|
|
12821
|
+
onClick: () => setStudioImportOpen(true),
|
|
12822
|
+
title: tr ? ".ci-survey.json paketinden anket içe aktar" : "Import survey from .ci-survey.json bundle",
|
|
12823
|
+
style: {
|
|
12824
|
+
padding: "7px 11px",
|
|
12825
|
+
borderRadius: 6,
|
|
12826
|
+
border: "1px solid rgba(56, 189, 248, 0.45)",
|
|
12827
|
+
background: "rgba(14, 165, 233, 0.16)",
|
|
12828
|
+
color: "#e0f2fe",
|
|
12829
|
+
fontSize: 11.5,
|
|
12830
|
+
fontWeight: 700,
|
|
12831
|
+
cursor: "pointer",
|
|
12832
|
+
display: "inline-flex",
|
|
12833
|
+
alignItems: "center",
|
|
12834
|
+
gap: 5
|
|
12835
|
+
},
|
|
12836
|
+
children: [
|
|
12837
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "upload_file", size: 15, color: "#7dd3fc" }),
|
|
12838
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "İçe Aktar" : "Import" })
|
|
12839
|
+
]
|
|
12840
|
+
}
|
|
12841
|
+
),
|
|
12842
|
+
/* @__PURE__ */ jsxs(
|
|
12843
|
+
"button",
|
|
12844
|
+
{
|
|
12845
|
+
type: "button",
|
|
12846
|
+
onClick: () => setStudioExportOpen(true),
|
|
12847
|
+
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)",
|
|
12848
|
+
style: {
|
|
12849
|
+
padding: "7px 11px",
|
|
12850
|
+
borderRadius: 6,
|
|
12851
|
+
border: "1px solid rgba(52, 211, 153, 0.45)",
|
|
12852
|
+
background: "rgba(16, 185, 129, 0.16)",
|
|
12853
|
+
color: "#d1fae5",
|
|
12854
|
+
fontSize: 11.5,
|
|
12855
|
+
fontWeight: 700,
|
|
12856
|
+
cursor: "pointer",
|
|
12857
|
+
display: "inline-flex",
|
|
12858
|
+
alignItems: "center",
|
|
12859
|
+
gap: 5
|
|
12860
|
+
},
|
|
12861
|
+
children: [
|
|
12862
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "download", size: 15, color: "#6ee7b7" }),
|
|
12863
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "Dışa Aktar" : "Export" })
|
|
12864
|
+
]
|
|
12865
|
+
}
|
|
12866
|
+
),
|
|
12867
|
+
Boolean(draft.id || draft.documentId || draft._id) && /* @__PURE__ */ jsxs(
|
|
12868
|
+
"button",
|
|
12869
|
+
{
|
|
12870
|
+
type: "button",
|
|
12871
|
+
onClick: () => setStudioCleanupAction("clear-responses"),
|
|
12872
|
+
title: tr ? "Anket yapısını koruyarak mevcut yanıtları sıfırlar (0 yapar)" : "Clear all recorded responses while keeping survey structure",
|
|
12873
|
+
style: {
|
|
12874
|
+
padding: "7px 10px",
|
|
12875
|
+
borderRadius: 6,
|
|
12876
|
+
border: "1px solid rgba(251, 191, 36, 0.45)",
|
|
12877
|
+
background: "rgba(217, 119, 6, 0.18)",
|
|
12878
|
+
color: "#fef3c7",
|
|
12879
|
+
fontSize: 11.5,
|
|
12880
|
+
fontWeight: 700,
|
|
12881
|
+
cursor: "pointer",
|
|
12882
|
+
display: "inline-flex",
|
|
12883
|
+
alignItems: "center",
|
|
12884
|
+
gap: 5
|
|
12885
|
+
},
|
|
12886
|
+
children: [
|
|
12887
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "restart_alt", size: 15, color: "#fcd34d" }),
|
|
12888
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "Yanıt 0'la" : "Reset Resp" })
|
|
12889
|
+
]
|
|
12890
|
+
}
|
|
12891
|
+
),
|
|
11333
12892
|
/* @__PURE__ */ jsxs(
|
|
11334
12893
|
"button",
|
|
11335
12894
|
{
|
|
@@ -11540,167 +13099,35 @@ const SurveyStudioModal = ({
|
|
|
11540
13099
|
"button",
|
|
11541
13100
|
{
|
|
11542
13101
|
type: "button",
|
|
11543
|
-
onClick: () =>
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
borderRadius: 6,
|
|
11556
|
-
border: active ? "1.5px solid #2563eb" : "1px solid #cbd5e1",
|
|
11557
|
-
background: active ? "#eff6ff" : "#f8fafc",
|
|
11558
|
-
color: active ? "#1d4ed8" : "#334155",
|
|
11559
|
-
fontSize: 11,
|
|
11560
|
-
fontWeight: 700,
|
|
11561
|
-
cursor: "pointer"
|
|
11562
|
-
},
|
|
11563
|
-
children: tr ? m.tr : m.en
|
|
11564
|
-
},
|
|
11565
|
-
m.id
|
|
11566
|
-
);
|
|
11567
|
-
}) })
|
|
11568
|
-
]
|
|
11569
|
-
}
|
|
11570
|
-
),
|
|
11571
|
-
draft.displayMode === "multi_step" && /* @__PURE__ */ jsxs(
|
|
11572
|
-
"div",
|
|
11573
|
-
{
|
|
11574
|
-
style: {
|
|
11575
|
-
padding: 10,
|
|
11576
|
-
borderRadius: 8,
|
|
11577
|
-
background: "#ffffff",
|
|
11578
|
-
border: "1px solid #cbd5e1"
|
|
11579
|
-
},
|
|
11580
|
-
children: [
|
|
11581
|
-
/* @__PURE__ */ jsxs(
|
|
11582
|
-
"div",
|
|
11583
|
-
{
|
|
11584
|
-
style: {
|
|
11585
|
-
display: "flex",
|
|
11586
|
-
alignItems: "center",
|
|
11587
|
-
justifyContent: "space-between",
|
|
11588
|
-
marginBottom: 8
|
|
11589
|
-
},
|
|
11590
|
-
children: [
|
|
11591
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, fontWeight: 700, color: "#1e3a8a" }, children: tr ? "Sihirbaz Adımları (Steps)" : "Wizard Steps" }),
|
|
11592
|
-
/* @__PURE__ */ jsx(
|
|
11593
|
-
"button",
|
|
11594
|
-
{
|
|
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
|
-
style: {
|
|
11610
|
-
padding: "3px 8px",
|
|
11611
|
-
fontSize: 10,
|
|
11612
|
-
fontWeight: 700,
|
|
11613
|
-
borderRadius: 4,
|
|
11614
|
-
border: "1px solid #93c5fd",
|
|
11615
|
-
background: "#eff6ff",
|
|
11616
|
-
color: "#1d4ed8",
|
|
11617
|
-
cursor: "pointer"
|
|
11618
|
-
},
|
|
11619
|
-
children: tr ? "+ Adım Ekle" : "+ Add Step"
|
|
11620
|
-
}
|
|
11621
|
-
)
|
|
11622
|
-
]
|
|
11623
|
-
}
|
|
11624
|
-
),
|
|
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: "×"
|
|
13102
|
+
onClick: () => {
|
|
13103
|
+
setDraft((prev) => {
|
|
13104
|
+
const nextRaw = {
|
|
13105
|
+
...prev,
|
|
13106
|
+
displayMode: m.id
|
|
13107
|
+
};
|
|
13108
|
+
if (m.id === "multi_step") {
|
|
13109
|
+
const norm = normalizeMultiStepDraft(nextRaw);
|
|
13110
|
+
if (norm.steps?.[0]?.id) {
|
|
13111
|
+
setActiveStepId(norm.steps[0].id);
|
|
13112
|
+
}
|
|
13113
|
+
return norm;
|
|
11699
13114
|
}
|
|
11700
|
-
|
|
11701
|
-
|
|
13115
|
+
return nextRaw;
|
|
13116
|
+
});
|
|
13117
|
+
},
|
|
13118
|
+
style: {
|
|
13119
|
+
padding: "7px 8px",
|
|
13120
|
+
borderRadius: 6,
|
|
13121
|
+
border: active ? "1.5px solid #2563eb" : "1px solid #cbd5e1",
|
|
13122
|
+
background: active ? "#eff6ff" : "#f8fafc",
|
|
13123
|
+
color: active ? "#1d4ed8" : "#334155",
|
|
13124
|
+
fontSize: 11,
|
|
13125
|
+
fontWeight: 700,
|
|
13126
|
+
cursor: "pointer"
|
|
13127
|
+
},
|
|
13128
|
+
children: tr ? m.tr : m.en
|
|
11702
13129
|
},
|
|
11703
|
-
|
|
13130
|
+
m.id
|
|
11704
13131
|
);
|
|
11705
13132
|
}) })
|
|
11706
13133
|
]
|
|
@@ -11716,7 +13143,43 @@ const SurveyStudioModal = ({
|
|
|
11716
13143
|
border: "1px solid #cbd5e1"
|
|
11717
13144
|
},
|
|
11718
13145
|
children: [
|
|
11719
|
-
/* @__PURE__ */
|
|
13146
|
+
/* @__PURE__ */ jsxs(
|
|
13147
|
+
"div",
|
|
13148
|
+
{
|
|
13149
|
+
style: {
|
|
13150
|
+
display: "flex",
|
|
13151
|
+
alignItems: "center",
|
|
13152
|
+
justifyContent: "space-between",
|
|
13153
|
+
gap: 6,
|
|
13154
|
+
marginBottom: 6
|
|
13155
|
+
},
|
|
13156
|
+
children: [
|
|
13157
|
+
/* @__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):" }),
|
|
13158
|
+
draft.displayMode === "multi_step" && steps.length > 0 && /* @__PURE__ */ jsxs(
|
|
13159
|
+
"span",
|
|
13160
|
+
{
|
|
13161
|
+
style: {
|
|
13162
|
+
fontSize: 10,
|
|
13163
|
+
fontWeight: 700,
|
|
13164
|
+
padding: "2px 7px",
|
|
13165
|
+
borderRadius: 10,
|
|
13166
|
+
background: "#eff6ff",
|
|
13167
|
+
color: "#1d4ed8"
|
|
13168
|
+
},
|
|
13169
|
+
children: [
|
|
13170
|
+
tr ? "Hedef:" : "Target:",
|
|
13171
|
+
" ",
|
|
13172
|
+
pickTextForLocale(
|
|
13173
|
+
steps.find((s) => s.id === activeStepId)?.title || steps[0].title,
|
|
13174
|
+
uiLocale,
|
|
13175
|
+
activeStepId
|
|
13176
|
+
)
|
|
13177
|
+
]
|
|
13178
|
+
}
|
|
13179
|
+
)
|
|
13180
|
+
]
|
|
13181
|
+
}
|
|
13182
|
+
),
|
|
11720
13183
|
/* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 5 }, children: QUESTION_TYPES_CATALOG.map((qt) => /* @__PURE__ */ jsxs(
|
|
11721
13184
|
"button",
|
|
11722
13185
|
{
|
|
@@ -11724,8 +13187,14 @@ const SurveyStudioModal = ({
|
|
|
11724
13187
|
draggable: true,
|
|
11725
13188
|
onDragStart: (e) => {
|
|
11726
13189
|
dragRef.current = { kind: "new-type", qType: qt.type };
|
|
13190
|
+
e.dataTransfer.effectAllowed = "copyMove";
|
|
11727
13191
|
e.dataTransfer.setData("text/plain", qt.type);
|
|
11728
13192
|
},
|
|
13193
|
+
onDragEnd: () => {
|
|
13194
|
+
dragRef.current = null;
|
|
13195
|
+
setDropIndicator(null);
|
|
13196
|
+
clearHoverExpandTimer();
|
|
13197
|
+
},
|
|
11729
13198
|
onClick: () => addQuestionOfType(qt.type),
|
|
11730
13199
|
style: {
|
|
11731
13200
|
padding: "4px 8px",
|
|
@@ -11747,177 +13216,1254 @@ const SurveyStudioModal = ({
|
|
|
11747
13216
|
]
|
|
11748
13217
|
}
|
|
11749
13218
|
),
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
13219
|
+
draft.displayMode === "multi_step" ? (() => {
|
|
13220
|
+
const groupedMap = groupQuestionsByStep(questions, steps);
|
|
13221
|
+
const allCollapsed = steps.length > 0 && steps.every((s) => Boolean(collapsedStepIds[s.id]));
|
|
13222
|
+
const addNewStepCategory = () => {
|
|
13223
|
+
const nextIdx = steps.length + 1;
|
|
13224
|
+
const newStepId = `step_${uid("s")}`;
|
|
13225
|
+
const dynamicStepTitles = {};
|
|
13226
|
+
for (const loc of strapiLocales) {
|
|
13227
|
+
dynamicStepTitles[loc.code] = loc.code.toLowerCase().startsWith("tr") ? `${nextIdx}. Adım` : `Step ${nextIdx}`;
|
|
13228
|
+
}
|
|
13229
|
+
if (!dynamicStepTitles.tr) dynamicStepTitles.tr = `${nextIdx}. Adım`;
|
|
13230
|
+
if (!dynamicStepTitles.en) dynamicStepTitles.en = `Step ${nextIdx}`;
|
|
13231
|
+
setDraft(
|
|
13232
|
+
(prev) => normalizeMultiStepDraft({
|
|
13233
|
+
...prev,
|
|
13234
|
+
steps: [
|
|
13235
|
+
...prev.steps || [],
|
|
13236
|
+
{
|
|
13237
|
+
id: newStepId,
|
|
13238
|
+
title: dynamicStepTitles
|
|
13239
|
+
}
|
|
13240
|
+
]
|
|
13241
|
+
})
|
|
13242
|
+
);
|
|
13243
|
+
setActiveStepId(newStepId);
|
|
13244
|
+
setCollapsedStepIds((prev) => ({ ...prev, [newStepId]: false }));
|
|
13245
|
+
};
|
|
13246
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 9 }, children: [
|
|
13247
|
+
/* @__PURE__ */ jsxs(
|
|
13248
|
+
"div",
|
|
13249
|
+
{
|
|
13250
|
+
style: {
|
|
13251
|
+
display: "flex",
|
|
13252
|
+
alignItems: "center",
|
|
13253
|
+
justifyContent: "space-between",
|
|
13254
|
+
flexWrap: "wrap",
|
|
13255
|
+
gap: 6,
|
|
13256
|
+
padding: "6px 10px",
|
|
13257
|
+
borderRadius: 8,
|
|
13258
|
+
background: "#eef2ff",
|
|
13259
|
+
border: "1px solid #c7d2fe"
|
|
13260
|
+
},
|
|
13261
|
+
children: [
|
|
13262
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
13263
|
+
/* @__PURE__ */ jsx(MaterialIcon, { name: "layers", size: 15, color: "#3730a3" }),
|
|
13264
|
+
/* @__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)` })
|
|
13265
|
+
] }),
|
|
13266
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
|
|
13267
|
+
/* @__PURE__ */ jsx(
|
|
13268
|
+
"button",
|
|
13269
|
+
{
|
|
13270
|
+
type: "button",
|
|
13271
|
+
onClick: () => {
|
|
13272
|
+
const nextState = {};
|
|
13273
|
+
for (const s of steps) {
|
|
13274
|
+
nextState[s.id] = !allCollapsed;
|
|
13275
|
+
}
|
|
13276
|
+
setCollapsedStepIds(nextState);
|
|
13277
|
+
},
|
|
13278
|
+
style: {
|
|
13279
|
+
padding: "4px 8px",
|
|
13280
|
+
fontSize: 10.5,
|
|
13281
|
+
fontWeight: 700,
|
|
13282
|
+
borderRadius: 5,
|
|
13283
|
+
border: "1px solid #cbd5e1",
|
|
13284
|
+
background: "#ffffff",
|
|
13285
|
+
color: "#334155",
|
|
13286
|
+
cursor: "pointer"
|
|
13287
|
+
},
|
|
13288
|
+
children: allCollapsed ? tr ? "▾ Tümünü Aç" : "▾ Expand All" : tr ? "▸ Tümünü Daralt" : "▸ Collapse All"
|
|
13289
|
+
}
|
|
13290
|
+
),
|
|
13291
|
+
/* @__PURE__ */ jsx(
|
|
13292
|
+
"button",
|
|
13293
|
+
{
|
|
13294
|
+
type: "button",
|
|
13295
|
+
onClick: addNewStepCategory,
|
|
13296
|
+
style: {
|
|
13297
|
+
padding: "4px 10px",
|
|
13298
|
+
fontSize: 10.5,
|
|
13299
|
+
fontWeight: 700,
|
|
13300
|
+
borderRadius: 5,
|
|
13301
|
+
border: "none",
|
|
13302
|
+
background: "#2563eb",
|
|
13303
|
+
color: "#ffffff",
|
|
13304
|
+
cursor: "pointer"
|
|
13305
|
+
},
|
|
13306
|
+
children: tr ? "+ Yeni Adım Ekle" : "+ Add Step"
|
|
13307
|
+
}
|
|
13308
|
+
)
|
|
13309
|
+
] })
|
|
13310
|
+
]
|
|
11764
13311
|
}
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
const
|
|
11769
|
-
const
|
|
11770
|
-
const
|
|
13312
|
+
),
|
|
13313
|
+
steps.map((st, sIdx) => {
|
|
13314
|
+
const stTitleObj = normalizeLocalizedRecord(st.title, strapiLocales);
|
|
13315
|
+
const stepEntries = groupedMap.get(st.id) || [];
|
|
13316
|
+
const isCollapsed = Boolean(collapsedStepIds[st.id]);
|
|
13317
|
+
const isFocusedStep = activeStepId === st.id;
|
|
13318
|
+
const containsSelectedQ = stepEntries.some(
|
|
13319
|
+
(ent) => ent.globalIndex === selectedQuestionIdx
|
|
13320
|
+
);
|
|
13321
|
+
const stepIndicatorBefore = dropIndicator?.kind === "step" && dropIndicator.targetId === st.id && dropIndicator.position === "before";
|
|
13322
|
+
const stepIndicatorAfter = dropIndicator?.kind === "step" && dropIndicator.targetId === st.id && dropIndicator.position === "after";
|
|
13323
|
+
const isQuestionZoneHovered = dropIndicator?.kind === "step-zone" && dropIndicator.targetId === st.id;
|
|
13324
|
+
const handleDropIntoStepEnd = (item) => {
|
|
13325
|
+
const prevSelectedKey = activeQ?.key;
|
|
13326
|
+
if (item.kind === "question") {
|
|
13327
|
+
const nextDraft = moveQuestionInMultiStepDraft(
|
|
13328
|
+
draft,
|
|
13329
|
+
item.questionKey,
|
|
13330
|
+
{
|
|
13331
|
+
stepId: st.id,
|
|
13332
|
+
position: "end"
|
|
13333
|
+
}
|
|
13334
|
+
);
|
|
13335
|
+
setDraft(nextDraft);
|
|
13336
|
+
selectQuestionByKey(nextDraft.questions, item.questionKey || prevSelectedKey);
|
|
13337
|
+
setActiveStepId(st.id);
|
|
13338
|
+
setCollapsedStepIds((prev) => ({ ...prev, [st.id]: false }));
|
|
13339
|
+
} else if (item.kind === "new-type") {
|
|
13340
|
+
const newQ = buildQuestionFromType(
|
|
13341
|
+
item.qType,
|
|
13342
|
+
st.id,
|
|
13343
|
+
questions.map((q) => q.key)
|
|
13344
|
+
);
|
|
13345
|
+
const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ, {
|
|
13346
|
+
stepId: st.id,
|
|
13347
|
+
position: "end"
|
|
13348
|
+
});
|
|
13349
|
+
setDraft(nextDraft);
|
|
13350
|
+
setSelectedQuestionIdx(insertedIndex);
|
|
13351
|
+
setActiveStepId(st.id);
|
|
13352
|
+
setCollapsedStepIds((prev) => ({ ...prev, [st.id]: false }));
|
|
13353
|
+
}
|
|
13354
|
+
};
|
|
11771
13355
|
return /* @__PURE__ */ jsxs(
|
|
11772
13356
|
"div",
|
|
11773
13357
|
{
|
|
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
13358
|
style: {
|
|
11805
|
-
|
|
11806
|
-
borderRadius:
|
|
11807
|
-
border:
|
|
11808
|
-
background:
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
alignItems: "center",
|
|
11812
|
-
justifyContent: "space-between",
|
|
11813
|
-
gap: 8
|
|
13359
|
+
position: "relative",
|
|
13360
|
+
borderRadius: 10,
|
|
13361
|
+
border: isQuestionZoneHovered ? "2px dashed #2563eb" : isFocusedStep || containsSelectedQ ? "1.5px solid #60a5fa" : "1px solid #cbd5e1",
|
|
13362
|
+
background: "#ffffff",
|
|
13363
|
+
boxShadow: isFocusedStep || containsSelectedQ ? "0 2px 10px rgba(37, 99, 235, 0.08)" : "none",
|
|
13364
|
+
transition: "border-color 0.14s ease, box-shadow 0.14s ease"
|
|
11814
13365
|
},
|
|
11815
13366
|
children: [
|
|
13367
|
+
stepIndicatorBefore && /* @__PURE__ */ jsx(
|
|
13368
|
+
"div",
|
|
13369
|
+
{
|
|
13370
|
+
style: {
|
|
13371
|
+
position: "absolute",
|
|
13372
|
+
top: -5,
|
|
13373
|
+
left: 6,
|
|
13374
|
+
right: 6,
|
|
13375
|
+
height: 3,
|
|
13376
|
+
borderRadius: 3,
|
|
13377
|
+
background: "#2563eb",
|
|
13378
|
+
zIndex: 5
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
),
|
|
11816
13382
|
/* @__PURE__ */ jsxs(
|
|
11817
13383
|
"div",
|
|
11818
13384
|
{
|
|
13385
|
+
draggable: stepDragReadyId === st.id,
|
|
13386
|
+
onClick: () => setActiveStepId(st.id),
|
|
13387
|
+
onDragStart: (e) => {
|
|
13388
|
+
if (stepDragReadyId !== st.id) {
|
|
13389
|
+
e.preventDefault();
|
|
13390
|
+
return;
|
|
13391
|
+
}
|
|
13392
|
+
dragRef.current = {
|
|
13393
|
+
kind: "step",
|
|
13394
|
+
index: sIdx,
|
|
13395
|
+
stepId: st.id
|
|
13396
|
+
};
|
|
13397
|
+
e.dataTransfer.effectAllowed = "move";
|
|
13398
|
+
e.dataTransfer.setData("text/plain", st.id);
|
|
13399
|
+
},
|
|
13400
|
+
onDragEnd: () => {
|
|
13401
|
+
dragRef.current = null;
|
|
13402
|
+
setStepDragReadyId(null);
|
|
13403
|
+
setDropIndicator(null);
|
|
13404
|
+
clearHoverExpandTimer();
|
|
13405
|
+
},
|
|
13406
|
+
onDragOver: (e) => {
|
|
13407
|
+
const item = dragRef.current;
|
|
13408
|
+
if (!item) return;
|
|
13409
|
+
if (item.kind === "step") {
|
|
13410
|
+
if (item.stepId === st.id) return;
|
|
13411
|
+
e.preventDefault();
|
|
13412
|
+
e.stopPropagation();
|
|
13413
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
13414
|
+
const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
|
|
13415
|
+
setDropIndicator({ kind: "step", targetId: st.id, position: pos });
|
|
13416
|
+
} else if (item.kind === "question" || item.kind === "new-type") {
|
|
13417
|
+
e.preventDefault();
|
|
13418
|
+
e.stopPropagation();
|
|
13419
|
+
setDropIndicator({ kind: "step-zone", targetId: st.id });
|
|
13420
|
+
if (isCollapsed && hoverExpandTimerRef.current?.stepId !== st.id) {
|
|
13421
|
+
clearHoverExpandTimer();
|
|
13422
|
+
hoverExpandTimerRef.current = {
|
|
13423
|
+
stepId: st.id,
|
|
13424
|
+
timer: setTimeout(() => {
|
|
13425
|
+
setCollapsedStepIds((prev) => ({
|
|
13426
|
+
...prev,
|
|
13427
|
+
[st.id]: false
|
|
13428
|
+
}));
|
|
13429
|
+
hoverExpandTimerRef.current = null;
|
|
13430
|
+
}, 380)
|
|
13431
|
+
};
|
|
13432
|
+
}
|
|
13433
|
+
}
|
|
13434
|
+
},
|
|
13435
|
+
onDragLeave: () => {
|
|
13436
|
+
clearHoverExpandTimer();
|
|
13437
|
+
},
|
|
13438
|
+
onDrop: (e) => {
|
|
13439
|
+
e.preventDefault();
|
|
13440
|
+
e.stopPropagation();
|
|
13441
|
+
clearHoverExpandTimer();
|
|
13442
|
+
const item = dragRef.current;
|
|
13443
|
+
const curInd = dropIndicator;
|
|
13444
|
+
dragRef.current = null;
|
|
13445
|
+
setStepDragReadyId(null);
|
|
13446
|
+
setDropIndicator(null);
|
|
13447
|
+
if (!item) return;
|
|
13448
|
+
if (item.kind === "step" && item.stepId !== st.id) {
|
|
13449
|
+
const prevSelectedKey = activeQ?.key;
|
|
13450
|
+
const pos = curInd?.kind === "step" && curInd.targetId === st.id ? curInd.position : "before";
|
|
13451
|
+
const nextDraft = reorderStepsInDraft(
|
|
13452
|
+
draft,
|
|
13453
|
+
item.stepId,
|
|
13454
|
+
st.id,
|
|
13455
|
+
pos
|
|
13456
|
+
);
|
|
13457
|
+
setDraft(nextDraft);
|
|
13458
|
+
selectQuestionByKey(nextDraft.questions, prevSelectedKey);
|
|
13459
|
+
return;
|
|
13460
|
+
}
|
|
13461
|
+
if (item.kind === "question" || item.kind === "new-type") {
|
|
13462
|
+
handleDropIntoStepEnd(item);
|
|
13463
|
+
}
|
|
13464
|
+
},
|
|
13465
|
+
style: {
|
|
13466
|
+
padding: "8px 10px",
|
|
13467
|
+
borderTopLeftRadius: 9,
|
|
13468
|
+
borderTopRightRadius: 9,
|
|
13469
|
+
borderBottomLeftRadius: isCollapsed ? 9 : 0,
|
|
13470
|
+
borderBottomRightRadius: isCollapsed ? 9 : 0,
|
|
13471
|
+
borderBottom: isCollapsed ? "none" : "1px solid #e2e8f0",
|
|
13472
|
+
background: isQuestionZoneHovered ? "#dbeafe" : isFocusedStep || containsSelectedQ ? "#eff6ff" : "#f8fafc",
|
|
13473
|
+
display: "flex",
|
|
13474
|
+
flexDirection: "column",
|
|
13475
|
+
gap: 6
|
|
13476
|
+
},
|
|
13477
|
+
children: [
|
|
13478
|
+
/* @__PURE__ */ jsxs(
|
|
13479
|
+
"div",
|
|
13480
|
+
{
|
|
13481
|
+
style: {
|
|
13482
|
+
display: "flex",
|
|
13483
|
+
alignItems: "center",
|
|
13484
|
+
justifyContent: "space-between",
|
|
13485
|
+
gap: 6
|
|
13486
|
+
},
|
|
13487
|
+
children: [
|
|
13488
|
+
/* @__PURE__ */ jsxs(
|
|
13489
|
+
"div",
|
|
13490
|
+
{
|
|
13491
|
+
style: {
|
|
13492
|
+
display: "flex",
|
|
13493
|
+
alignItems: "center",
|
|
13494
|
+
gap: 6,
|
|
13495
|
+
minWidth: 0
|
|
13496
|
+
},
|
|
13497
|
+
children: [
|
|
13498
|
+
/* @__PURE__ */ jsx(
|
|
13499
|
+
"span",
|
|
13500
|
+
{
|
|
13501
|
+
onMouseDown: () => setStepDragReadyId(st.id),
|
|
13502
|
+
onMouseUp: () => setStepDragReadyId(null),
|
|
13503
|
+
title: tr ? "Adımı sürükleyerek sıralayın" : "Drag to reorder step category",
|
|
13504
|
+
style: {
|
|
13505
|
+
display: "inline-flex",
|
|
13506
|
+
alignItems: "center",
|
|
13507
|
+
padding: "2px 3px",
|
|
13508
|
+
borderRadius: 4,
|
|
13509
|
+
cursor: "grab",
|
|
13510
|
+
background: "#e2e8f0"
|
|
13511
|
+
},
|
|
13512
|
+
children: /* @__PURE__ */ jsx(
|
|
13513
|
+
MaterialIcon,
|
|
13514
|
+
{
|
|
13515
|
+
name: "drag_indicator",
|
|
13516
|
+
size: 15,
|
|
13517
|
+
color: "#334155"
|
|
13518
|
+
}
|
|
13519
|
+
)
|
|
13520
|
+
}
|
|
13521
|
+
),
|
|
13522
|
+
/* @__PURE__ */ jsxs(
|
|
13523
|
+
"button",
|
|
13524
|
+
{
|
|
13525
|
+
type: "button",
|
|
13526
|
+
onClick: (e) => {
|
|
13527
|
+
e.stopPropagation();
|
|
13528
|
+
setCollapsedStepIds((prev) => ({
|
|
13529
|
+
...prev,
|
|
13530
|
+
[st.id]: !prev[st.id]
|
|
13531
|
+
}));
|
|
13532
|
+
setActiveStepId(st.id);
|
|
13533
|
+
},
|
|
13534
|
+
style: {
|
|
13535
|
+
border: "none",
|
|
13536
|
+
background: "transparent",
|
|
13537
|
+
padding: "2px 4px",
|
|
13538
|
+
cursor: "pointer",
|
|
13539
|
+
fontSize: 12,
|
|
13540
|
+
fontWeight: 800,
|
|
13541
|
+
color: "#1e3a8a",
|
|
13542
|
+
display: "inline-flex",
|
|
13543
|
+
alignItems: "center",
|
|
13544
|
+
gap: 5
|
|
13545
|
+
},
|
|
13546
|
+
children: [
|
|
13547
|
+
/* @__PURE__ */ jsx("span", { children: isCollapsed ? "▸" : "▾" }),
|
|
13548
|
+
/* @__PURE__ */ jsx(
|
|
13549
|
+
"span",
|
|
13550
|
+
{
|
|
13551
|
+
style: {
|
|
13552
|
+
padding: "2px 7px",
|
|
13553
|
+
borderRadius: 6,
|
|
13554
|
+
background: "#1e3a8a",
|
|
13555
|
+
color: "#ffffff",
|
|
13556
|
+
fontSize: 10.5,
|
|
13557
|
+
fontWeight: 800
|
|
13558
|
+
},
|
|
13559
|
+
children: tr ? `Adım ${sIdx + 1}` : `Step ${sIdx + 1}`
|
|
13560
|
+
}
|
|
13561
|
+
),
|
|
13562
|
+
/* @__PURE__ */ jsx(
|
|
13563
|
+
"span",
|
|
13564
|
+
{
|
|
13565
|
+
style: {
|
|
13566
|
+
fontSize: 12,
|
|
13567
|
+
fontWeight: 700,
|
|
13568
|
+
color: "#0f172a"
|
|
13569
|
+
},
|
|
13570
|
+
children: pickTextForLocale(st.title, uiLocale, st.id)
|
|
13571
|
+
}
|
|
13572
|
+
)
|
|
13573
|
+
]
|
|
13574
|
+
}
|
|
13575
|
+
)
|
|
13576
|
+
]
|
|
13577
|
+
}
|
|
13578
|
+
),
|
|
13579
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
13580
|
+
/* @__PURE__ */ jsxs(
|
|
13581
|
+
"span",
|
|
13582
|
+
{
|
|
13583
|
+
style: {
|
|
13584
|
+
fontSize: 10.5,
|
|
13585
|
+
fontWeight: 700,
|
|
13586
|
+
padding: "2px 8px",
|
|
13587
|
+
borderRadius: 10,
|
|
13588
|
+
background: stepEntries.length > 0 ? "#dbeafe" : "#f1f5f9",
|
|
13589
|
+
color: stepEntries.length > 0 ? "#1e40af" : "#64748b"
|
|
13590
|
+
},
|
|
13591
|
+
children: [
|
|
13592
|
+
stepEntries.length,
|
|
13593
|
+
" ",
|
|
13594
|
+
tr ? "soru" : "Qs"
|
|
13595
|
+
]
|
|
13596
|
+
}
|
|
13597
|
+
),
|
|
13598
|
+
/* @__PURE__ */ jsx(
|
|
13599
|
+
"button",
|
|
13600
|
+
{
|
|
13601
|
+
type: "button",
|
|
13602
|
+
disabled: sIdx === 0,
|
|
13603
|
+
onClick: (e) => {
|
|
13604
|
+
e.stopPropagation();
|
|
13605
|
+
const prevKey = activeQ?.key;
|
|
13606
|
+
const nextDraft = shiftStepByOffset(draft, st.id, -1);
|
|
13607
|
+
setDraft(nextDraft);
|
|
13608
|
+
selectQuestionByKey(nextDraft.questions, prevKey);
|
|
13609
|
+
},
|
|
13610
|
+
title: tr ? "Kategoriyi yukarı taşı" : "Move step up",
|
|
13611
|
+
style: {
|
|
13612
|
+
border: "1px solid #cbd5e1",
|
|
13613
|
+
background: "#ffffff",
|
|
13614
|
+
color: sIdx === 0 ? "#cbd5e1" : "#334155",
|
|
13615
|
+
borderRadius: 4,
|
|
13616
|
+
padding: "1px 5px",
|
|
13617
|
+
fontSize: 11,
|
|
13618
|
+
cursor: sIdx === 0 ? "default" : "pointer"
|
|
13619
|
+
},
|
|
13620
|
+
children: "↑"
|
|
13621
|
+
}
|
|
13622
|
+
),
|
|
13623
|
+
/* @__PURE__ */ jsx(
|
|
13624
|
+
"button",
|
|
13625
|
+
{
|
|
13626
|
+
type: "button",
|
|
13627
|
+
disabled: sIdx === steps.length - 1,
|
|
13628
|
+
onClick: (e) => {
|
|
13629
|
+
e.stopPropagation();
|
|
13630
|
+
const prevKey = activeQ?.key;
|
|
13631
|
+
const nextDraft = shiftStepByOffset(draft, st.id, 1);
|
|
13632
|
+
setDraft(nextDraft);
|
|
13633
|
+
selectQuestionByKey(nextDraft.questions, prevKey);
|
|
13634
|
+
},
|
|
13635
|
+
title: tr ? "Kategoriyi aşağı taşı" : "Move step down",
|
|
13636
|
+
style: {
|
|
13637
|
+
border: "1px solid #cbd5e1",
|
|
13638
|
+
background: "#ffffff",
|
|
13639
|
+
color: sIdx === steps.length - 1 ? "#cbd5e1" : "#334155",
|
|
13640
|
+
borderRadius: 4,
|
|
13641
|
+
padding: "1px 5px",
|
|
13642
|
+
fontSize: 11,
|
|
13643
|
+
cursor: sIdx === steps.length - 1 ? "default" : "pointer"
|
|
13644
|
+
},
|
|
13645
|
+
children: "↓"
|
|
13646
|
+
}
|
|
13647
|
+
),
|
|
13648
|
+
/* @__PURE__ */ jsx(
|
|
13649
|
+
"button",
|
|
13650
|
+
{
|
|
13651
|
+
type: "button",
|
|
13652
|
+
disabled: steps.length <= 1,
|
|
13653
|
+
onClick: (e) => {
|
|
13654
|
+
e.stopPropagation();
|
|
13655
|
+
const prevKey = activeQ?.key;
|
|
13656
|
+
const res = deleteStepWithQuestionReassignment(
|
|
13657
|
+
draft,
|
|
13658
|
+
st.id
|
|
13659
|
+
);
|
|
13660
|
+
setDraft(res.draft);
|
|
13661
|
+
setActiveStepId(res.fallbackStepId);
|
|
13662
|
+
setCollapsedStepIds((prev) => ({
|
|
13663
|
+
...prev,
|
|
13664
|
+
[res.fallbackStepId]: false
|
|
13665
|
+
}));
|
|
13666
|
+
selectQuestionByKey(res.draft.questions, prevKey);
|
|
13667
|
+
if (res.movedQuestionCount > 0) {
|
|
13668
|
+
setStatusMsg(
|
|
13669
|
+
tr ? `${res.movedQuestionCount} soru komşu adıma aktarıldı.` : `${res.movedQuestionCount} question(s) moved to adjacent step.`
|
|
13670
|
+
);
|
|
13671
|
+
}
|
|
13672
|
+
},
|
|
13673
|
+
title: tr ? "Adımı sil (içindeki sorular komşu adıma aktarılır)" : "Delete step (reassigns questions safely)",
|
|
13674
|
+
style: {
|
|
13675
|
+
border: "none",
|
|
13676
|
+
background: "transparent",
|
|
13677
|
+
color: steps.length <= 1 ? "#cbd5e1" : "#dc2626",
|
|
13678
|
+
cursor: steps.length <= 1 ? "default" : "pointer",
|
|
13679
|
+
fontSize: 14,
|
|
13680
|
+
fontWeight: 700,
|
|
13681
|
+
padding: "0 4px"
|
|
13682
|
+
},
|
|
13683
|
+
children: "×"
|
|
13684
|
+
}
|
|
13685
|
+
)
|
|
13686
|
+
] })
|
|
13687
|
+
]
|
|
13688
|
+
}
|
|
13689
|
+
),
|
|
13690
|
+
!isCollapsed && (() => {
|
|
13691
|
+
const stDescObj = normalizeLocalizedRecord(
|
|
13692
|
+
st.description,
|
|
13693
|
+
strapiLocales
|
|
13694
|
+
);
|
|
13695
|
+
const hasFilledDesc = Object.values(stDescObj).some(
|
|
13696
|
+
(val) => String(val || "").trim().length > 0
|
|
13697
|
+
);
|
|
13698
|
+
const showStepDesc = openStepDescIds[st.id] !== void 0 ? openStepDescIds[st.id] : hasFilledDesc;
|
|
13699
|
+
const stepLocaleCols = `repeat(${Math.min(
|
|
13700
|
+
Math.max(strapiLocales.length, 1),
|
|
13701
|
+
2
|
|
13702
|
+
)}, minmax(0, 1fr))`;
|
|
13703
|
+
return /* @__PURE__ */ jsxs(
|
|
13704
|
+
"div",
|
|
13705
|
+
{
|
|
13706
|
+
onMouseDown: (e) => {
|
|
13707
|
+
e.stopPropagation();
|
|
13708
|
+
setStepDragReadyId(null);
|
|
13709
|
+
},
|
|
13710
|
+
onClick: (e) => e.stopPropagation(),
|
|
13711
|
+
style: {
|
|
13712
|
+
display: "flex",
|
|
13713
|
+
flexDirection: "column",
|
|
13714
|
+
gap: 6
|
|
13715
|
+
},
|
|
13716
|
+
children: [
|
|
13717
|
+
/* @__PURE__ */ jsx(
|
|
13718
|
+
"div",
|
|
13719
|
+
{
|
|
13720
|
+
style: {
|
|
13721
|
+
display: "grid",
|
|
13722
|
+
gridTemplateColumns: stepLocaleCols,
|
|
13723
|
+
gap: 5
|
|
13724
|
+
},
|
|
13725
|
+
children: strapiLocales.map((loc) => /* @__PURE__ */ jsxs(
|
|
13726
|
+
"div",
|
|
13727
|
+
{
|
|
13728
|
+
style: {
|
|
13729
|
+
display: "flex",
|
|
13730
|
+
alignItems: "stretch",
|
|
13731
|
+
borderRadius: 6,
|
|
13732
|
+
border: "1px solid #cbd5e1",
|
|
13733
|
+
background: "#ffffff",
|
|
13734
|
+
overflow: "hidden"
|
|
13735
|
+
},
|
|
13736
|
+
children: [
|
|
13737
|
+
/* @__PURE__ */ jsx(
|
|
13738
|
+
"span",
|
|
13739
|
+
{
|
|
13740
|
+
title: loc.name || loc.code,
|
|
13741
|
+
style: {
|
|
13742
|
+
padding: "0 7px",
|
|
13743
|
+
background: loc.isDefault ? "#dbeafe" : "#f1f5f9",
|
|
13744
|
+
color: loc.isDefault ? "#1e40af" : "#334155",
|
|
13745
|
+
fontSize: 10,
|
|
13746
|
+
fontWeight: 800,
|
|
13747
|
+
borderRight: "1px solid #cbd5e1",
|
|
13748
|
+
display: "inline-flex",
|
|
13749
|
+
alignItems: "center",
|
|
13750
|
+
flexShrink: 0
|
|
13751
|
+
},
|
|
13752
|
+
children: loc.code.toUpperCase()
|
|
13753
|
+
}
|
|
13754
|
+
),
|
|
13755
|
+
/* @__PURE__ */ jsx(
|
|
13756
|
+
"input",
|
|
13757
|
+
{
|
|
13758
|
+
type: "text",
|
|
13759
|
+
value: stTitleObj[loc.code] || "",
|
|
13760
|
+
onChange: (e) => {
|
|
13761
|
+
const nextSteps = steps.map(
|
|
13762
|
+
(item, i) => i === sIdx ? {
|
|
13763
|
+
...item,
|
|
13764
|
+
title: {
|
|
13765
|
+
...stTitleObj,
|
|
13766
|
+
[loc.code]: e.target.value
|
|
13767
|
+
}
|
|
13768
|
+
} : item
|
|
13769
|
+
);
|
|
13770
|
+
setDraft((prev) => ({
|
|
13771
|
+
...prev,
|
|
13772
|
+
steps: nextSteps
|
|
13773
|
+
}));
|
|
13774
|
+
},
|
|
13775
|
+
placeholder: tr ? "Kategori Başlığı" : "Step Title",
|
|
13776
|
+
style: {
|
|
13777
|
+
flex: 1,
|
|
13778
|
+
minWidth: 0,
|
|
13779
|
+
border: "none",
|
|
13780
|
+
outline: "none",
|
|
13781
|
+
padding: "4px 7px",
|
|
13782
|
+
fontSize: 11,
|
|
13783
|
+
color: "#0f172a",
|
|
13784
|
+
background: "transparent"
|
|
13785
|
+
}
|
|
13786
|
+
}
|
|
13787
|
+
)
|
|
13788
|
+
]
|
|
13789
|
+
},
|
|
13790
|
+
`st-${st.id}-${loc.code}`
|
|
13791
|
+
))
|
|
13792
|
+
}
|
|
13793
|
+
),
|
|
13794
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsxs(
|
|
13795
|
+
"button",
|
|
13796
|
+
{
|
|
13797
|
+
type: "button",
|
|
13798
|
+
onClick: () => setOpenStepDescIds((prev) => ({
|
|
13799
|
+
...prev,
|
|
13800
|
+
[st.id]: !showStepDesc
|
|
13801
|
+
})),
|
|
13802
|
+
style: {
|
|
13803
|
+
border: "none",
|
|
13804
|
+
background: "transparent",
|
|
13805
|
+
padding: "1px 2px",
|
|
13806
|
+
fontSize: 10.5,
|
|
13807
|
+
fontWeight: 700,
|
|
13808
|
+
color: showStepDesc ? "#1d4ed8" : "#64748b",
|
|
13809
|
+
cursor: "pointer",
|
|
13810
|
+
display: "inline-flex",
|
|
13811
|
+
alignItems: "center",
|
|
13812
|
+
gap: 4
|
|
13813
|
+
},
|
|
13814
|
+
children: [
|
|
13815
|
+
/* @__PURE__ */ jsx("span", { children: showStepDesc ? "▾" : "+" }),
|
|
13816
|
+
/* @__PURE__ */ jsx("span", { children: tr ? "Kategori Alt Açıklaması (Opsiyonel)" : "Step Subtitle / Description (Optional)" })
|
|
13817
|
+
]
|
|
13818
|
+
}
|
|
13819
|
+
) }),
|
|
13820
|
+
showStepDesc && /* @__PURE__ */ jsx(
|
|
13821
|
+
"div",
|
|
13822
|
+
{
|
|
13823
|
+
style: {
|
|
13824
|
+
display: "grid",
|
|
13825
|
+
gridTemplateColumns: stepLocaleCols,
|
|
13826
|
+
gap: 5
|
|
13827
|
+
},
|
|
13828
|
+
children: strapiLocales.map((loc) => /* @__PURE__ */ jsxs(
|
|
13829
|
+
"div",
|
|
13830
|
+
{
|
|
13831
|
+
style: {
|
|
13832
|
+
display: "flex",
|
|
13833
|
+
alignItems: "stretch",
|
|
13834
|
+
borderRadius: 6,
|
|
13835
|
+
border: "1px dashed #cbd5e1",
|
|
13836
|
+
background: "#f8fafc",
|
|
13837
|
+
overflow: "hidden"
|
|
13838
|
+
},
|
|
13839
|
+
children: [
|
|
13840
|
+
/* @__PURE__ */ jsx(
|
|
13841
|
+
"span",
|
|
13842
|
+
{
|
|
13843
|
+
style: {
|
|
13844
|
+
padding: "0 6px",
|
|
13845
|
+
background: "#e2e8f0",
|
|
13846
|
+
color: "#475569",
|
|
13847
|
+
fontSize: 9.5,
|
|
13848
|
+
fontWeight: 800,
|
|
13849
|
+
borderRight: "1px solid #cbd5e1",
|
|
13850
|
+
display: "inline-flex",
|
|
13851
|
+
alignItems: "center",
|
|
13852
|
+
flexShrink: 0
|
|
13853
|
+
},
|
|
13854
|
+
children: loc.code.toUpperCase()
|
|
13855
|
+
}
|
|
13856
|
+
),
|
|
13857
|
+
/* @__PURE__ */ jsx(
|
|
13858
|
+
"input",
|
|
13859
|
+
{
|
|
13860
|
+
type: "text",
|
|
13861
|
+
value: stDescObj[loc.code] || "",
|
|
13862
|
+
onChange: (e) => {
|
|
13863
|
+
const nextSteps = steps.map(
|
|
13864
|
+
(item, i) => i === sIdx ? {
|
|
13865
|
+
...item,
|
|
13866
|
+
description: {
|
|
13867
|
+
...stDescObj,
|
|
13868
|
+
[loc.code]: e.target.value
|
|
13869
|
+
}
|
|
13870
|
+
} : item
|
|
13871
|
+
);
|
|
13872
|
+
setDraft((prev) => ({
|
|
13873
|
+
...prev,
|
|
13874
|
+
steps: nextSteps
|
|
13875
|
+
}));
|
|
13876
|
+
},
|
|
13877
|
+
placeholder: tr ? "Opsiyonel alt açıklama..." : "Optional step description...",
|
|
13878
|
+
style: {
|
|
13879
|
+
flex: 1,
|
|
13880
|
+
minWidth: 0,
|
|
13881
|
+
border: "none",
|
|
13882
|
+
outline: "none",
|
|
13883
|
+
padding: "4px 7px",
|
|
13884
|
+
fontSize: 10.5,
|
|
13885
|
+
color: "#334155",
|
|
13886
|
+
background: "transparent"
|
|
13887
|
+
}
|
|
13888
|
+
}
|
|
13889
|
+
)
|
|
13890
|
+
]
|
|
13891
|
+
},
|
|
13892
|
+
`stdesc-${st.id}-${loc.code}`
|
|
13893
|
+
))
|
|
13894
|
+
}
|
|
13895
|
+
)
|
|
13896
|
+
]
|
|
13897
|
+
}
|
|
13898
|
+
);
|
|
13899
|
+
})()
|
|
13900
|
+
]
|
|
13901
|
+
}
|
|
13902
|
+
),
|
|
13903
|
+
!isCollapsed && /* @__PURE__ */ jsxs(
|
|
13904
|
+
"div",
|
|
13905
|
+
{
|
|
13906
|
+
onDragOver: (e) => {
|
|
13907
|
+
const item = dragRef.current;
|
|
13908
|
+
if (item?.kind === "question" || item?.kind === "new-type") {
|
|
13909
|
+
e.preventDefault();
|
|
13910
|
+
setDropIndicator({ kind: "step-zone", targetId: st.id });
|
|
13911
|
+
}
|
|
13912
|
+
},
|
|
13913
|
+
onDrop: (e) => {
|
|
13914
|
+
const item = dragRef.current;
|
|
13915
|
+
if (item?.kind === "question" || item?.kind === "new-type") {
|
|
13916
|
+
e.preventDefault();
|
|
13917
|
+
e.stopPropagation();
|
|
13918
|
+
dragRef.current = null;
|
|
13919
|
+
setDropIndicator(null);
|
|
13920
|
+
handleDropIntoStepEnd(item);
|
|
13921
|
+
}
|
|
13922
|
+
},
|
|
11819
13923
|
style: {
|
|
13924
|
+
padding: 9,
|
|
11820
13925
|
display: "flex",
|
|
11821
|
-
|
|
11822
|
-
gap:
|
|
11823
|
-
|
|
13926
|
+
flexDirection: "column",
|
|
13927
|
+
gap: 6,
|
|
13928
|
+
background: isQuestionZoneHovered ? "#f0f9ff" : "#ffffff",
|
|
13929
|
+
borderBottomLeftRadius: 9,
|
|
13930
|
+
borderBottomRightRadius: 9
|
|
11824
13931
|
},
|
|
11825
13932
|
children: [
|
|
11826
|
-
/* @__PURE__ */ jsx(
|
|
11827
|
-
|
|
13933
|
+
stepEntries.length === 0 ? /* @__PURE__ */ jsx(
|
|
13934
|
+
"div",
|
|
11828
13935
|
{
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
13936
|
+
style: {
|
|
13937
|
+
padding: "14px 10px",
|
|
13938
|
+
borderRadius: 7,
|
|
13939
|
+
border: "1.5 dashed #cbd5e1",
|
|
13940
|
+
borderStyle: "dashed",
|
|
13941
|
+
background: "#f8fafc",
|
|
13942
|
+
textAlign: "center",
|
|
13943
|
+
fontSize: 11,
|
|
13944
|
+
color: "#64748b"
|
|
13945
|
+
},
|
|
13946
|
+
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."
|
|
11832
13947
|
}
|
|
11833
|
-
),
|
|
11834
|
-
|
|
11835
|
-
|
|
13948
|
+
) : stepEntries.map(({ question: q, globalIndex: qIdx, localIndex }) => {
|
|
13949
|
+
const selected = qIdx === selectedQuestionIdx;
|
|
13950
|
+
const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
|
|
13951
|
+
const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
|
|
13952
|
+
const qIndBefore = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "before";
|
|
13953
|
+
const qIndAfter = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "after";
|
|
13954
|
+
return /* @__PURE__ */ jsxs(
|
|
11836
13955
|
"div",
|
|
11837
13956
|
{
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
13957
|
+
draggable: true,
|
|
13958
|
+
onDragStart: (e) => {
|
|
13959
|
+
e.stopPropagation();
|
|
13960
|
+
dragRef.current = {
|
|
13961
|
+
kind: "question",
|
|
13962
|
+
index: qIdx,
|
|
13963
|
+
questionKey: q.key,
|
|
13964
|
+
fromStepId: st.id
|
|
13965
|
+
};
|
|
13966
|
+
e.dataTransfer.effectAllowed = "move";
|
|
13967
|
+
e.dataTransfer.setData("text/plain", q.key);
|
|
13968
|
+
},
|
|
13969
|
+
onDragEnd: () => {
|
|
13970
|
+
dragRef.current = null;
|
|
13971
|
+
setDropIndicator(null);
|
|
13972
|
+
clearHoverExpandTimer();
|
|
13973
|
+
},
|
|
13974
|
+
onDragOver: (e) => {
|
|
13975
|
+
const item = dragRef.current;
|
|
13976
|
+
if (item?.kind === "question" || item?.kind === "new-type") {
|
|
13977
|
+
e.preventDefault();
|
|
13978
|
+
e.stopPropagation();
|
|
13979
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
13980
|
+
const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
|
|
13981
|
+
setDropIndicator({
|
|
13982
|
+
kind: "question",
|
|
13983
|
+
targetId: q.key,
|
|
13984
|
+
position: pos
|
|
13985
|
+
});
|
|
13986
|
+
}
|
|
13987
|
+
},
|
|
13988
|
+
onDrop: (e) => {
|
|
13989
|
+
e.preventDefault();
|
|
13990
|
+
e.stopPropagation();
|
|
13991
|
+
const item = dragRef.current;
|
|
13992
|
+
const curInd = dropIndicator;
|
|
13993
|
+
dragRef.current = null;
|
|
13994
|
+
setDropIndicator(null);
|
|
13995
|
+
if (!item) return;
|
|
13996
|
+
const pos = curInd?.kind === "question" && curInd.targetId === q.key ? curInd.position : "before";
|
|
13997
|
+
if (item.kind === "new-type") {
|
|
13998
|
+
const newQ = buildQuestionFromType(
|
|
13999
|
+
item.qType,
|
|
14000
|
+
st.id,
|
|
14001
|
+
questions.map((x) => x.key)
|
|
14002
|
+
);
|
|
14003
|
+
const { draft: nextDraft, insertedIndex } = insertQuestionInMultiStepDraft(draft, newQ, {
|
|
14004
|
+
stepId: st.id,
|
|
14005
|
+
targetQuestionKey: q.key,
|
|
14006
|
+
position: pos
|
|
14007
|
+
});
|
|
14008
|
+
setDraft(nextDraft);
|
|
14009
|
+
setSelectedQuestionIdx(insertedIndex);
|
|
14010
|
+
setActiveStepId(st.id);
|
|
14011
|
+
return;
|
|
14012
|
+
}
|
|
14013
|
+
if (item.kind === "question") {
|
|
14014
|
+
const nextDraft = moveQuestionInMultiStepDraft(
|
|
14015
|
+
draft,
|
|
14016
|
+
item.questionKey,
|
|
14017
|
+
{
|
|
14018
|
+
stepId: st.id,
|
|
14019
|
+
targetQuestionKey: q.key,
|
|
14020
|
+
position: pos
|
|
14021
|
+
}
|
|
14022
|
+
);
|
|
14023
|
+
setDraft(nextDraft);
|
|
14024
|
+
selectQuestionByKey(
|
|
14025
|
+
nextDraft.questions,
|
|
14026
|
+
item.questionKey
|
|
14027
|
+
);
|
|
14028
|
+
setActiveStepId(st.id);
|
|
14029
|
+
}
|
|
14030
|
+
},
|
|
14031
|
+
onClick: (e) => {
|
|
14032
|
+
e.stopPropagation();
|
|
14033
|
+
setSelectedQuestionIdx(qIdx);
|
|
14034
|
+
setActiveStepId(st.id);
|
|
11845
14035
|
},
|
|
11846
|
-
children: [
|
|
11847
|
-
qIdx + 1,
|
|
11848
|
-
". ",
|
|
11849
|
-
qTitle,
|
|
11850
|
-
" ",
|
|
11851
|
-
q.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626" }, children: "*" })
|
|
11852
|
-
]
|
|
11853
|
-
}
|
|
11854
|
-
),
|
|
11855
|
-
/* @__PURE__ */ jsxs(
|
|
11856
|
-
"div",
|
|
11857
|
-
{
|
|
11858
14036
|
style: {
|
|
14037
|
+
position: "relative",
|
|
14038
|
+
padding: "8px 10px",
|
|
14039
|
+
borderRadius: 7,
|
|
14040
|
+
border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
14041
|
+
background: selected ? "#eff6ff" : "#f8fafc",
|
|
14042
|
+
cursor: "grab",
|
|
11859
14043
|
display: "flex",
|
|
11860
14044
|
alignItems: "center",
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
color: "#64748b",
|
|
11864
|
-
marginTop: 2
|
|
14045
|
+
justifyContent: "space-between",
|
|
14046
|
+
gap: 8
|
|
11865
14047
|
},
|
|
11866
14048
|
children: [
|
|
11867
|
-
/* @__PURE__ */ jsx(
|
|
11868
|
-
|
|
11869
|
-
"• ",
|
|
11870
|
-
q.type
|
|
11871
|
-
] }),
|
|
11872
|
-
draft.displayMode === "multi_step" && q.stepId && /* @__PURE__ */ jsxs("span", { style: { color: "#1d4ed8", fontWeight: 600 }, children: [
|
|
11873
|
-
"• ",
|
|
11874
|
-
q.stepId
|
|
11875
|
-
] }),
|
|
11876
|
-
hasCond && /* @__PURE__ */ jsx(
|
|
11877
|
-
"span",
|
|
14049
|
+
qIndBefore && /* @__PURE__ */ jsx(
|
|
14050
|
+
"div",
|
|
11878
14051
|
{
|
|
11879
14052
|
style: {
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
14053
|
+
position: "absolute",
|
|
14054
|
+
top: -4,
|
|
14055
|
+
left: 4,
|
|
14056
|
+
right: 4,
|
|
14057
|
+
height: 2.5,
|
|
14058
|
+
borderRadius: 2,
|
|
14059
|
+
background: "#2563eb",
|
|
14060
|
+
zIndex: 4
|
|
14061
|
+
}
|
|
14062
|
+
}
|
|
14063
|
+
),
|
|
14064
|
+
/* @__PURE__ */ jsxs(
|
|
14065
|
+
"div",
|
|
14066
|
+
{
|
|
14067
|
+
style: {
|
|
14068
|
+
display: "flex",
|
|
14069
|
+
alignItems: "center",
|
|
14070
|
+
gap: 7,
|
|
14071
|
+
overflow: "hidden"
|
|
14072
|
+
},
|
|
14073
|
+
children: [
|
|
14074
|
+
/* @__PURE__ */ jsx(
|
|
14075
|
+
MaterialIcon,
|
|
14076
|
+
{
|
|
14077
|
+
name: "drag_indicator",
|
|
14078
|
+
size: 15,
|
|
14079
|
+
color: selected ? "#2563eb" : "#94a3b8"
|
|
14080
|
+
}
|
|
14081
|
+
),
|
|
14082
|
+
/* @__PURE__ */ jsxs("div", { style: { overflow: "hidden" }, children: [
|
|
14083
|
+
/* @__PURE__ */ jsxs(
|
|
14084
|
+
"div",
|
|
14085
|
+
{
|
|
14086
|
+
style: {
|
|
14087
|
+
fontSize: 12,
|
|
14088
|
+
fontWeight: 700,
|
|
14089
|
+
color: "#0f172a",
|
|
14090
|
+
whiteSpace: "nowrap",
|
|
14091
|
+
overflow: "hidden",
|
|
14092
|
+
textOverflow: "ellipsis"
|
|
14093
|
+
},
|
|
14094
|
+
children: [
|
|
14095
|
+
/* @__PURE__ */ jsxs(
|
|
14096
|
+
"span",
|
|
14097
|
+
{
|
|
14098
|
+
style: {
|
|
14099
|
+
color: "#2563eb",
|
|
14100
|
+
marginRight: 4,
|
|
14101
|
+
fontSize: 11
|
|
14102
|
+
},
|
|
14103
|
+
children: [
|
|
14104
|
+
sIdx + 1,
|
|
14105
|
+
".",
|
|
14106
|
+
localIndex + 1
|
|
14107
|
+
]
|
|
14108
|
+
}
|
|
14109
|
+
),
|
|
14110
|
+
qTitle,
|
|
14111
|
+
" ",
|
|
14112
|
+
q.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626" }, children: "*" })
|
|
14113
|
+
]
|
|
14114
|
+
}
|
|
14115
|
+
),
|
|
14116
|
+
/* @__PURE__ */ jsxs(
|
|
14117
|
+
"div",
|
|
14118
|
+
{
|
|
14119
|
+
style: {
|
|
14120
|
+
display: "flex",
|
|
14121
|
+
alignItems: "center",
|
|
14122
|
+
gap: 6,
|
|
14123
|
+
fontSize: 10,
|
|
14124
|
+
color: "#64748b",
|
|
14125
|
+
marginTop: 2
|
|
14126
|
+
},
|
|
14127
|
+
children: [
|
|
14128
|
+
/* @__PURE__ */ jsx("code", { children: q.key }),
|
|
14129
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
14130
|
+
"• ",
|
|
14131
|
+
q.type
|
|
14132
|
+
] }),
|
|
14133
|
+
hasCond && /* @__PURE__ */ jsx(
|
|
14134
|
+
"span",
|
|
14135
|
+
{
|
|
14136
|
+
style: {
|
|
14137
|
+
padding: "1px 5px",
|
|
14138
|
+
borderRadius: 4,
|
|
14139
|
+
background: "#fef3c7",
|
|
14140
|
+
color: "#92400e",
|
|
14141
|
+
fontWeight: 700
|
|
14142
|
+
},
|
|
14143
|
+
children: tr ? "Koşullu" : "Skip Logic"
|
|
14144
|
+
}
|
|
14145
|
+
)
|
|
14146
|
+
]
|
|
14147
|
+
}
|
|
14148
|
+
)
|
|
14149
|
+
] })
|
|
14150
|
+
]
|
|
14151
|
+
}
|
|
14152
|
+
),
|
|
14153
|
+
/* @__PURE__ */ jsx(
|
|
14154
|
+
"button",
|
|
14155
|
+
{
|
|
14156
|
+
type: "button",
|
|
14157
|
+
onClick: (e) => {
|
|
14158
|
+
e.stopPropagation();
|
|
14159
|
+
removeQuestion(qIdx);
|
|
14160
|
+
},
|
|
14161
|
+
style: {
|
|
14162
|
+
border: "none",
|
|
14163
|
+
background: "transparent",
|
|
14164
|
+
color: "#dc2626",
|
|
14165
|
+
cursor: "pointer",
|
|
14166
|
+
fontSize: 15
|
|
11885
14167
|
},
|
|
11886
|
-
|
|
14168
|
+
title: tr ? "Soruyu sil" : "Delete question",
|
|
14169
|
+
children: "×"
|
|
14170
|
+
}
|
|
14171
|
+
),
|
|
14172
|
+
qIndAfter && /* @__PURE__ */ jsx(
|
|
14173
|
+
"div",
|
|
14174
|
+
{
|
|
14175
|
+
style: {
|
|
14176
|
+
position: "absolute",
|
|
14177
|
+
bottom: -4,
|
|
14178
|
+
left: 4,
|
|
14179
|
+
right: 4,
|
|
14180
|
+
height: 2.5,
|
|
14181
|
+
borderRadius: 2,
|
|
14182
|
+
background: "#2563eb",
|
|
14183
|
+
zIndex: 4
|
|
14184
|
+
}
|
|
11887
14185
|
}
|
|
11888
14186
|
)
|
|
11889
14187
|
]
|
|
11890
|
-
}
|
|
11891
|
-
|
|
11892
|
-
|
|
14188
|
+
},
|
|
14189
|
+
q.key || qIdx
|
|
14190
|
+
);
|
|
14191
|
+
}),
|
|
14192
|
+
/* @__PURE__ */ jsxs(
|
|
14193
|
+
"button",
|
|
14194
|
+
{
|
|
14195
|
+
type: "button",
|
|
14196
|
+
onClick: (e) => {
|
|
14197
|
+
e.stopPropagation();
|
|
14198
|
+
addQuestionOfType("single_choice", void 0, st.id);
|
|
14199
|
+
},
|
|
14200
|
+
style: {
|
|
14201
|
+
marginTop: 2,
|
|
14202
|
+
padding: "5px 8px",
|
|
14203
|
+
borderRadius: 6,
|
|
14204
|
+
border: "1px dashed #93c5fd",
|
|
14205
|
+
background: "#f8fafc",
|
|
14206
|
+
color: "#1d4ed8",
|
|
14207
|
+
fontSize: 10.5,
|
|
14208
|
+
fontWeight: 700,
|
|
14209
|
+
cursor: "pointer"
|
|
14210
|
+
},
|
|
14211
|
+
children: [
|
|
14212
|
+
"+ ",
|
|
14213
|
+
tr ? "Bu Adıma Soru Ekle" : "Add Question to This Step"
|
|
14214
|
+
]
|
|
14215
|
+
}
|
|
14216
|
+
)
|
|
11893
14217
|
]
|
|
11894
14218
|
}
|
|
11895
14219
|
),
|
|
11896
|
-
/* @__PURE__ */ jsx(
|
|
11897
|
-
"
|
|
14220
|
+
stepIndicatorAfter && /* @__PURE__ */ jsx(
|
|
14221
|
+
"div",
|
|
11898
14222
|
{
|
|
11899
|
-
type: "button",
|
|
11900
|
-
onClick: (e) => {
|
|
11901
|
-
e.stopPropagation();
|
|
11902
|
-
removeQuestion(qIdx);
|
|
11903
|
-
},
|
|
11904
14223
|
style: {
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
14224
|
+
position: "absolute",
|
|
14225
|
+
bottom: -5,
|
|
14226
|
+
left: 6,
|
|
14227
|
+
right: 6,
|
|
14228
|
+
height: 3,
|
|
14229
|
+
borderRadius: 3,
|
|
14230
|
+
background: "#2563eb",
|
|
14231
|
+
zIndex: 5
|
|
14232
|
+
}
|
|
11913
14233
|
}
|
|
11914
14234
|
)
|
|
11915
14235
|
]
|
|
11916
14236
|
},
|
|
11917
|
-
|
|
14237
|
+
st.id
|
|
11918
14238
|
);
|
|
11919
14239
|
})
|
|
11920
|
-
}
|
|
14240
|
+
] });
|
|
14241
|
+
})() : (
|
|
14242
|
+
/* SINGLE-PAGE / QUICK-POLL FLAT DRAGGABLE QUESTIONS LIST */
|
|
14243
|
+
/* @__PURE__ */ jsx(
|
|
14244
|
+
"div",
|
|
14245
|
+
{
|
|
14246
|
+
onDragOver: (e) => {
|
|
14247
|
+
if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
|
|
14248
|
+
e.preventDefault();
|
|
14249
|
+
}
|
|
14250
|
+
},
|
|
14251
|
+
onDrop: (e) => {
|
|
14252
|
+
e.preventDefault();
|
|
14253
|
+
if (dragRef.current?.kind === "new-type") {
|
|
14254
|
+
const t = dragRef.current.qType;
|
|
14255
|
+
dragRef.current = null;
|
|
14256
|
+
setDropIndicator(null);
|
|
14257
|
+
addQuestionOfType(t);
|
|
14258
|
+
}
|
|
14259
|
+
},
|
|
14260
|
+
style: { display: "flex", flexDirection: "column", gap: 7 },
|
|
14261
|
+
children: questions.map((q, qIdx) => {
|
|
14262
|
+
const selected = qIdx === selectedQuestionIdx;
|
|
14263
|
+
const qTitle = pickTextForLocale(q.title, uiLocale, q.key);
|
|
14264
|
+
const hasCond = q.conditions && Array.isArray(q.conditions.rules) && q.conditions.rules.length > 0;
|
|
14265
|
+
const qIndBefore = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "before";
|
|
14266
|
+
const qIndAfter = dropIndicator?.kind === "question" && dropIndicator.targetId === q.key && dropIndicator.position === "after";
|
|
14267
|
+
return /* @__PURE__ */ jsxs(
|
|
14268
|
+
"div",
|
|
14269
|
+
{
|
|
14270
|
+
draggable: true,
|
|
14271
|
+
onDragStart: (e) => {
|
|
14272
|
+
dragRef.current = {
|
|
14273
|
+
kind: "question",
|
|
14274
|
+
index: qIdx,
|
|
14275
|
+
questionKey: q.key
|
|
14276
|
+
};
|
|
14277
|
+
e.dataTransfer.setData("text/plain", q.key);
|
|
14278
|
+
},
|
|
14279
|
+
onDragEnd: () => {
|
|
14280
|
+
dragRef.current = null;
|
|
14281
|
+
setDropIndicator(null);
|
|
14282
|
+
},
|
|
14283
|
+
onDragOver: (e) => {
|
|
14284
|
+
if (dragRef.current?.kind === "question" || dragRef.current?.kind === "new-type") {
|
|
14285
|
+
e.preventDefault();
|
|
14286
|
+
e.stopPropagation();
|
|
14287
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
14288
|
+
const pos = e.clientY - rect.top < rect.height / 2 ? "before" : "after";
|
|
14289
|
+
setDropIndicator({
|
|
14290
|
+
kind: "question",
|
|
14291
|
+
targetId: q.key,
|
|
14292
|
+
position: pos
|
|
14293
|
+
});
|
|
14294
|
+
}
|
|
14295
|
+
},
|
|
14296
|
+
onDrop: (e) => {
|
|
14297
|
+
e.preventDefault();
|
|
14298
|
+
e.stopPropagation();
|
|
14299
|
+
const item = dragRef.current;
|
|
14300
|
+
const curInd = dropIndicator;
|
|
14301
|
+
dragRef.current = null;
|
|
14302
|
+
setDropIndicator(null);
|
|
14303
|
+
if (!item) return;
|
|
14304
|
+
const pos = curInd?.kind === "question" && curInd.targetId === q.key ? curInd.position : "before";
|
|
14305
|
+
if (item.kind === "new-type") {
|
|
14306
|
+
const insIdx = pos === "after" ? qIdx + 1 : qIdx;
|
|
14307
|
+
addQuestionOfType(item.qType, insIdx);
|
|
14308
|
+
return;
|
|
14309
|
+
}
|
|
14310
|
+
if (item.kind === "question" && item.questionKey !== q.key) {
|
|
14311
|
+
const next = reorderFlatQuestions(
|
|
14312
|
+
questions,
|
|
14313
|
+
item.questionKey,
|
|
14314
|
+
q.key,
|
|
14315
|
+
pos
|
|
14316
|
+
);
|
|
14317
|
+
setDraft((prev) => ({ ...prev, questions: next }));
|
|
14318
|
+
selectQuestionByKey(next, item.questionKey);
|
|
14319
|
+
}
|
|
14320
|
+
},
|
|
14321
|
+
onClick: () => setSelectedQuestionIdx(qIdx),
|
|
14322
|
+
style: {
|
|
14323
|
+
position: "relative",
|
|
14324
|
+
padding: "9px 10px",
|
|
14325
|
+
borderRadius: 8,
|
|
14326
|
+
border: selected ? "2px solid #2563eb" : "1px solid #cbd5e1",
|
|
14327
|
+
background: selected ? "#eff6ff" : "#ffffff",
|
|
14328
|
+
cursor: "grab",
|
|
14329
|
+
display: "flex",
|
|
14330
|
+
alignItems: "center",
|
|
14331
|
+
justifyContent: "space-between",
|
|
14332
|
+
gap: 8
|
|
14333
|
+
},
|
|
14334
|
+
children: [
|
|
14335
|
+
qIndBefore && /* @__PURE__ */ jsx(
|
|
14336
|
+
"div",
|
|
14337
|
+
{
|
|
14338
|
+
style: {
|
|
14339
|
+
position: "absolute",
|
|
14340
|
+
top: -4,
|
|
14341
|
+
left: 4,
|
|
14342
|
+
right: 4,
|
|
14343
|
+
height: 2.5,
|
|
14344
|
+
borderRadius: 2,
|
|
14345
|
+
background: "#2563eb",
|
|
14346
|
+
zIndex: 4
|
|
14347
|
+
}
|
|
14348
|
+
}
|
|
14349
|
+
),
|
|
14350
|
+
/* @__PURE__ */ jsxs(
|
|
14351
|
+
"div",
|
|
14352
|
+
{
|
|
14353
|
+
style: {
|
|
14354
|
+
display: "flex",
|
|
14355
|
+
alignItems: "center",
|
|
14356
|
+
gap: 7,
|
|
14357
|
+
overflow: "hidden"
|
|
14358
|
+
},
|
|
14359
|
+
children: [
|
|
14360
|
+
/* @__PURE__ */ jsx(
|
|
14361
|
+
MaterialIcon,
|
|
14362
|
+
{
|
|
14363
|
+
name: "drag_indicator",
|
|
14364
|
+
size: 16,
|
|
14365
|
+
color: selected ? "#2563eb" : "#94a3b8"
|
|
14366
|
+
}
|
|
14367
|
+
),
|
|
14368
|
+
/* @__PURE__ */ jsxs("div", { style: { overflow: "hidden" }, children: [
|
|
14369
|
+
/* @__PURE__ */ jsxs(
|
|
14370
|
+
"div",
|
|
14371
|
+
{
|
|
14372
|
+
style: {
|
|
14373
|
+
fontSize: 12,
|
|
14374
|
+
fontWeight: 700,
|
|
14375
|
+
color: "#0f172a",
|
|
14376
|
+
whiteSpace: "nowrap",
|
|
14377
|
+
overflow: "hidden",
|
|
14378
|
+
textOverflow: "ellipsis"
|
|
14379
|
+
},
|
|
14380
|
+
children: [
|
|
14381
|
+
qIdx + 1,
|
|
14382
|
+
". ",
|
|
14383
|
+
qTitle,
|
|
14384
|
+
" ",
|
|
14385
|
+
q.required && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626" }, children: "*" })
|
|
14386
|
+
]
|
|
14387
|
+
}
|
|
14388
|
+
),
|
|
14389
|
+
/* @__PURE__ */ jsxs(
|
|
14390
|
+
"div",
|
|
14391
|
+
{
|
|
14392
|
+
style: {
|
|
14393
|
+
display: "flex",
|
|
14394
|
+
alignItems: "center",
|
|
14395
|
+
gap: 6,
|
|
14396
|
+
fontSize: 10,
|
|
14397
|
+
color: "#64748b",
|
|
14398
|
+
marginTop: 2
|
|
14399
|
+
},
|
|
14400
|
+
children: [
|
|
14401
|
+
/* @__PURE__ */ jsx("code", { children: q.key }),
|
|
14402
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
14403
|
+
"• ",
|
|
14404
|
+
q.type
|
|
14405
|
+
] }),
|
|
14406
|
+
hasCond && /* @__PURE__ */ jsx(
|
|
14407
|
+
"span",
|
|
14408
|
+
{
|
|
14409
|
+
style: {
|
|
14410
|
+
padding: "1px 5px",
|
|
14411
|
+
borderRadius: 4,
|
|
14412
|
+
background: "#fef3c7",
|
|
14413
|
+
color: "#92400e",
|
|
14414
|
+
fontWeight: 700
|
|
14415
|
+
},
|
|
14416
|
+
children: tr ? "Koşullu" : "Skip Logic"
|
|
14417
|
+
}
|
|
14418
|
+
)
|
|
14419
|
+
]
|
|
14420
|
+
}
|
|
14421
|
+
)
|
|
14422
|
+
] })
|
|
14423
|
+
]
|
|
14424
|
+
}
|
|
14425
|
+
),
|
|
14426
|
+
/* @__PURE__ */ jsx(
|
|
14427
|
+
"button",
|
|
14428
|
+
{
|
|
14429
|
+
type: "button",
|
|
14430
|
+
onClick: (e) => {
|
|
14431
|
+
e.stopPropagation();
|
|
14432
|
+
removeQuestion(qIdx);
|
|
14433
|
+
},
|
|
14434
|
+
style: {
|
|
14435
|
+
border: "none",
|
|
14436
|
+
background: "transparent",
|
|
14437
|
+
color: "#dc2626",
|
|
14438
|
+
cursor: "pointer",
|
|
14439
|
+
fontSize: 15
|
|
14440
|
+
},
|
|
14441
|
+
title: tr ? "Soruyu sil" : "Delete question",
|
|
14442
|
+
children: "×"
|
|
14443
|
+
}
|
|
14444
|
+
),
|
|
14445
|
+
qIndAfter && /* @__PURE__ */ jsx(
|
|
14446
|
+
"div",
|
|
14447
|
+
{
|
|
14448
|
+
style: {
|
|
14449
|
+
position: "absolute",
|
|
14450
|
+
bottom: -4,
|
|
14451
|
+
left: 4,
|
|
14452
|
+
right: 4,
|
|
14453
|
+
height: 2.5,
|
|
14454
|
+
borderRadius: 2,
|
|
14455
|
+
background: "#2563eb",
|
|
14456
|
+
zIndex: 4
|
|
14457
|
+
}
|
|
14458
|
+
}
|
|
14459
|
+
)
|
|
14460
|
+
]
|
|
14461
|
+
},
|
|
14462
|
+
q.key || qIdx
|
|
14463
|
+
);
|
|
14464
|
+
})
|
|
14465
|
+
}
|
|
14466
|
+
)
|
|
11921
14467
|
)
|
|
11922
14468
|
]
|
|
11923
14469
|
}
|
|
@@ -12009,7 +14555,17 @@ const SurveyStudioModal = ({
|
|
|
12009
14555
|
"select",
|
|
12010
14556
|
{
|
|
12011
14557
|
value: activeQ.stepId || steps[0]?.id || "",
|
|
12012
|
-
onChange: (e) =>
|
|
14558
|
+
onChange: (e) => {
|
|
14559
|
+
const nextStepId = e.target.value;
|
|
14560
|
+
const nextDraft = moveQuestionInMultiStepDraft(draft, activeQ.key, {
|
|
14561
|
+
stepId: nextStepId,
|
|
14562
|
+
position: "end"
|
|
14563
|
+
});
|
|
14564
|
+
setDraft(nextDraft);
|
|
14565
|
+
selectQuestionByKey(nextDraft.questions, activeQ.key);
|
|
14566
|
+
setActiveStepId(nextStepId);
|
|
14567
|
+
setCollapsedStepIds((prev) => ({ ...prev, [nextStepId]: false }));
|
|
14568
|
+
},
|
|
12013
14569
|
style: inputStyle,
|
|
12014
14570
|
children: steps.map((st) => /* @__PURE__ */ jsx("option", { value: st.id, children: pickTextForLocale(st.title, uiLocale, st.id) }, st.id))
|
|
12015
14571
|
}
|
|
@@ -13540,7 +16096,72 @@ const SurveyStudioModal = ({
|
|
|
13540
16096
|
strapiLocales
|
|
13541
16097
|
}
|
|
13542
16098
|
),
|
|
13543
|
-
tab === "analytics" && /* @__PURE__ */ jsx("div", { style: { flex: 1, padding: 20, overflowY: "auto", background: "#f8fafc" }, children: /* @__PURE__ */ jsx(
|
|
16099
|
+
tab === "analytics" && /* @__PURE__ */ jsx("div", { style: { flex: 1, padding: 20, overflowY: "auto", background: "#f8fafc" }, children: /* @__PURE__ */ jsx(
|
|
16100
|
+
SurveyAnalyticsView,
|
|
16101
|
+
{
|
|
16102
|
+
surveySlugOrId: draft.slug,
|
|
16103
|
+
uiLocale
|
|
16104
|
+
},
|
|
16105
|
+
`${draft.slug}-${studioAnalyticsKey}`
|
|
16106
|
+
) }),
|
|
16107
|
+
/* @__PURE__ */ jsx(
|
|
16108
|
+
SurveyExportModal,
|
|
16109
|
+
{
|
|
16110
|
+
open: studioExportOpen,
|
|
16111
|
+
uiLocale,
|
|
16112
|
+
targetSurvey: draft,
|
|
16113
|
+
allowAllSurveys: false,
|
|
16114
|
+
isUnsavedDraft: !draft.id && !draft.documentId && !draft._id,
|
|
16115
|
+
onClose: () => setStudioExportOpen(false)
|
|
16116
|
+
}
|
|
16117
|
+
),
|
|
16118
|
+
/* @__PURE__ */ jsx(
|
|
16119
|
+
SurveyImportModal,
|
|
16120
|
+
{
|
|
16121
|
+
open: studioImportOpen,
|
|
16122
|
+
uiLocale,
|
|
16123
|
+
existingSlugs: draft.slug ? [draft.slug] : [],
|
|
16124
|
+
onClose: () => setStudioImportOpen(false),
|
|
16125
|
+
onImported: (res) => {
|
|
16126
|
+
const first = res.importedSurveys?.[0];
|
|
16127
|
+
if (first) {
|
|
16128
|
+
const nextDraft = first.displayMode === "multi_step" ? normalizeMultiStepDraft(JSON.parse(JSON.stringify(first))) : JSON.parse(JSON.stringify(first));
|
|
16129
|
+
setDraft(nextDraft);
|
|
16130
|
+
setSelectedQuestionIdx(0);
|
|
16131
|
+
setActiveStepId(nextDraft.steps?.[0]?.id || "step_1");
|
|
16132
|
+
setStudioAnalyticsKey((k) => k + 1);
|
|
16133
|
+
setStatusMsg(
|
|
16134
|
+
tr ? `İçe aktarıldı (${res.importedResponsesCount} yanıt)!` : `Imported (${res.importedResponsesCount} responses)!`
|
|
16135
|
+
);
|
|
16136
|
+
if (typeof window !== "undefined") {
|
|
16137
|
+
window.dispatchEvent(new CustomEvent("ci-survey-updated", { detail: first }));
|
|
16138
|
+
}
|
|
16139
|
+
onSaved?.(first);
|
|
16140
|
+
}
|
|
16141
|
+
}
|
|
16142
|
+
}
|
|
16143
|
+
),
|
|
16144
|
+
/* @__PURE__ */ jsx(
|
|
16145
|
+
SurveyCleanupConfirmModal,
|
|
16146
|
+
{
|
|
16147
|
+
open: Boolean(studioCleanupAction),
|
|
16148
|
+
action: studioCleanupAction,
|
|
16149
|
+
uiLocale,
|
|
16150
|
+
targetSurvey: draft,
|
|
16151
|
+
onClose: () => setStudioCleanupAction(null),
|
|
16152
|
+
onCompleted: (act, payload) => {
|
|
16153
|
+
if (act === "clear-responses") {
|
|
16154
|
+
const updatedDraft = { ...draft, responseCount: 0, npsScore: null };
|
|
16155
|
+
setDraft(updatedDraft);
|
|
16156
|
+
setStudioAnalyticsKey((k) => k + 1);
|
|
16157
|
+
setStatusMsg(
|
|
16158
|
+
tr ? `${payload?.deletedCount || 0} yanıt sıfırlandı.` : `Cleared ${payload?.deletedCount || 0} response(s).`
|
|
16159
|
+
);
|
|
16160
|
+
onSaved?.(updatedDraft);
|
|
16161
|
+
}
|
|
16162
|
+
}
|
|
16163
|
+
}
|
|
16164
|
+
)
|
|
13544
16165
|
]
|
|
13545
16166
|
}
|
|
13546
16167
|
)
|
|
@@ -13601,13 +16222,13 @@ const SurveyWidgetEditor = ({ widget, onChange }) => {
|
|
|
13601
16222
|
/* @__PURE__ */ jsx(
|
|
13602
16223
|
"select",
|
|
13603
16224
|
{
|
|
13604
|
-
value: matchedSurvey?.slug || selectedRef,
|
|
16225
|
+
value: matchedSurvey?.slug || (surveysList.length > 0 ? selectedRef : ""),
|
|
13605
16226
|
onChange: (e) => {
|
|
13606
16227
|
const chosen = surveysList.find((s) => s.slug === e.target.value);
|
|
13607
16228
|
if (chosen) bindSurveyToWidget(chosen);
|
|
13608
16229
|
},
|
|
13609
16230
|
style: inputStyle,
|
|
13610
|
-
children: surveysList.map((s) => /* @__PURE__ */ jsxs("option", { value: s.slug, children: [
|
|
16231
|
+
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
16232
|
pickTextForLocale(s.titleI18n, locale, s.title),
|
|
13612
16233
|
" (",
|
|
13613
16234
|
s.responseCount ?? 0,
|
|
@@ -13821,9 +16442,12 @@ export {
|
|
|
13821
16442
|
pickTextForLocale as N,
|
|
13822
16443
|
SurveyAnalyticsView as O,
|
|
13823
16444
|
SurveyStudioModal as P,
|
|
13824
|
-
|
|
16445
|
+
SurveyExportModal as Q,
|
|
13825
16446
|
ROW_PRESETS as R,
|
|
13826
16447
|
StrapiMediaPicker as S,
|
|
16448
|
+
SurveyImportModal as T,
|
|
16449
|
+
SurveyCleanupConfirmModal as U,
|
|
16450
|
+
persistLocale as V,
|
|
13827
16451
|
WIDGET_DEFINITIONS as W,
|
|
13828
16452
|
ZOOM_OPTIONS as Z,
|
|
13829
16453
|
useEditorTranslator as a,
|