Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/src/components/MainContents/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const Contents = styled.div`
padding: 2.375rem 2.5rem;
gap: 3rem;
overflow-x: scroll;
overflow-y: hidden;

.medalWrapper:nth-of-type(1n) .medal {
background-color: #ffd79b;
Expand Down
18 changes: 14 additions & 4 deletions projects/admin/src/PageContainer/CreatePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ import { toast } from 'react-toastify';
const CreatePage = () => {
const [titleValue, setTitleValue] = useState<string>('');
const [detailValue, setDetailValue] = useState<string>('');
const [time, setTime] = useState<number>(0);
const [minute, setMinute] = useState(0);
const [second, setSecond] = useState(0);

const { push } = useRouter();

const { mutate, isSuccess } = usePostMission();

const handleSubmit = () => {
if (titleValue && detailValue && time)
mutate({ title: titleValue, content: detailValue, timeLimit: time });
if (titleValue && detailValue && minute + second !== 0)
mutate({
title: titleValue,
content: detailValue,
timeLimit: minute * 60 + second,
});
else toast.error('작성되지 않은 빈칸이 있습니다.');
};

Expand All @@ -37,7 +42,12 @@ const CreatePage = () => {
<S.PageWrapper>
<div>
<S.TimerWrapper>
<Timer time={time} setTime={setTime} />
<Timer
minute={minute}
setMinute={setMinute}
second={second}
setSecond={setSecond}
/>
</S.TimerWrapper>
<S.Section>[제목]</S.Section>
<TitleInput inputValue={titleValue} setInputValue={setTitleValue} />
Expand Down
21 changes: 15 additions & 6 deletions projects/admin/src/PageContainer/ScoringPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
'use client';

import { useGetScoringList } from 'api/admin';
import * as S from './style';

import { MissionCarousel } from 'admin/components';

const ScoringPage = () => (
<S.PageWrapper>
<S.ScoringText>채점하기</S.ScoringText>
<MissionCarousel />
</S.PageWrapper>
);
const ScoringPage = () => {
const { data } = useGetScoringList();

return (
<S.PageWrapper>
<S.ScoringText>채점하기</S.ScoringText>
{data?.length > 0 ? (
<MissionCarousel />
) : (
<h1>채점할 문제가 없습니다...</h1>
)}
</S.PageWrapper>
);
};

export default ScoringPage;
62 changes: 32 additions & 30 deletions projects/admin/src/components/Timer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
'use client';

import * as S from './style';
import { Dispatch, SetStateAction, useState } from 'react';
import { Dispatch, SetStateAction } from 'react';

interface TimerProps {
time: number;
setTime: Dispatch<SetStateAction<number>>;
minute: number;
setMinute: Dispatch<SetStateAction<number>>;
second: number;
setSecond: Dispatch<SetStateAction<number>>;
}

const Timer: React.FC<TimerProps> = ({ time, setTime }) => {
const [minute, setMinute] = useState(0);
const [second, setSecond] = useState(0);

const onMinuteChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newMinute = parseInt(e.target.value) * 60;
setMinute(newMinute);
setTime(newMinute + second);
};

const onSecondChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newSecond = parseInt(e.target.value);
setSecond(newSecond);
setTime(minute + newSecond);
};

return (
<S.Wrapper>
<S.TimerWrapper>
<S.Input maxLength={2} placeholder='00' onChange={onMinuteChange} />
<S.Collon>:</S.Collon>
<S.Input maxLength={2} placeholder='00' onChange={onSecondChange} />
</S.TimerWrapper>
<S.NoticeText>* 문제는 12:30 ~ 19:30분까지 풀 수 있습니다.</S.NoticeText>
</S.Wrapper>
);
};
const Timer: React.FC<TimerProps> = ({
minute,
setMinute,
second,
setSecond,
}) => (
<S.Wrapper>
<S.TimerWrapper>
<S.Input
maxLength={2}
value={minute}
onChange={(e) =>
e.target.value ? setMinute(parseInt(e.target.value)) : setMinute(0)
}
/>
<S.Collon>:</S.Collon>
<S.Input
maxLength={2}
value={second}
onChange={(e) =>
e.target.value ? setSecond(parseInt(e.target.value)) : setSecond(0)
}
/>
</S.TimerWrapper>
<S.NoticeText>* 문제는 12:30 ~ 19:30분까지 풀 수 있습니다.</S.NoticeText>
</S.Wrapper>
);

export default Timer;
36 changes: 21 additions & 15 deletions projects/client/src/components/ShopModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,27 @@ const ShopModal: React.FC<ShopModalProps> = ({ selectedList }) => {
<XIcon />
</S.CloseButton>
</form>
<S.ModalTitle>선택하신 상품이 맞으십니까?</S.ModalTitle>
<S.ItemList>
{selectedList?.map((selectedItem, index) => (
<ShopModalItem
key={selectedItem.itemId}
data={selectedItem}
count={countList[index]}
calculateCount={calculateCount}
index={index}
/>
))}
</S.ItemList>
<form method='dialog'>
<S.PurchusButton onClick={handleSubmit}>구매하기</S.PurchusButton>
</form>
{selectedList.length > 0 ? (
<>
<S.ModalTitle>선택하신 상품이 맞습니까?</S.ModalTitle>
<S.ItemList>
{selectedList?.map((selectedItem, index) => (
<ShopModalItem
key={selectedItem.itemId}
data={selectedItem}
count={countList[index]}
calculateCount={calculateCount}
index={index}
/>
))}
</S.ItemList>
<form method='dialog'>
<S.PurchusButton onClick={handleSubmit}>구매하기</S.PurchusButton>
</form>
</>
) : (
<S.ModalTitle>선택하신 상품이 없습니다...</S.ModalTitle>
)}
</S.ModalWrapper>
);
};
Expand Down