Skip to content

Commit

Permalink
Merge pull request #100 from JNU-econovation/FE
Browse files Browse the repository at this point in the history
fix: 슬랙 로그인 페이지 경로 수정
  • Loading branch information
mlnwns authored Jul 22, 2024
2 parents 65d9446 + 08b7e46 commit ea2399d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 34 deletions.
56 changes: 39 additions & 17 deletions FE/error/src/components/scheduleCreate/CreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ const CreateModal = ({
setEventInfo("");
setEventPlace("");
setEventMemo("");
setNewStartDate(selectedDate + "T" + eventStartTime);
setNewEndDate(selectedDate + "T" + eventEndTime);
setEventStartTime("00:00"); // 초기화 추가
setEventEndTime("00:00"); // 초기화 추가
setNewStartDate(selectedDate + "T00:00"); // 수정
setNewEndDate(selectedDate + "T00:00"); // 수정

setSelectedFilter(null);
setActiveDropdown(null);
}
}, [isOpen, selectedDate]);

const isFilterSelected = () => {
return selectedFilter && selectedFilter.category && selectedFilter.filter;
};

const handleTitleChange = (event) => {
setEventName(event.target.value);
};
Expand Down Expand Up @@ -72,23 +79,25 @@ const CreateModal = ({
};

const handleStartTimeSelect = (time) => {
const startDateString = `${StartDate}T${time}`;
const endDateString = `${EndDate}T${eventEndTime}`;

setEventStartTime(time);
setNewStartDate(startDateString);
setNewStartDate(`${StartDate}T${time}`);

if (compareAsc(parseISO(startDateString), parseISO(endDateString)) > 0) {
// 시작 시간이 종료 시간보다 늦을 경우, 종료 시간을 시작 시간과 같게 설정
if (StartDate === EndDate && time > eventEndTime) {
setEventEndTime(time);
setNewEndDate(startDateString);
setNewEndDate(`${EndDate}T${time}`);
}
};

const handleEndTimeSelect = (time) => {
let updatedEndDate = addDays(new Date(EndDate), 1);
const newEndDate = `${format(updatedEndDate, "yyyy-MM-dd")}T${time}`;
if (StartDate === EndDate && time < eventStartTime) {
// 종료 시간이 시작 시간보다 이를 경우, 시작 시간을 종료 시간과 같게 설정
setEventStartTime(time);
setNewStartDate(`${StartDate}T${time}`);
}

setEventEndTime(time);
setNewEndDate(newEndDate);
setNewEndDate(`${EndDate}T${time}`);
};

const handleMemoChange = (e) => {
Expand Down Expand Up @@ -136,18 +145,21 @@ const CreateModal = ({
}

const saveData = () => {
if (!eventName || !isFilterSelected()) {
return; // 추가적인 안전장치
}

const data = {
eventName: eventName,
eventStartDate: eventStartDate,
eventEndDate: eventEndDate,
eventPlace: eventPlace,
eventInfo: eventMemo,
eventCategory: {
econo: selectedFilter.econo,
group: selectedFilter.group,
personal: selectedFilter.personal,
[selectedFilter.category]: selectedFilter.filter,
},
};

axios.post("/api/calendar", data).then((res) => {
createDate(
eventName,
Expand Down Expand Up @@ -266,9 +278,16 @@ const CreateModal = ({
/>
</DateRow>
<DateRow>
<TimeSelect onTimeSelect={handleStartTimeSelect} />
<TimeSelect
onTimeSelect={handleStartTimeSelect}
currentTime={eventStartTime}
/>
부터
<TimeSelect onTimeSelect={handleEndTimeSelect} />
<TimeSelect
onTimeSelect={handleEndTimeSelect}
currentTime={eventEndTime}
minTime={StartDate === EndDate ? eventStartTime : undefined}
/>
까지
</DateRow>
</DateTimeContainer>
Expand All @@ -283,7 +302,10 @@ const CreateModal = ({
<ReactQuill placeholder={"설명 추가"} onChange={handleMemoChange} />
</EditorBox>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
<SaveButton onClick={saveData} disabled={!eventName}>
<SaveButton
onClick={saveData}
disabled={!eventName || !isFilterSelected()}
>
저장
</SaveButton>
</div>
Expand Down
14 changes: 8 additions & 6 deletions FE/error/src/pages/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const LoginPage = () => {
const response = await axios.post(
`https://error.econo-calendar.com:8080/api/auth/login/slack?type=slack&code=${authCode}&redirect_uri=https://econo-calendar.com/login`
);
if (response.data.success) {
localStorage.setItem("slackToken", response.data.token);

if (response.data.data.code === "201") {
localStorage.setItem("slackToken", response.data.data.accessToken);
navigate("/");
} else {
setError(response.data.message || "Login failed");
console.error("Login failed:", response.data);
setError(response.data.data.message || "Login failed");
console.log(response.data.data.code);
console.error("Login failed:", response.data.data);
}
} catch (error) {
setError("Authentication failed. Please try again.");
Expand All @@ -44,9 +46,9 @@ const LoginPage = () => {
};

const handleOnLogin = () => {
const slackAuthUrl = `https://econovation-2018.slack.com/oauth?client_id=437291124342.7141431332214&scope=incoming-webhook&user_scope=&redirect_uri=${encodeURIComponent(
const slackAuthUrl = `https://econovation-2018.slack.com/oauth?client_id=437291124342.7141431332214&scope=chat%3Awrite%2Cchat%3Awrite.customize%2Cchat%3Awrite.public%2Cemoji%3Aread%2Cfiles%3Awrite%2Cincoming-webhook&user_scope=chat%3Awrite%2Cusers.profile%3Aread&redirect_uri=${encodeURIComponent(
redirectUri
)}&state=&granular_bot_scope=0&single_channel=0&install_redirect=&tracked=1&team=`;
)}&state=&granular_bot_scope=1&single_channel=0&install_redirect=&tracked=1&team=`;
window.location.href = slackAuthUrl;
};

Expand Down
22 changes: 11 additions & 11 deletions FE/error/src/utils/TimeSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ for (let i = 0; i < 24; i++) {
hour.push(op);
}

const TimeSelect = ({ onTimeSelect }) => {
const [timeValue, setTimeValue] = useState("");
const TimeSelect = ({ onTimeSelect, currentTime, minTime }) => {
const handleChange = (option) => {
setTimeValue(option.value);
if (onTimeSelect) {
onTimeSelect(option.value);
}
};

const filteredHours = minTime
? hour.filter((option) => option.value >= minTime)
: hour;

return (
<>
<Select
value={hour.find((option) => option.value === timeValue)}
onChange={handleChange}
placeholder="00시 00분"
options={hour}
/>
</>
<Select
value={hour.find((option) => option.value === currentTime)}
onChange={handleChange}
placeholder="00시 00분"
options={filteredHours}
/>
);
};

Expand Down

0 comments on commit ea2399d

Please sign in to comment.