Skip to content
Snippets Groups Projects
Commit f6f8fac1 authored by 유 채린's avatar 유 채린
Browse files

feat: add createVote disabled button

parent 37f3ba35
Branches
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
import {PageItem} from "./recruit/recruitList";
import InfiniteScrollStyles from './infiniteScroll.module.css'
import {ChannelItem} from "./channel/channelList";
import { json } from 'react-router-dom';
function InfiniteScroll(props){
const [items, setItems] = useState([]);
......@@ -78,17 +77,10 @@ function InfiniteScroll(props){
setIsLoading(true);
try{
const response = '';
if(page==='channels'){
response = await fetch(`/api/${page}?${min}=${minDate}${queryString2}`);
}else{
response = await fetch(`/api/${page}?${min}=${minId}${queryString2}`);
}
const response = await fetch(`/api/${page}?${min}=${minDate}${queryString2}`);
const jsonData = await response.json();
if(page==='channels'){
setMinId(jsonData['minDate']);
setMinDate(jsonData['minDate']);
const newData = jsonData[page];
if (newData.length > 0) {
const components = [];
......@@ -108,6 +100,8 @@ function InfiniteScroll(props){
setItems((prevItem) => [...prevItem, ...components]);
}
}else if(page==='recruits'){
const response = await fetch(`/api/${page}?${min}=${minId}${queryString2}`);
const jsonData = await response.json();
setMinId(jsonData['minId']);
const newData = jsonData[page];
if(newData.length > 0) {
......@@ -118,6 +112,8 @@ function InfiniteScroll(props){
setItems(prevItem => [...prevItem, ...components]);
}
} else{
const response = await fetch(`/api/${page}?${min}=${minId}${queryString2}`);
const jsonData = await response.json();
setMinId(jsonData['minId']);
const newData = jsonData["recruits"];
if(newData.length > 0) {
......
......@@ -36,9 +36,9 @@ function Notice(props){
const sortedNotice = subscribeNotices.sort((a, b) => a.date - b.date);
const noticeComponents = sortedNotice.map((notice) => (
<p className={styles.noticeContent}>
<span className={styles.channel}>{notice.channel}</span>
<span className={styles.date}>{notice.date}</span>
<span className={styles.content}>{notice.title}</span>
<span className={styles.channel}>{notice.channelNickname}</span>
<span className={styles.noticeTitle}>{notice.title}</span>
<span className={styles.content}>{notice.content}</span>
</p>
));
......
......@@ -63,15 +63,11 @@
float: left;
}
.time{
}
.channel{
}
.date{
.noticeTitle{
}
......
import React from 'react';
import createVoteStyles from './createVote.module.css';
function CreateVote({ id, data }){
function CreateVote({ data, time }){
const createVote = async ()=>{
try{
const response = await fetch(`/api/recruits/${id}/times/save`,{
const response = await fetch(`/api/recruits/${data.id}/times/save`,{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
body: JSON.stringify(time),
});
if (response.ok){
......@@ -26,7 +26,11 @@ function CreateVote({ id, data }){
return (
<div>
<div>
{data.vote === 'Before' ?(
<button type='button' className={createVoteStyles.createVote} onClick={createVote}>투표 생성</button>
):(
<button type='button' className={createVoteStyles.endCreateVote} onClick={createVote} disabled>투표 생성</button>
)}
</div>
</div>
......
......@@ -10,3 +10,16 @@
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); /* 그림자 추가 */
transition: background-color 0.3s, color 0.3s, transform 0.3s;
}
.endCreateVote{
width: 90px;
height:35px;
border:none;
border-radius: 5px;
cursor: pointer;
color: white;
background-color:#b5b9c5;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); /* 그림자 추가 */
transition: background-color 0.3s, color 0.3s, transform 0.3s;
}
\ No newline at end of file
......@@ -231,7 +231,7 @@ function TimeInquiry({ isOpen, onClose, data }){
<div className={timeInquiryStyles.voteButton}>
<div className={timeInquiryStyles.createVote}>
<CreateVote id={data.id} data={selectedTimes}/>
<CreateVote data={data} time={selectedTimes}/>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment