Skip to content

Commit

Permalink
Merge pull request #44 from Goorm-Lucky7/develop/apis
Browse files Browse the repository at this point in the history
[PR] ๋””ํ…Œ์ผ ๋ฐ ๊ธ€ ์ž‘์„ฑ ํŽ˜์ด์ง€ API ๋งŒ๋“ค๊ธฐ
  • Loading branch information
kangsinbeom authored May 10, 2024
2 parents 0894d9f + 1c40c8b commit 61e9685
Show file tree
Hide file tree
Showing 39 changed files with 298 additions and 243 deletions.
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions k8s/configs/default.conf

This file was deleted.

29 changes: 0 additions & 29 deletions k8s/frontend.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions k8s/ingress.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions k8s/kustomization.yaml

This file was deleted.

59 changes: 0 additions & 59 deletions k8s/nginx.yaml

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@tanstack/react-query-devtools": "^5.32.0",
"axios": "^1.6.8",
"framer-motion": "^11.1.7",
"monaco-editor": "^0.48.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.3",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/apis/authAxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export const getAuthAxios = (accessToken?: string) => {
};

const authAxios = axios.create({
baseURL: 'http://211.206.94.24:9999',
headers: headersOption,
withCredentials: true,
baseURL: 'http://13.124.54.157:8080',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
});

authAxios.interceptors.response.use(async (response) => {
Expand Down
Empty file added src/apis/comment.ts
Empty file.
24 changes: 24 additions & 0 deletions src/apis/post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { PostForm } from '@/types/post';
import { getAuthAxios } from './authAxios';

export const postProblem = async (formData: PostForm) => {
const access = localStorage.getItem('access');
if (!access) {
console.error('Access token is missing or invalid');
throw new Error('Access token is missing or invalid');
}
const authAxios = getAuthAxios(access);
const response = await authAxios.post('/api/post', formData);
return response.data;
};

export const getProblem = async (postId: string) => {
const access = localStorage.getItem('access');
if (!access) {
console.error('Access token is missing or invalid');
throw new Error('Access token is missing or invalid');
}
const authAxios = getAuthAxios(access);
const response = await authAxios.get(`/api/posts/${postId}`);
return response.data as PostForm;
};
28 changes: 28 additions & 0 deletions src/components/detail/commentList/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Comment } from '@/types/comment';
import { CommentItem } from '..';

import * as S from './styles';

const defaultComment = {
commentId: 1,
createdAt: new Date('2024-05-02'),
content:
'asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf',
user: {
nickname: '์•„๋ธŒ๋ผ์นดํƒ€๋ธŒ๋ผ๋งˆ์ด๋งˆ์ด๋งˆ์ด',
profileImage: null,
},
} as Comment;

const CommentList = () => {
const mock = [1, 2, 3, 4, 5, 6, 7, 8, 9];
return (
<S.Container>
{mock.map(() => (
<CommentItem {...defaultComment} />
))}
</S.Container>
);
};

export default CommentList;
10 changes: 10 additions & 0 deletions src/components/detail/commentList/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { layoutMap } from '@/styles/layout';
import styled from '@emotion/styled';

export const Container = styled.div`
display: flex;
flex-direction: column-reverse;
gap: 10px;
padding: 10px;
${layoutMap.scrollbarsNone}
`;
1 change: 1 addition & 0 deletions src/components/detail/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// comment
export { default as CommentItem } from './commentItem';
export { default as CommentList } from './commentList';
16 changes: 16 additions & 0 deletions src/components/loader/circleLoader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { animationMap } from '@/styles/framerMotion';
import { motion } from 'framer-motion';

import * as S from './styles';

const CircleLoader = () => {
return (
<motion.span
css={S.circleStyle}
animate={{ rotate: 360 }}
transition={animationMap.spinTransition}
/>
);
};

export default CircleLoader;
14 changes: 14 additions & 0 deletions src/components/loader/circleLoader/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { css } from '@emotion/react';

export const circleStyle = css`
display: block;
width: 3rem;
height: 3rem;
border: 0.5rem solid #e9e9e9;
border-top: 0.5rem solid #3498db;
border-radius: 50%;
position: absolute;
box-sizing: border-box;
left: 50%;
top: 50%;
`;
2 changes: 1 addition & 1 deletion src/components/loginForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function LoginForm() {
const accessToken = response.accessToken;
localStorage.setItem('access', accessToken);
console.log('๋กœ๊ทธ์ธ ์„ฑ๊ณต:', response);
navigate('/mypage');
navigate(-1);
} catch (error) {
const axiosError = error as AxiosError<{ message: string }>;
console.error('๋กœ๊ทธ์ธ ์—๋Ÿฌ:', error);
Expand Down
4 changes: 2 additions & 2 deletions src/components/post/codeBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CodeEditor, Select, Text } from '@/components/shared';
import { LANGUAGE } from '@/consts/language';
import { LANGUAGE, LanguageValues } from '@/consts/language';

import * as S from './styles';
import useSetFormData from '@/hooks/post/useSetFormData';

const CodeBox = () => {
const { postForm, updatePostForm } = useSetFormData();
const handleChangeSelect = (value: string) => {
const handleChangeSelect = (value: LanguageValues) => {
updatePostForm({ language: value });
};
return (
Expand Down
18 changes: 9 additions & 9 deletions src/components/post/posttestCaseBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const defalutValue = [{ example: '', result: '' }];

const PostTestCaseBox = () => {
const updatePostForm = postFormStore((state) => state.updatePostForm);
const [testCase, setTestCases] = useState<TestCase[]>(defalutValue);
const [testCases, setTestCases] = useState<TestCase[]>(defalutValue);
useEffect(() => {
updatePostForm({ testCase });
}, [testCase, updatePostForm]);
updatePostForm({ testCases });
}, [testCases, updatePostForm]);
const handleChange = ({
index,
event,
Expand All @@ -21,14 +21,14 @@ const PostTestCaseBox = () => {
event: ChangeEvent<HTMLTextAreaElement>;
}) => {
const { value, name } = event.target;
const updateTestCase = testCase.map((testCase, i) => {
const updateTestCase = testCases.map((testCases, i) => {
if (index === i) {
return { ...testCase, [name]: value };
return { ...testCases, [name]: value };
}
return testCase;
return testCases;
});
setTestCases(updateTestCase);
updatePostForm({ testCase: updateTestCase });
updatePostForm({ testCases: updateTestCase });
};
return (
<S.TestCaseContainer>
Expand All @@ -42,7 +42,7 @@ const PostTestCaseBox = () => {
<S.ContentBox>
<Text>Example</Text>
<S.TestBlock>
{testCase.map((testCase, index) => (
{testCases.map((testCase, index) => (
<textarea
key={`example-${index}`}
name="example"
Expand All @@ -53,7 +53,7 @@ const PostTestCaseBox = () => {
</S.TestBlock>
<Text>Return</Text>
<S.TestBlock>
{testCase.map((testCase, index) => (
{testCases.map((testCase, index) => (
<textarea
key={`result-${index}`}
name="result"
Expand Down
Loading

0 comments on commit 61e9685

Please sign in to comment.