refactor settings
This commit is contained in:
parent
e9bfc9e554
commit
457d895042
3 changed files with 27 additions and 12 deletions
|
|
@ -5,10 +5,13 @@ import Survey from "../Survey/Survey.tsx";
|
||||||
import SettingSurvey from "../SettingSurvey/SettingSurvey.tsx";
|
import SettingSurvey from "../SettingSurvey/SettingSurvey.tsx";
|
||||||
|
|
||||||
const MainComponent: React.FC = () => {
|
const MainComponent: React.FC = () => {
|
||||||
const [activePage, setActivePage] = useState('Вопросы');
|
const [activePage, setActivePage] = useState(
|
||||||
|
localStorage.getItem("activePage") || "Вопросы"
|
||||||
|
);
|
||||||
|
|
||||||
const handleNavigationClick = (title: string) => {
|
const handleNavigationClick = (title: string) => {
|
||||||
setActivePage(title);
|
setActivePage(title);
|
||||||
|
localStorage.setItem('activePage', title);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,41 @@
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { format } from "@formkit/tempo";
|
|
||||||
import styles from "./TimeEvent.module.css";
|
import styles from "./TimeEvent.module.css";
|
||||||
|
|
||||||
|
|
||||||
interface TimeEventProps {
|
interface TimeEventProps {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimeEvent: React.FC<TimeEventProps> = ({ title }) => {
|
const TimeEvent: React.FC<TimeEventProps> = ({ title }) => {
|
||||||
const date = new Date();
|
const [date, setDate] = useState<string>(() => {
|
||||||
|
const now = new Date();
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(now.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const [time, setTime] = useState<string>(() => {
|
||||||
|
const now = new Date();
|
||||||
|
const hours = String(now.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
return `${hours}:${minutes}`;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.timeEvent}>
|
<div className={styles.timeEvent}>
|
||||||
<h2 className={styles.title}>{title}</h2>
|
<h2 className={styles.title}>{title}</h2>
|
||||||
<div className={styles.datetime}>
|
<div className={styles.datetime}>
|
||||||
<input
|
<input
|
||||||
|
type="date"
|
||||||
className={styles.inputDate}
|
className={styles.inputDate}
|
||||||
type='date'
|
value={date}
|
||||||
placeholder={format(date, "MM/DD/YYYY")}
|
onChange={(e) => setDate(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
|
type="time"
|
||||||
className={styles.inputTime}
|
className={styles.inputTime}
|
||||||
type='time'
|
value={time}
|
||||||
placeholder={format(date, "HH:mm")}
|
onChange={(e) => setTime(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue