fix created at
This commit is contained in:
parent
a652b78230
commit
6068c717d3
6 changed files with 34 additions and 73 deletions
|
|
@ -5,7 +5,6 @@ export interface ISurvey {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
createdBy: number;
|
createdBy: number;
|
||||||
createdAt: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INewSurvey{
|
export interface INewSurvey{
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,6 @@ export const MySurveyList = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [surveys, setSurveys] = useState<MySurveyItem[]>([]);
|
const [surveys, setSurveys] = useState<MySurveyItem[]>([]);
|
||||||
|
|
||||||
const formatDate = (dateString: string) => {
|
|
||||||
const date = new Date(dateString);
|
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
||||||
|
|
||||||
return `${day}/${month}/${year} ${hours}:${minutes}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSurvey = async () => {
|
const fetchSurvey = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -74,7 +63,7 @@ export const MySurveyList = () => {
|
||||||
<h1 className={styles.title}>{survey.title}</h1>
|
<h1 className={styles.title}>{survey.title}</h1>
|
||||||
<h2 className={styles.description}>{survey.description}</h2>
|
<h2 className={styles.description}>{survey.description}</h2>
|
||||||
</div>
|
</div>
|
||||||
<span className={styles.date}>Дата создания: {formatDate(survey.createdAt)}</span>
|
<span className={styles.date}>Дата создания: {survey.createdBy}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={`${styles.status} ${
|
<div className={`${styles.status} ${
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,10 @@
|
||||||
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
||||||
import styles from './Results.module.css'
|
import styles from './Results.module.css'
|
||||||
import {useEffect, useState} from "react";
|
import {useState} from "react";
|
||||||
import {useParams} from "react-router-dom";
|
|
||||||
import {getSurveyById} from "../../api/SurveyApi.ts";
|
|
||||||
|
|
||||||
export const Results = () => {
|
export const Results = () => {
|
||||||
const [descriptionSurvey, setDescriptionSurvey] = useState('');
|
const [descriptionSurvey, setDescriptionSurvey] = useState('');
|
||||||
const [titleSurvey, setTitleSurvey] = useState('');
|
const [titleSurvey, setTitleSurvey] = useState('Название опроса');
|
||||||
const { surveyId } = useParams<{ surveyId: string }>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!surveyId) {
|
|
||||||
console.error('Survey ID is missing');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const id = parseInt(surveyId);
|
|
||||||
if (isNaN(id)) {
|
|
||||||
console.error('Invalid survey ID');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchData = async () => {
|
|
||||||
try {
|
|
||||||
const surveyData = await getSurveyById(id);
|
|
||||||
setTitleSurvey(surveyData.title);
|
|
||||||
setDescriptionSurvey(surveyData.description);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Ошибка:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchData();
|
|
||||||
|
|
||||||
}, [surveyId]);
|
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div className={styles.results}>
|
<div className={styles.results}>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
.settingSurvey{
|
.settingSurvey{
|
||||||
width: 85%;
|
width: 85%;
|
||||||
height: 100vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.startEndTime{
|
.startEndTime{
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,43 @@
|
||||||
import React, {useEffect, useState} from 'react';
|
import React, {useState} from 'react';
|
||||||
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
||||||
import styles from "./SettingSurvey.module.css";
|
import styles from "./SettingSurvey.module.css";
|
||||||
import TimeEvent from "../TimeEvent/TimeEvent.tsx";
|
import TimeEvent from "../TimeEvent/TimeEvent.tsx";
|
||||||
import SaveButton from "../SaveButton/SaveButton.tsx";
|
import SaveButton from "../SaveButton/SaveButton.tsx";
|
||||||
import {useParams} from "react-router-dom";
|
// import {useParams} from "react-router-dom";
|
||||||
import {getSurveyById} from "../../api/SurveyApi.ts";
|
// import {getSurveyById, ISurvey} from "../../api/SurveyApi.ts";
|
||||||
|
|
||||||
|
|
||||||
const SettingSurvey: React.FC = () => {
|
const SettingSurvey: React.FC = () => {
|
||||||
const [descriptionSurvey, setDescriptionSurvey] = useState('');
|
const [descriptionSurvey, setDescriptionSurvey] = useState('');
|
||||||
|
// const [survey, setSurvey] = useState<ISurvey | null>(null);
|
||||||
const [titleSurvey, setTitleSurvey] = useState('');
|
const [titleSurvey, setTitleSurvey] = useState('');
|
||||||
const { surveyId } = useParams<{ surveyId: string }>();
|
// const { surveyId } = useParams<{ surveyId: string }>();
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (!surveyId) {
|
// if (!surveyId) {
|
||||||
console.error('Survey ID is missing');
|
// console.error('Survey ID is missing');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const id = parseInt(surveyId);
|
// const id = parseInt(surveyId);
|
||||||
if (isNaN(id)) {
|
// if (isNaN(id)) {
|
||||||
console.error('Invalid survey ID');
|
// console.error('Invalid survey ID');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const fetchData = async () => {
|
// const fetchData = async () => {
|
||||||
try {
|
// try {
|
||||||
const surveyData = await getSurveyById(id);
|
// const surveyData = await getSurveyById(id);
|
||||||
setTitleSurvey(surveyData.title);
|
// setSurvey(surveyData);
|
||||||
setDescriptionSurvey(surveyData.description);
|
// setTitleSurvey(surveyData.title);
|
||||||
} catch (error) {
|
// setDescriptionSurvey(surveyData.description);
|
||||||
console.error('Ошибка:', error);
|
// } catch (error) {
|
||||||
}
|
// console.error('Ошибка:', error);
|
||||||
};
|
// }
|
||||||
|
// };
|
||||||
fetchData();
|
//
|
||||||
|
// fetchData();
|
||||||
}, [surveyId]);
|
//
|
||||||
|
// }, [surveyId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.settingSurvey}>
|
<div className={styles.settingSurvey}>
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderTitle = () => {
|
const renderTitle = () => {
|
||||||
if ( isCompleteSurveyActive) {
|
if (isSurveyViewPage || isCompleteSurveyActive) {
|
||||||
return (
|
return (
|
||||||
<button className={styles.titleSurvey}>
|
<button className={styles.titleSurvey}>
|
||||||
<h1>{titleSurvey || 'Название опроса'}</h1>
|
<h1>{titleSurvey || 'Название опроса'}</h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue