This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useContext } from 'react'; | |
import { useNavigate } from 'react-router-dom'; | |
import { userContext } from '../App'; | |
function useCheckLogin() { | |
const navigate = useNavigate(); | |
const { isLoggedIn } = useContext(userContext); | |
useEffect(() => { | |
if (!isLoggedIn) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useContext } from 'react'; | |
import { useNavigate } from 'react-router-dom'; | |
import { userContext } from '../App'; | |
import { postFetch } from './API'; | |
import { checkPassword } from './checkPassword'; | |
function useLoginLogic(initialInputs, url, alertMsg, key1, key2, key3) { | |
const navigate = useNavigate(); | |
const [inputs, setInputs] = useState(initialInputs); | |
const { setIsLoggedIn, setTokens } = useContext(userContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const postFetch = async (url, newData, jwt) => { | |
try { | |
const res = await fetch(url, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: jwt, | |
withCredentials: true | |
}, | |
body: JSON.stringify(newData) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const checkPassword = (str) => { | |
const regexp = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/; | |
const result = regexp.test(str); | |
if (!result) { | |
alert( | |
'Passwords must contain at least eight characters, including at least 1 letter and 1 number.' | |
); | |
} | |
return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aclean = (arr) => { | |
const obj = {}; | |
for (let word of arr) { | |
// ear, are, era을 알파벳 순으로 정렬을 해서 aer로 만들어준 다음 sorted 변수에 담는다. | |
const sorted = word.toLowerCase().split("").sort().join(""); | |
// 정렬된 aer과 원래의 단어를 key-value로 객체에 담는다. | |
obj[sorted] = word; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// grid item component | |
const Container = styled.article` | |
grid-row: ${(props) => (props.main ? "span 2" : "span 1")}; | |
grid-column: ${(props) => (props.main ? "span 6" : "span 3")}; | |
@media screen and (max-width: 1024px) { | |
grid-column: ${(props) => (props.main ? "span 12" : "span 6")}; | |
} | |
@media screen and (max-width: 720px) { | |
grid-column: span 12; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// grid container component | |
const Section = styled.section` | |
padding: 1rem 0; | |
display: grid; | |
grid-template-columns: repeat(12, 1fr); | |
grid-template-rows: repeat(2, 1fr); | |
gap: 1.5rem; | |
@media screen and (max-width: 1024px) { | |
grid-template-rows: repeat(4, 1fr); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container { | |
padding: 1rem 0; | |
display: grid; | |
grid-template-columns: repeat(12, 1fr); | |
grid-template-rows: repeat(2, 1fr); | |
gap: 1.5rem; | |
} | |
/* 태블릿 분기 */ | |
@media screen and (max-width: 1024px) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container { | |
padding: 1rem 0; | |
display: grid; | |
grid-template-columns: repeat(12, 1fr); | |
grid-template-rows: repeat(2, 1fr); | |
gap: 1.5rem; | |
} | |
.mainItem { | |
grid-row: span 2; |