Skip to content
Snippets Groups Projects
Commit 379897e7 authored by Min Dong Hyeun's avatar Min Dong Hyeun
Browse files

[Modify&ADD] MeetingInfoForm

parent 86ada037
No related branches found
No related tags found
No related merge requests found
import { useState, useEffect } from "react";
import HomeMake from "./routes/HomeMake"; import HomeMake from "./routes/HomeMake";
import MeetingInfo from "./routes/MeetingInfo"; import MeetingInfo from "./routes/MeetingInfo";
import LinkPage from "./routes/LinkPage"; import LinkPage from "./routes/LinkPage";
import HomeParticipate from "./routes/HomeParticipate"; import HomeParticipate from "./routes/HomeParticipate";
import UserTimeInfo from "./routes/HomeMake"; import UserTimeInfo from "./routes/UserTimeInfo";
import ResultMake from "./routes/ResultMake"; import ResultMake from "./routes/ResultMake";
import ResultEnd from "./routes/ResultEnd"; import ResultEnd from "./routes/ResultEnd";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
...@@ -12,20 +11,13 @@ function App() { ...@@ -12,20 +11,13 @@ function App() {
return ( return (
<Router> <Router>
<Routes> <Routes>
<Route path="/" element={<HomeMake />}>
{" "}
</Route>
<Route path="/homeparticipate" element={<HomeParticipate />}></Route>
<Route path="/meetinginfo" element={<MeetingInfo />}>
{" "}
</Route>
<Route path="/meetinginfo/linkpage" element={<LinkPage />}></Route> <Route path="/meetinginfo/linkpage" element={<LinkPage />}></Route>
<Route <Route path="/homeparticipate/usertimeinfo" element={<UserTimeInfo />}></Route>
path="/homeparticipate/usertimeinfo" <Route path="/homeparticipate" element={<HomeParticipate />}></Route>
element={<UserTimeInfo />} <Route path="/meetinginfo" element={<MeetingInfo />}></Route>
></Route>
<Route path="/result" element={<ResultMake />}></Route>//결과확인페이지 <Route path="/result" element={<ResultMake />}></Route>//결과확인페이지
<Route path="/resultend" element={<ResultEnd />}></Route>// 투표 종료 <Route path="/resultend" element={<ResultEnd />}></Route>// 투표 종료
<Route path="/" element={<HomeMake />}> </Route>
페이지 페이지
</Routes> </Routes>
</Router> </Router>
......
...@@ -7,7 +7,6 @@ import CalendarMonth from "./CalendarMonth"; ...@@ -7,7 +7,6 @@ import CalendarMonth from "./CalendarMonth";
function Calendar({ onChange }) { function Calendar({ onChange }) {
return ( return (
<div> <div>
<h2>달력</h2>
<CalendarMonth /> <CalendarMonth />
</div> </div>
); );
......
...@@ -87,6 +87,7 @@ function CalendarMonth(){ ...@@ -87,6 +87,7 @@ function CalendarMonth(){
return( return(
<div className="calendar"> <div className="calendar">
<h1>달력</h1>
<MakeHeader nowMonth={nowMonth} prevMonth={prevMonth} nextMonth={nextMonth}></MakeHeader> <MakeHeader nowMonth={nowMonth} prevMonth={prevMonth} nextMonth={nextMonth}></MakeHeader>
<h1>{nowYear}</h1> <h1>{nowYear}</h1>
<table className="calendarTable"> <table className="calendarTable">
......
import { useState, useEffect } from "react"; import { useState } from "react";
import Input from "../components/Input"; import Input from "../components/Input";
import Button from "../components/Button"; import Button from "../components/Button";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
function LinkPageForm() { function LinkPageForm() {
const [random, setRandom] = useState("");
const [link, setLink] = useState(""); const [link, setLink] = useState("");
const navigate = useNavigate(); const navigate = useNavigate();
const generateRandom = () => {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const linkLength = 10;
let randomLink = '';
for (let i = 0; i < linkLength; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
randomLink += characters[randomIndex];
}
setRandom(randomLink);
};
const copyToClipboard = async (link) => { const copyToClipboard = async (link) => {
try { try {
const textToCopy = `localhost:3000/HomeParticipate/${random}`; const textToCopy = `localhost:3000/HomeParticipate`;
await navigator.clipboard.writeText(textToCopy); await navigator.clipboard.writeText(textToCopy);
alert('클립보드에 복사되었습니다'); alert('클립보드에 복사되었습니다');
} catch (err) { } catch (err) {
...@@ -32,17 +19,15 @@ function LinkPageForm() { ...@@ -32,17 +19,15 @@ function LinkPageForm() {
const handleSubmit = (event) => { const handleSubmit = (event) => {
event.preventDefault(); event.preventDefault();
setLink(`/HomeParticipate/${random}`) setLink(`/HomeParticipate`)
navigate(link); navigate(link);
} }
useEffect(() => {
generateRandom();
}, [])
return ( return (
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div> <div>
<Input <Input
value={`localhost:3000/HomeParticipate/${random}`} value={`localhost:3000/HomeParticipate/`}
/> />
<Button <Button
type="button" type="button"
......
export default function MakeHeader(props){ import Button from "./Button";
return(
<div className="header"> export default function MakeHeader({ prevMonth, nextMonth, nowMonth }) {
<h1>{props.nowMonth}</h1> return (
<button onClick={props.prevMonth}>prev</button> <div>
<button onClick={props.nextMonth}>next</button> <h2>
<span className="header">
<Button
type="button"
text="prev"
onClick={prevMonth}
/>
{nowMonth}
<Button
type="button"
text="next"
onClick={nextMonth}
/>
</span>
</h2>
</div> </div>
); );
} }
\ No newline at end of file
...@@ -7,7 +7,9 @@ import { useNavigate } from "react-router-dom"; ...@@ -7,7 +7,9 @@ import { useNavigate } from "react-router-dom";
function MeetingInfoForm() { function MeetingInfoForm() {
const [meetingPurpose, setMeetingPurpose] = useState(""); const [meetingPurpose, setMeetingPurpose] = useState("");
const [number, setNumber] = useState(); const [number, setNumber] = useState();
const [endTime, setEndTime] = useState(""); const [endVote, setEndVote] = useState("");
const [start, setStart] = useState();
const [end, setEnd] = useState();
const toDo = [ const toDo = [
'선택', '선택',
'식사', '식사',
...@@ -29,8 +31,16 @@ function MeetingInfoForm() { ...@@ -29,8 +31,16 @@ function MeetingInfoForm() {
setNumber(event.target.value); setNumber(event.target.value);
} }
const handleVoteEnd = (event) => {
setEndVote(event.target.value);
}
const handleStart = (event) => {
setStart(event.target.value);
}
const handleEnd = (event) => { const handleEnd = (event) => {
setEndTime(event.target.value); setEnd(event.target.value);
} }
const handleSubmit = (event) => { const handleSubmit = (event) => {
...@@ -41,16 +51,36 @@ function MeetingInfoForm() { ...@@ -41,16 +51,36 @@ function MeetingInfoForm() {
return ( return (
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div> <div>
<h1>약속 일정 만들기</h1> <div className="purpose-selector">
<label> <h1>약속 일정 만들기</h1>
목적: <label>
<select value={meetingPurpose} onChange={handleOnChange}> 목적:
{toDo.map((todo, index) => ( <select value={meetingPurpose} onChange={handleOnChange}>
<option key={index}>{todo}</option> {toDo.map((todo, index) => (
))} <option key={index}>{todo}</option>
</select> ))}
</label> </select>
</label>
</div>
<Calendar onChange={handleCalendar} /> <Calendar onChange={handleCalendar} />
<div className="timeStartEnd">
시작:
<Input
type="time"
value={start}
onChange={handleStart}
placeholder="시작"
/>
종료:
<Input
type="time"
value={end}
onChange={handleEnd}
placeholder="종료"
/>
</div>
<Input <Input
type="number" type="number"
value={number} value={number}
...@@ -59,8 +89,8 @@ function MeetingInfoForm() { ...@@ -59,8 +89,8 @@ function MeetingInfoForm() {
/> />
<Input <Input
type="datetime-local" type="datetime-local"
value={endTime} value={endVote}
onChange={handleEnd} onChange={handleVoteEnd}
/> />
<Button <Button
type="submit" type="submit"
......
import HomeParticipateForm from "../components/HomeParticipateForm";
import "../styles/HomeMake.css";
function HomeParticipate(){ function HomeParticipate(){
return( return(
<h1>HomeParticipate</h1> <div className="center-container">
<HomeParticipateForm />
</div>
); );
} }
......
function UserTimeInfo(){ import { useState } from "react";
return( import Button from "../components/Button";
<h1>UserTimeInfo</h1> import Calendar from "../components/Calendar"
import "../styles/HomeMake.css"
function UserTimeInfo() {
const [state, setState] = useState(true);
const handleState = () => {
setState((state) => !state);
}
const handleCalendar = (value) => {
console.log('Selected Date:', value);
};
return (
<div className="center-container">
<Button
type="button"
text="가능한 시간"
onClick={handleState}
/>
<Button
type="button"
text="불가능한 시간"
onClick={handleState}
/>
{state ? <Calendar
onChange={handleCalendar}
/> :
<Calendar
onChange={handleCalendar}
/>
}
</div>
); );
} }
......
.calendar-container { .calendar-container {
position: absolute; margin-top: 20px;;
left: 100px;
margin-top: 100px;
width: auto;
} }
table { table {
......
...@@ -6,7 +6,7 @@ body { ...@@ -6,7 +6,7 @@ body {
.center-container { .center-container {
display: flex; display: flex;
justify-content: center; flex-direction: column; /* 세로 방향으로 정렬 */
align-items: center; align-items: center;
height: 100vh; height: 100vh;
} }
...@@ -27,6 +27,22 @@ h1 { ...@@ -27,6 +27,22 @@ h1 {
font-family: "Lato"; font-family: "Lato";
} }
h2 {
display: flex;
align-items: center;
justify-content: space-between;
white-space: nowrap;
margin: 0;
}
.timeStartEnd{
display: flex;
align-items: center;
justify-content: space-between;
white-space: nowrap;
margin: 0;
}
input { input {
width: 100%; width: 100%;
padding: 10px; padding: 10px;
...@@ -51,6 +67,14 @@ button:hover { ...@@ -51,6 +67,14 @@ button:hover {
background-color: #2980b9; background-color: #2980b9;
} }
.header{
display: flex;
gap: 100px;
}
.purpose-selector{
margin : 20px;
}
.calendarTable { .calendarTable {
margin: 0 auto; /* 가운데 정렬을 위해 margin을 auto로 설정합니다. */ margin: 0 auto; /* 가운데 정렬을 위해 margin을 auto로 설정합니다. */
} }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
margin-bottom: 20px; margin-bottom: 20px;
padding: 0; padding: 0;
} }
.calendar { .calendar {
margin-top: 100px; border: 1px solid;
padding : 10px;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment