Skip to content

Commit

Permalink
#1/21
Browse files Browse the repository at this point in the history
asdf
  • Loading branch information
yeonh0 committed Jan 21, 2023
1 parent ef3c2f1 commit c9e3f4b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/routes/ReserveCheck.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
import React, { useEffect, useState } from 'react';

import { Link, useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import BackButton from 'components/UI/BackButton';
import { getByDisplayValue } from '@testing-library/react';

import { db, auth } from 'util/firebaseConfig';
import { getDoc, docSnap, doc } from 'firebase/firestore';
import { getDoc, doc } from 'firebase/firestore';

const Reservecheck = () => {
const selectedTime = localStorage.getItem('key');
const navigate = useNavigate();
const [userData, setUserData] = useState(null);

useEffect(() => {
console.log('page load');
const getDB = async () => {
const docRef = doc(db, 'users', auth.currentUser.uid);
const docSnap = await getDoc(docRef);
console.log(docSnap.data());
setUserData(docSnap.data());
};
getDB();
}, []);

// 사용 목적 체크박스 state
const [purpose, setPurpose] = useState('');

// 체크박스 1개만 체크 가능 & 체크한 값을 저장
const checkOnlyOne = (checkThis) => {
const checkboxes = document.getElementsByName('checkbox');
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] !== checkThis) {
checkboxes[i].checked = false;
}
}
if (checkboxes[0].checked === true || checkboxes[1].checked === true) {
if (checkboxes[0].checked === true) {
handlecheck(true);
setPurpose(0);
} else if (checkboxes[1].checked === true) {
handlecheck(true);
setPurpose(1);
}
};

const formSubmitHandler = async (event) => {
try {
event.preventDefault();

console.log('formSubmitHandler 실행');
//홈페이지로 이동
navigate('/');
navigate('/app/reserve/complete/:id');
} catch (error) {
console.log(error.message);
}
Expand Down

0 comments on commit c9e3f4b

Please sign in to comment.