Skip to content

Commit

Permalink
Merge pull request #92 from Qfeed-Dev/feature/#84
Browse files Browse the repository at this point in the history
[Feat] 회원가입 추가기능
  • Loading branch information
hamo-o authored Sep 28, 2023
2 parents 0d4a2da + 04a67b6 commit 314fe7a
Show file tree
Hide file tree
Showing 23 changed files with 597 additions and 197 deletions.
13 changes: 9 additions & 4 deletions src/apis/auth/checkSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ export async function checkSignUp(request: NextRequest) {
const url = request.nextUrl.clone();

if (user.name && user.schoolType) {
url.pathname = "/";
return NextResponse.redirect(url);
return NextResponse.next();
} else if (user.name) {
if (url.pathname !== "/auth/organization") {
if (
url.pathname !== "/auth/organization" &&
url.pathname !== "/auth/default"
) {
url.pathname = "/auth/organization";
return NextResponse.redirect(url);
} else return NextResponse.next();
} else {
return NextResponse.next();
if (url.pathname !== "/auth/default") {
url.pathname = "/auth/default";
return NextResponse.redirect(url);
} else return NextResponse.next();
}
}
54 changes: 54 additions & 0 deletions src/apis/school/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import axios from "axios";

const schoolAPI = {
async getSchoolName(word: string) {
const response = await axios.get(
"https://open.neis.go.kr/hub/schoolInfo",
{
params: {
KEY: process.env.NEXT_PUBLIC_SCHOOL_API_KEY,
Type: "json",
pIndex: 1,
pSize: 20,
SCHUL_NM: word
}
}
);
return response.data;
},
async getUnivName(word: string) {
const response = await axios.get(
"https://www.career.go.kr/cnet/openapi/getOpenApi",
{
params: {
apiKey: process.env.NEXT_PUBLIC_UNIV_API_KEY,
svcType: "api",
svcCode: "SCHOOL",
contentType: "json",
gubun: "univ_list",
searchSchulNm: word
}
}
);
return response.data;
},
async getMajorName(word: string) {
const response = await axios.get(
"https://www.career.go.kr/cnet/openapi/getOpenApi",
{
params: {
apiKey: process.env.NEXT_PUBLIC_UNIV_API_KEY,
svcType: "api",
svcCode: "MAJOR",
contentType: "json",
gubun: "univ_list",
univSe: "univ",
searchTitle: word
}
}
);
return response.data;
}
};

export default schoolAPI;
27 changes: 27 additions & 0 deletions src/components/Icon/icons/images/CheckImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const CheckImage = () => {
return (
<svg
width="104"
height="105"
viewBox="0 0 104 105"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle
cx="52"
cy="52.2441"
r="52"
fill="white"
fillOpacity="0.05"
/>
<path
d="M31 52.2441L47.8 67.2441L73 37.2441"
stroke="white"
strokeWidth="7.5"
strokeLinecap="round"
/>
</svg>
);
};

export default CheckImage;
1 change: 1 addition & 0 deletions src/components/Icon/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { default as QFeedImage } from "./images/QFeedImage";
export { default as QFeedImage2 } from "./images/QFeedImage2";
export { default as WaveImage } from "./images/WaveImage";
export { default as FriendImage } from "./images/FriendImage";
export { default as CheckImage } from "./images/CheckImage";

// bottom navigation
export { default as BHome } from "./bottomNavigation/Home";
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/input-fill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Input = styled.input`
width: 80vw;
color: ${colors.light_qwhite};
transform: scale(0.75);
transform: scale(0.85);
transform-origin: left;
`;

Expand Down
4 changes: 2 additions & 2 deletions src/components/inputs/input-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const InputLine = ({ ...props }: InputProps) => {

const InputWrapper = styled.div`
width: 100%;
padding: 1rem 0;
padding: 1rem 0 0.5rem;
margin-bottom: 0.5rem;
display: flex;
Expand All @@ -57,7 +57,7 @@ const Input = styled.input`
width: 80vw;
color: ${colors.light_qwhite};
transform: scale(0.75);
transform: scale(0.85);
transform-origin: left;
`;

Expand Down
56 changes: 56 additions & 0 deletions src/components/selectbox/Options.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"use client";

import styled from "styled-components";
import { useState } from "react";
import Flex from "../common/Flex";
import Text from "../common/Text";
import { colors } from "styles/theme";
import { motion } from "framer-motion";
import { dropdown } from "src/constants/animation";

export interface OptionProps {
options: any;
value?: string;
setState?: any;
defaultValue?: string;
}

const Option = (props: OptionProps) => {
const [open, setOpen] = useState<boolean>(true);
return (
<Flex direction="column" align="start" gap={8}>
<Options
initial="hide"
animate={open ? "show" : "hide"}
variants={dropdown}
>
{props.options.map((option: any) => (
<OptionItem
key={option.value}
onClick={() => {
props.setState(option.name);
setOpen(!open);
}}
>
<Text typo="Subtitle1r">{option.name}</Text>
</OptionItem>
))}
</Options>
</Flex>
);
};

const Options = styled(motion.ul)`
width: 100%;
max-height: 212px;
border-radius: 0 0 10px 10px;
overflow: scroll;
`;

const OptionItem = styled.li`
width: 100%;
padding: 1rem;
background: ${colors.light_gray3};
`;

export default Option;
43 changes: 0 additions & 43 deletions src/components/sign-up/elementary-school.tsx

This file was deleted.

43 changes: 0 additions & 43 deletions src/components/sign-up/middle-high-school.tsx

This file was deleted.

66 changes: 0 additions & 66 deletions src/components/sign-up/university.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/common/useInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const useInput = (initialState?: string) => {
setValue(event.target.value);
}
};
return { value, handleChangeInput, reset };
return { value, handleChangeInput, setValue, reset };
};
31 changes: 31 additions & 0 deletions src/hooks/school/useGetMajorQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
import schoolAPI from "src/apis/school";

const useGetMajorQuery = (word: string) => {
// const { data, fetchNextPage, hasNextPage, isFetched } = useInfiniteQuery(
// ["school"],
// ({ pageParam = 0 }) => getUserQuestions(id, qtype, pageParam, 10),
// {
// getNextPageParam: (lastPage) => {
// return lastPage.data.count > lastPage.idx + 10
// ? lastPage.idx + 10
// : undefined;
// }
// }
// );

// return { data, fetchNextPage, hasNextPage, isFetched };
const { data, isLoading, refetch } = useQuery(
["major"],
() => schoolAPI.getMajorName(word),
{
onError: (error: any) => {
alert(error);
}
}
);

return { data, isLoading, refetch };
};

export default useGetMajorQuery;
Loading

0 comments on commit 314fe7a

Please sign in to comment.