mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
Update doc-survey-widget.tsx
This commit is contained in:
parent
5122aafb8e
commit
a52c686fbf
@ -59,8 +59,10 @@ export const DocSurveyWidget = ({ className }: Props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentSurveyId = survey?.id || generateRandomSurveyId();
|
||||||
|
|
||||||
const data = await updateSurvey({
|
const data = await updateSurvey({
|
||||||
surveyId: survey?.id,
|
surveyId: currentSurveyId,
|
||||||
body: { response: selectedOption, responseText: text },
|
body: { response: selectedOption, responseText: text },
|
||||||
});
|
});
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
@ -304,7 +306,8 @@ const generateRandomSurveyId = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createSurvey = async ({ body }: { body: DocSurveyCreateDto }) => {
|
const createSurvey = async ({ body }: { body: DocSurveyCreateDto }) => {
|
||||||
const response = await fetch(`${DOC_SURVEY_URL}?surveyId=${generateRandomSurveyId()}`, {
|
const surveyId = generateRandomSurveyId();
|
||||||
|
const response = await fetch(`${DOC_SURVEY_URL}?surveyId=${surveyId}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -321,6 +324,7 @@ const createSurvey = async ({ body }: { body: DocSurveyCreateDto }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const updateSurvey = async ({
|
const updateSurvey = async ({
|
||||||
surveyId,
|
surveyId,
|
||||||
body,
|
body,
|
||||||
@ -328,7 +332,7 @@ const updateSurvey = async ({
|
|||||||
surveyId?: string;
|
surveyId?: string;
|
||||||
body: DocSurveyUpdateDto;
|
body: DocSurveyUpdateDto;
|
||||||
}) => {
|
}) => {
|
||||||
const response = await fetch(`${DOC_SURVEY_URL}?surveyId=${generateRandomSurveyId()}`, {
|
const response = await fetch(`${DOC_SURVEY_URL}?surveyId=${surveyId}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -344,6 +348,7 @@ const updateSurvey = async ({
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const surveyOptions: {
|
const surveyOptions: {
|
||||||
value: SurveyOption;
|
value: SurveyOption;
|
||||||
img: string;
|
img: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user