fix registration

This commit is contained in:
Tatiana Nikolaeva 2025-06-02 18:23:14 +05:00
parent 2ec9354fc1
commit 08f827267d
12 changed files with 84 additions and 88 deletions

View file

@ -4,4 +4,19 @@
max-width: 100vw;
min-height: 100vh;
padding: 34px 16%;
}
.departur_button{
display: block;
margin: 10px auto;
padding: 25px 50.5px;
border: none;
border-radius: 20px;
background-color: #3788D6;
color: white;
font-weight: 700;
font-size: 24px;
text-align: center;
box-shadow: 0 0 7.4px 0 rgba(154, 202, 247, 1);
box-sizing: border-box;
}

View file

@ -7,34 +7,16 @@ import {getSurveyById, ISurvey} from "../../api/SurveyApi.ts";
import {getListQuestions} from "../../api/QuestionApi.ts";
import {getAnswerVariants, IAnswerVariant} from "../../api/AnswerVariantsApi.ts";
export const CompletingSurvey = () => {
// const [titleSurvey, setTitleSurvey] = useState("Название опроса");
// const [descriptionSurvey, setDescriptionSurvey] = useState("");
// const [questions, setQuestions] = useState<Question[]>([
// { id: 1, text: 'Вопрос 1', questionType: 'SingleAnswerQuestion', answerVariants: [{ id: 1, text: 'Ответ 1' },
// { id: 2, text: 'Ответ 1' }, { id: 3, text: 'Ответ 1' }]},
// { id: 2, text: 'Вопрос 2', questionType: 'MultipleAnswerQuestion', answerVariants: [{ id: 1, text: 'Ответ 1' },
// { id: 2, text: 'Ответ 1' }, { id: 3, text: 'Ответ 1' }]}
// ]);
// const [questions, setQuestions] = useState<Question[]>([]);
// const [loading, setLoading] = useState(true);
// const [error, setError] = useState<string | null>(null);
//
// const [description, setDescription] = useState('');
// const [title, setTitle] = useState('');
//
// const { survey, setSurvey } = useOutletContext<{
// survey: ISurvey;
// setSurvey: (survey: ISurvey) => void;
// }>();
const {surveyId} = useParams<{surveyId: string}>();
const [survey, setSurvey] = useState<ISurvey | null>(null);
const [questions, setQuestions] = useState<Question[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const fetchSurveyData = async () => {
try {
@ -73,6 +55,7 @@ export const CompletingSurvey = () => {
if (error) return <div>{error}</div>;
if (!survey) return <div>Опрос не найден</div>;
return (
<div className={styles.survey}>
<SurveyInfo
@ -85,6 +68,7 @@ export const CompletingSurvey = () => {
questions={questions}
setQuestions={setQuestions}
/>
<button className={styles.departur_button}>Отправить</button>
</div>
)
}

View file

@ -1,16 +0,0 @@
/*QuestionsList.module.css*/
.departur_button{
display: block;
margin: 10px auto;
padding: 25px 50.5px;
border: none;
border-radius: 20px;
background-color: #3788D6;
color: white;
font-weight: 700;
font-size: 24px;
text-align: center;
box-shadow: 0 0 7.4px 0 rgba(154, 202, 247, 1);
box-sizing: border-box;
}

View file

@ -3,7 +3,6 @@ import QuestionItem from "../QuestionItem/QuestionItem.tsx";
import AddQuestionButton from "../AddQuestionButton/AddQuestionButton.tsx";
import {addNewQuestion, deleteQuestion, getListQuestions} from "../../api/QuestionApi.ts";
import {addNewAnswerVariant} from "../../api/AnswerVariantsApi.ts";
import styles from './QuestionsList.module.css'
import {useRouteReadOnly} from "../../hooks/useRouteReadOnly.ts";
interface QuestionsListProps {
@ -127,9 +126,7 @@ const QuestionsList: React.FC<QuestionsListProps> = ({questions, setQuestions, s
surveyId={surveyId}
/>
))}
{!isReadOnly ? <AddQuestionButton onClick={handleAddQuestion} /> : (
<button className={styles.departur_button}>Отправить</button>
)}
{!isReadOnly ? <AddQuestionButton onClick={handleAddQuestion} /> : ''}
</>
);

View file

@ -38,10 +38,7 @@ const RegisterForm = () => {
const responseData = await registerUser({username, firstName, lastName, email, password});
if (responseData && !responseData.error) {
console.log('Регистрация успешна');
localStorage.setItem("user", JSON.stringify({
firstName,
lastName
}));
localStorage.setItem("user", JSON.stringify(responseData.user));
navigate('/my-surveys');
}
else if (responseData.status === 409){