Skip to content

Commit

Permalink
[#46] Feat: Letter 신청 가능 여부 필드 값 response에서 받아오도록 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
MuseopKim committed Apr 8, 2021
1 parent c7cdb69 commit 5066f26
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/api/letters.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const getLetters = async (status, direction) => {
params
});
const {
data: { letters }
data: { letters, readyToLetter }
} = response;
return letters;
return { letters, readyToLetter };
};

export const getLetterById = async id => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/LetterList/ActionButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDispatch } from "react-redux";
import { changeModalType, openModal } from "../../modules/letterModal";
import { LETTER_MODAL } from "../../constants/types";

const ActionButtons = ({ currentUser }) => {
const ActionButtons = ({ currentUser, data }) => {
const dispatch = useDispatch();
const openCreateModal = () => {
dispatch(openModal());
Expand All @@ -14,7 +14,7 @@ const ActionButtons = ({ currentUser }) => {

return (
<ActionsButtonsBlock>
{currentUser && (
{data && data.readyToLetter && currentUser && (
<CreateButton onClick={openCreateModal}>
<CreateButtonIcon />
<CreateButtonText>신청곡 등록</CreateButtonText>
Expand Down
8 changes: 4 additions & 4 deletions src/components/LetterList/LetterList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Loading from "../Loading/Loading";
import EmptyResult from "../EmptyResult/EmptyResult";

const LetterList = ({
letters,
data,
jwtToken,
currentUser,
loading,
Expand All @@ -17,14 +17,14 @@ const LetterList = ({
<LetterListBlock>
{loading && <Loading position={50} />}
{error && <GlobalErrorHandler error={error} />}
{letters && letters.length === 0 && (
{data && data.letters.length === 0 && (
<EmptyResult
message={"리얼피아노는 신청곡과 여러분의 이야기를 기다립니다."}
opacity={0.3}
/>
)}
{letters &&
letters.map(letter => (
{data &&
data.letters.map(letter => (
<Letter
key={letter.id}
id={letter.id}
Expand Down
9 changes: 3 additions & 6 deletions src/pages/Letters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import ReactHelmet from "../common/ReactHelmet";
import { DIRECTION } from "../modules/pagination";

const Letters = () => {
const { data: letters, status, loading, error } = useSelector(
state => state.letters
);
const { data, status, loading, error } = useSelector(state => state.letters);
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);

const { currentUser, jwtToken } = useSelector(state => state.auth);
const dispatch = useDispatch();

Expand All @@ -38,10 +35,10 @@ const Letters = () => {
<LettersButtonBlock>
<ListTitle status={status} />
<StatusButtons status={status} />
<ActionButtons currentUser={currentUser} />
<ActionButtons currentUser={currentUser} data={data} />
</LettersButtonBlock>
<LetterList
letters={letters}
data={data}
jwtToken={jwtToken}
currentUser={currentUser}
loading={loading}
Expand Down

0 comments on commit 5066f26

Please sign in to comment.