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";
|
||||
|
||||
const MainComponent: React.FC = () => {
|
||||
const [activePage, setActivePage] = useState('Вопросы');
|
||||
const [activePage, setActivePage] = useState(
|
||||
localStorage.getItem("activePage") || "Вопросы"
|
||||
);
|
||||
|
||||
const handleNavigationClick = (title: string) => {
|
||||
setActivePage(title);
|
||||
localStorage.setItem('activePage', title);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,29 +1,41 @@
|
|||
import React from 'react';
|
||||
import { format } from "@formkit/tempo";
|
||||
import React, { useState } from 'react';
|
||||
import styles from "./TimeEvent.module.css";
|
||||
|
||||
|
||||
interface TimeEventProps {
|
||||
title: string;
|
||||
|
||||
}
|
||||
|
||||
const TimeEvent: React.FC<TimeEventProps> = ({title}) => {
|
||||
const date = new Date();
|
||||
const TimeEvent: React.FC<TimeEventProps> = ({ title }) => {
|
||||
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 (
|
||||
<div className={styles.timeEvent}>
|
||||
<h2 className={styles.title}>{title}</h2>
|
||||
<div className={styles.datetime}>
|
||||
<input
|
||||
type="date"
|
||||
className={styles.inputDate}
|
||||
type='date'
|
||||
placeholder={format(date, "MM/DD/YYYY")}
|
||||
value={date}
|
||||
onChange={(e) => setDate(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type="time"
|
||||
className={styles.inputTime}
|
||||
type='time'
|
||||
placeholder={format(date, "HH:mm")}
|
||||
value={time}
|
||||
onChange={(e) => setTime(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue