Skip to content

Commit

Permalink
Merge pull request #119 from SW13-Monstera/dev
Browse files Browse the repository at this point in the history
Merge into main
  • Loading branch information
Kim-Hyunjo authored Jan 21, 2024
2 parents e699f92 + 839e7d6 commit 26373cd
Show file tree
Hide file tree
Showing 58 changed files with 3,114 additions and 135 deletions.
1,980 changes: 1,892 additions & 88 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "npm run build --workspace=service",
"build:admin": "npm run build --workspace=admin",
"lint": "eslint 'packages/**/src/**/*.{ts,tsx,js,jsx}'",
"lint-diff": "eslint $(git diff --name-only --diff-filter=duxb origin/$BASE origin/$HEAD | grep -E '\\.((j|t)sx?)$' | xargs)"
"lint-diff": "eslint $(git diff --name-only --diff-filter=duxb origin/$BASE origin/$HEAD | grep -E '\\.((j|t)sx?)$' | xargs)",
"test": "npm run test --workspace=service"
},
"workspaces": [
"packages/service",
Expand Down
6 changes: 3 additions & 3 deletions packages/admin/src/api/apiClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import { getUserInfo } from 'auth/utils/userInfo';
import { parseJwt } from 'auth/utils/parseJwt';
import { AUTHORIZTION, BEARER_TOKEN } from 'auth/constants';
import { AUTHORIZATION, BEARER_TOKEN } from 'auth/constants';
import { authApiWrapper } from './wrapper/auth/authApiWrapper';

const apiClient = axios.create({
Expand All @@ -13,7 +13,7 @@ const userInfo = getUserInfo();
if (userInfo) {
const token: string | null | undefined = userInfo.accessToken;
if (typeof token === 'string') {
apiClient.defaults.headers.common[AUTHORIZTION] = BEARER_TOKEN(token);
apiClient.defaults.headers.common[AUTHORIZATION] = BEARER_TOKEN(token);
}
}

Expand All @@ -30,7 +30,7 @@ apiClient.interceptors.response.use(
const jwt = parseJwt(userInfo.accessToken);
if (jwt?.exp && Date.now() >= jwt.exp * 1000) {
authApiWrapper.refresh()?.then((newAccessToken) => {
originalRequest.headers[AUTHORIZTION] = BEARER_TOKEN(newAccessToken);
originalRequest.headers[AUTHORIZATION] = BEARER_TOKEN(newAccessToken);
return apiClient(originalRequest);
});
}
Expand Down
6 changes: 3 additions & 3 deletions packages/admin/src/api/wrapper/auth/authApiWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { setLogout } from './../../../utils/index';
import { getUserInfo, setUserInfo } from 'auth/utils/userInfo';
import apiClient from '../../apiClient';
import { API_URL } from '../../../constants/apiUrl';
import { AUTHORIZTION, BEARER_TOKEN, ROLES } from 'auth/constants';
import { AUTHORIZATION, BEARER_TOKEN, ROLES } from 'auth/constants';

interface ILoginRequest {
email: string;
Expand All @@ -18,7 +18,7 @@ export const authApiWrapper = {
alert('권한 없음');
throw new Error('권한 없음');
}
apiClient.defaults.headers.common[AUTHORIZTION] = BEARER_TOKEN(res.data.accessToken);
apiClient.defaults.headers.common[AUTHORIZATION] = BEARER_TOKEN(res.data.accessToken);
return res.data;
},
(err) => {
Expand All @@ -40,7 +40,7 @@ export const authApiWrapper = {
.then(
(res: { data: { accessToken: string } }) => {
const newAccessToken = res.data.accessToken;
apiClient.defaults.headers.common[AUTHORIZTION] = BEARER_TOKEN(newAccessToken);
apiClient.defaults.headers.common[AUTHORIZATION] = BEARER_TOKEN(newAccessToken);
setUserInfo({ ...userInfo, accessToken: newAccessToken });
return res.data.accessToken;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export const LongProblemEditPage = () => {
standardAnswers:
Array.from(
document.getElementsByClassName('standard-answer') as HTMLCollectionOf<HTMLInputElement>,
).map((e) => e.value) || [],
)
.filter((e) => !e.ariaHidden)
.map((e) => e.value) || [],
tags: tagState.filter((tag) => tag.isChecked).map((e) => e.id),
gradingStandards: [
...keywordStandardState.map(({ content, score, type }) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/admin/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import apiClient from '../api/apiClient';
import { AUTHORIZTION, BEARER_TOKEN, USER_INFO } from 'auth/constants';
import { AUTHORIZATION, BEARER_TOKEN, USER_INFO } from 'auth/constants';

export const roundToSecondDigit = (num: number) => Math.round(num * 100) / 100;

Expand All @@ -19,7 +19,7 @@ export const isNumeric = (value: any) => {

export function setLogout() {
localStorage.removeItem(USER_INFO);
delete apiClient.defaults.headers.common[AUTHORIZTION];
delete apiClient.defaults.headers.common[AUTHORIZATION];
}

export const setTokenHeader = () => {
Expand All @@ -29,7 +29,7 @@ export const setTokenHeader = () => {
const userInfo = JSON.parse(userInfoString);
const token: string | null | undefined = userInfo.accessToken;
if (typeof token === 'string') {
apiClient.defaults.headers.common[AUTHORIZTION] = BEARER_TOKEN(token);
apiClient.defaults.headers.common[AUTHORIZATION] = BEARER_TOKEN(token);
}
}
} catch (e) {
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const USER_INFO = "userInfo";
export const AUTHORIZTION = "Authorization";
export const USER_INFO = 'userInfo';
export const AUTHORIZATION = 'Authorization';
export const BEARER_TOKEN = (token: string) => `Bearer ${token}`;
export const ROLES = {
ROLE_ADMIN: "ROLE_ADMIN",
ROLE_USER: "ROLE_USER",
ROLE_ADMIN: 'ROLE_ADMIN',
ROLE_USER: 'ROLE_USER',
} as const;
2 changes: 2 additions & 0 deletions packages/auth/utils/userInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export const getUserInfo = (): IUserInfo | null => {
export const removeUserInfo = () => {
localStorage.removeItem(USER_INFO);
};

export const isLogin = () => !!getUserInfo()?.id;
4 changes: 3 additions & 1 deletion packages/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "vite --mode development --port 3123",
"build": "tsc && vite build --mode production",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,6 +45,7 @@
"rehype-highlight": "^5.0.2",
"remark-gfm": "^3.0.1",
"vite-plugin-svgr": "^2.2.0",
"vitest": "^1.2.0",
"zustand": "^4.0.0-rc.1"
},
"devDependencies": {
Expand Down
17 changes: 17 additions & 0 deletions packages/service/src/Component/Button/FloatingButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IButton } from '../../../types/button';
import { floatingButtonStyle } from './style.css';

const FloatingButton = (props: IButton) => {
return (
<button
type='button'
className={floatingButtonStyle}
onClick={props.onClick}
onMouseOver={props.onMouseOver}
onMouseOut={props.onMouseOut}
>
{props.children}
</button>
);
};
export default FloatingButton;
27 changes: 27 additions & 0 deletions packages/service/src/Component/Button/FloatingButton/style.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { style } from '@vanilla-extract/css';
import { COLOR } from '../../../constants/color';
import { spreadBoxShadow } from '../../../styles/keyframe.css';
import { themeColors } from '../../../styles/theme.css';

export const floatingButtonStyle = style({
position: 'fixed',
bottom: '20px',
right: '20px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '56px',
height: '56px',
cursor: 'pointer',
borderRadius: '24px',
background: `linear-gradient(${COLOR.PRIMARY} 0%, rgba(42,90,243) 100%)`,
color: COLOR.BACKGROUND.ALICE_BLUE,
fontSize: '2rem',
boxShadow: `0px 0px 4px ${themeColors.shadow[1]}`,
animation: spreadBoxShadow,
zIndex: '10',

':hover': {
boxShadow: `4px 8px 24px ${themeColors.shadow[1]}`,
},
});
10 changes: 10 additions & 0 deletions packages/service/src/Component/Button/TextButton/style.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ export const textButtonSizeStyle = styleVariants({
borderRadius: '8px',
},
],
xsmall: [
{
width: '3.5rem',
height: '1.5rem',
fontWeight: '500',
fontSize: '0.75rem',
lineHeight: '1rem',
borderRadius: '4px',
},
],
});

export const unactivatedStyle = style({
Expand Down
4 changes: 2 additions & 2 deletions packages/service/src/Component/Utils/DefaultSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const DefaultSelect = ({
},
})}
defaultValue={defaultValue}
onChange={(e: MultiValue<IOption> | SingleValue<IOption>) => {
onChange={(e) => {
onChange(e);
if (isMulti) setSelectedOptions(e);
}}
Expand Down Expand Up @@ -85,7 +85,7 @@ export const DefaultSelect = ({
neutral90: themeColors.text[5],
},
})}
onChange={(e: MultiValue<IOption> | SingleValue<IOption>) => {
onChange={(e) => {
onChange(e);
if (isMulti) setSelectedOptions(e);
}}
Expand Down
Loading

1 comment on commit 26373cd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.