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;
|
||||
description: string;
|
||||
createdBy: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface INewSurvey{
|
||||
|
|
|
|||
|
|
@ -13,17 +13,6 @@ export const MySurveyList = () => {
|
|||
const navigate = useNavigate();
|
||||
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(() => {
|
||||
const fetchSurvey = async () => {
|
||||
try {
|
||||
|
|
@ -74,7 +63,7 @@ export const MySurveyList = () => {
|
|||
<h1 className={styles.title}>{survey.title}</h1>
|
||||
<h2 className={styles.description}>{survey.description}</h2>
|
||||
</div>
|
||||
<span className={styles.date}>Дата создания: {formatDate(survey.createdAt)}</span>
|
||||
<span className={styles.date}>Дата создания: {survey.createdBy}</span>
|
||||
</div>
|
||||
<div className={styles.container}>
|
||||
<div className={`${styles.status} ${
|
||||
|
|
|
|||
|
|
@ -1,38 +1,10 @@
|
|||
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
||||
import styles from './Results.module.css'
|
||||
import {useEffect, useState} from "react";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {getSurveyById} from "../../api/SurveyApi.ts";
|
||||
import {useState} from "react";
|
||||
|
||||
export const Results = () => {
|
||||
const [descriptionSurvey, setDescriptionSurvey] = 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]);
|
||||
const [titleSurvey, setTitleSurvey] = useState('Название опроса');
|
||||
|
||||
return(
|
||||
<div className={styles.results}>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
.settingSurvey{
|
||||
width: 85%;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.startEndTime{
|
||||
|
|
|
|||
|
|
@ -1,41 +1,43 @@
|
|||
import React, {useEffect, useState} from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
||||
import styles from "./SettingSurvey.module.css";
|
||||
import TimeEvent from "../TimeEvent/TimeEvent.tsx";
|
||||
import SaveButton from "../SaveButton/SaveButton.tsx";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {getSurveyById} from "../../api/SurveyApi.ts";
|
||||
// import {useParams} from "react-router-dom";
|
||||
// import {getSurveyById, ISurvey} from "../../api/SurveyApi.ts";
|
||||
|
||||
|
||||
const SettingSurvey: React.FC = () => {
|
||||
const [descriptionSurvey, setDescriptionSurvey] = useState('');
|
||||
// const [survey, setSurvey] = useState<ISurvey | null>(null);
|
||||
const [titleSurvey, setTitleSurvey] = useState('');
|
||||
const { surveyId } = useParams<{ surveyId: string }>();
|
||||
// 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]);
|
||||
// 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);
|
||||
// setSurvey(surveyData);
|
||||
// setTitleSurvey(surveyData.title);
|
||||
// setDescriptionSurvey(surveyData.description);
|
||||
// } catch (error) {
|
||||
// console.error('Ошибка:', error);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// fetchData();
|
||||
//
|
||||
// }, [surveyId]);
|
||||
|
||||
return (
|
||||
<div className={styles.settingSurvey}>
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
|
|||
}
|
||||
|
||||
const renderTitle = () => {
|
||||
if ( isCompleteSurveyActive) {
|
||||
if (isSurveyViewPage || isCompleteSurveyActive) {
|
||||
return (
|
||||
<button className={styles.titleSurvey}>
|
||||
<h1>{titleSurvey || 'Название опроса'}</h1>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue