Skip to content

Commit 1c9dced

Browse files
authored
Merge pull request #107 from saseungmin/fix-introduce-apply-status
[Fix] Errors that occur when recruitment is due
2 parents 98dd903 + 059115e commit 1c9dced

File tree

4 files changed

+69
-44
lines changed

4 files changed

+69
-44
lines changed

src/components/introduce/ApplicantViewButton.test.jsx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('ApplicantViewButton', () => {
118118
it('renders recruitment closed text', () => {
119119
const { container } = renderApplicantViewButton({ group, time, user: 'user1' });
120120

121-
expect(container).toHaveTextContent('모집 마감');
121+
expect(container).toHaveTextContent('승인 거절');
122122
});
123123
});
124124

@@ -137,43 +137,11 @@ describe('ApplicantViewButton', () => {
137137
};
138138

139139
it('renders recruitment closed text', () => {
140-
const { container } = renderApplicantViewButton({ group, time, user: 'user3' });
140+
const { container } = renderApplicantViewButton({ group, time, user: 'user4' });
141141

142142
expect(container).toHaveTextContent('모집 마감');
143143
});
144144
});
145-
146-
describe('When the user clicks the Apply button without logging in', () => {
147-
const nowDate = new Date();
148-
const tomorrow = nowDate.setDate(nowDate.getDate() + 1);
149-
150-
const group = {
151-
...STUDY_GROUP,
152-
applyEndDate: tomorrow,
153-
participants: [
154-
{ id: 'user2' },
155-
],
156-
personnel: 2,
157-
};
158-
159-
it('renders modal window appears and application failure message', () => {
160-
const { container, getByText } = renderApplicantViewButton({ group, time });
161-
162-
const button = getByText('신청하기');
163-
164-
expect(button).not.toBeNull();
165-
166-
fireEvent.click(button);
167-
168-
expect(handleApply).not.toBeCalled();
169-
170-
expect(container).toHaveTextContent('로그인 후 신청 가능합니다.');
171-
172-
fireEvent.click(getByText('확인'));
173-
174-
expect(container).not.toHaveTextContent('로그인 후 신청 가능합니다.');
175-
});
176-
});
177145
});
178146

179147
context('When the study recruitment is opened', () => {
@@ -248,6 +216,38 @@ describe('ApplicantViewButton', () => {
248216
});
249217
});
250218
});
219+
220+
describe('When the user clicks the Apply button without logging in', () => {
221+
const nowDate = new Date();
222+
const tomorrow = nowDate.setDate(nowDate.getDate() + 1);
223+
224+
const group = {
225+
...STUDY_GROUP,
226+
applyEndDate: tomorrow,
227+
participants: [
228+
{ id: 'user2' },
229+
],
230+
personnel: 2,
231+
};
232+
233+
it('renders modal window appears and application failure message', () => {
234+
const { container, getByText } = renderApplicantViewButton({ group, time });
235+
236+
const button = getByText('신청하기');
237+
238+
expect(button).not.toBeNull();
239+
240+
fireEvent.click(button);
241+
242+
expect(handleApply).not.toBeCalled();
243+
244+
expect(container).toHaveTextContent('로그인 후 신청 가능합니다.');
245+
246+
fireEvent.click(getByText('확인'));
247+
248+
expect(container).not.toHaveTextContent('로그인 후 신청 가능합니다.');
249+
});
250+
});
251251
});
252252
});
253253
});

src/components/introduce/ApplyStatusButton.jsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ApproveStatus from '../../styles/ApproveStatus';
44

55
import StyledApplyStatusButton from '../../styles/StyledApplyStatusButton';
66

7-
const checkConfirm = (confirm) => confirm === true;
7+
const checkConfirm = (user) => user.confirm && user.confirm === true;
88

99
const ApplyStatusButton = ({
1010
timeStatus, onApply, userStatus, onCancel,
@@ -21,7 +21,18 @@ const ApplyStatusButton = ({
2121
);
2222
}
2323

24-
if (!timeStatus && !checkConfirm(userStatus.confirm)) {
24+
if (timeStatus && !userStatus) {
25+
return (
26+
<StyledApplyStatusButton
27+
type="button"
28+
className="deadline"
29+
>
30+
모집 마감
31+
</StyledApplyStatusButton>
32+
);
33+
}
34+
35+
if (!timeStatus && !checkConfirm(userStatus)) {
2536
return (
2637
<>
2738
<ApproveStatus load>
@@ -38,7 +49,7 @@ const ApplyStatusButton = ({
3849
);
3950
}
4051

41-
if (!timeStatus && checkConfirm(userStatus.confirm)) {
52+
if (!timeStatus && checkConfirm(userStatus)) {
4253
return (
4354
<>
4455
<ApproveStatus approve>
@@ -55,23 +66,23 @@ const ApplyStatusButton = ({
5566
);
5667
}
5768

58-
if (timeStatus && checkConfirm(userStatus.confirm)) {
69+
if (timeStatus && !checkConfirm(userStatus)) {
5970
return (
6071
<StyledApplyStatusButton
6172
type="button"
62-
className="apply-complete"
73+
className="apply-reject"
6374
>
64-
신청 완료
75+
승인 거절
6576
</StyledApplyStatusButton>
6677
);
6778
}
6879

6980
return (
7081
<StyledApplyStatusButton
7182
type="button"
72-
className="deadline"
83+
className="apply-complete"
7384
>
74-
모집 마감
85+
신청 완료
7586
</StyledApplyStatusButton>
7687
);
7788
};

src/components/introduce/ApplyStatusButton.test.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('ApplyStatusButton', () => {
4343
});
4444

4545
context('When the study application is completed', () => {
46-
it('renders application completed', () => {
46+
it('renders "application completed"', () => {
4747
const { container } = renderApplyStatusButton({
4848
userStatus: { confirm: true },
4949
timeStatus: true,
@@ -54,12 +54,20 @@ describe('ApplyStatusButton', () => {
5454
});
5555

5656
context('When the study application deadline', () => {
57-
it('renders application deadline', () => {
57+
it('renders "Rejection of approval"', () => {
5858
const { container } = renderApplyStatusButton({
5959
userStatus: { confirm: false },
6060
timeStatus: true,
6161
});
6262

63+
expect(container).toHaveTextContent('승인 거절');
64+
});
65+
66+
it('renders "Application deadline"', () => {
67+
const { container } = renderApplyStatusButton({
68+
timeStatus: true,
69+
});
70+
6371
expect(container).toHaveTextContent('모집 마감');
6472
});
6573
});

src/styles/StyledApplyStatusButton.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ const StyledApplyStatusButtonWrapper = styled.button`
3232
}
3333
}
3434
35+
&.apply-reject {
36+
background: ${palette.gray[1]};
37+
border: 2px solid ${palette.warn[0]};
38+
color: ${palette.warn[1]};
39+
}
40+
3541
&.apply-complete {
3642
background: ${palette.gray[1]};
3743
border: 2px solid #a5d8ff;

0 commit comments

Comments
 (0)