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
6 changes: 3 additions & 3 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions src/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { MemoryRouter } from 'react-router-dom';
import { render } from '@testing-library/react';

import App from './App';

import STUDY_GROUPS from '../fixtures/study-groups';
import STUDY_GROUP from '../fixtures/study-group';

jest.mock('react-redux');
Expand All @@ -20,7 +22,7 @@ describe('App', () => {
useDispatch.mockImplementation(() => dispatch);

useSelector.mockImplementation((selector) => selector({
groups: [],
groups: STUDY_GROUPS,
group: STUDY_GROUP,
}));
});
Expand All @@ -43,7 +45,7 @@ describe('App', () => {
it('renders the study introduce page', () => {
const { container } = renderApp({ path: '/introduce/1' });

expect(container).toHaveTextContent('์Šคํ„ฐ๋”” ์†Œ๊ฐœ');
expect(container).toHaveTextContent('์Šคํ„ฐ๋””๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.2');
});
});
});
114 changes: 110 additions & 4 deletions src/components/introduce/StudyIntroduceForm.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,122 @@
import React from 'react';

import styled from '@emotion/styled';

import Tags from '../common/Tags';
import palette from '../../styles/palette';

const StudyIntroduceWrapper = styled.div`
margin-top: 6em;
`;

const IntroduceHeaderWrapper = styled.div`
border-bottom: 2px solid ${palette.gray[4]};
padding-bottom: 1.5rem;
margin-bottom: 2rem;
display: flex;
justify-content: space-between;
h1 {
font-size: 2.3rem;
line-height: 1.5;
margin: 0;
}
// TODO: ์ถ”ํ›„ ๊ณตํ†ต ๋ฒ„ํŠผ style component๋กœ ๋ณ€๊ฒฝ
button {
display: inline-flex;
align-items: center;
margin: .5rem 0 .5rem 0;
padding: 0.25rem 5rem;
font-size: 1.5em;
line-height: 0;
font-family: 'Gamja Flower', cursive;
border-radius: 0.4rem;
border: none;
background: ${palette.teal[5]};
color: white;
&:hover{
background: ${palette.teal[4]};
}
Comment on lines +24 to +38
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • ๋ฒ„ํŠผ์€ ๊ณตํ†ต์œผ๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ (TODO)

}
`;

const IntroduceReferenceWrapper = styled.div`
display: flex;
padding: 1rem;
border-radius: 0.75rem;
background-color: ${palette.gray[1]};
margin-bottom: 1.5rem;
font-size: 1.1rem;
label {
line-height: 3rem;
font-weight: bold;
margin-right: .7rem;
}
`;

const ModeratorWrapper = styled.div`
margin-bottom: 1.5rem;
font-size: 1.2rem;
font-weight: bold;
color: ${palette.gray[6]};
`;

const IntroduceReference = styled.div`
padding-left: 50px;
padding-right: 50px;
border-right: 0.1rem solid ${palette.gray[3]};
`;

const IntroduceContentTitle = styled.div`
padding: 7px 2rem 7px 2rem;
width: 17%;
text-align: center;
font-weight: bold;
margin-bottom: 0;
margin-top: 1rem;
border-bottom: 2px solid ${palette.violet[3]};
font-size: 1.4rem;
`;

const StudyIntroduceWrapper = styled.div``;
const IntroduceContent = styled.div`
position: relative;
margin-top: 2rem;
border: 0.0625rem solid ${palette.gray[3]};
border-radius: 0.75rem;
padding: 1.5rem;
`;

const StudyIntroduceForm = ({ group }) => {
const { title, contents, tags } = group;
const {
title, contents, tags, moderatorId, personnel, participants, applyEndDate,
} = group;
return (
<StudyIntroduceWrapper>
<h2>{title}</h2>
<p>{contents}</p>
<IntroduceHeaderWrapper>
<h1>{title}</h1>
<button type="button">์‹ ์ฒญํ•˜๊ธฐ</button>
</IntroduceHeaderWrapper>
<ModeratorWrapper>
{`๐Ÿ™‹โ€โ™‚๏ธ ${moderatorId}`}
</ModeratorWrapper>
<IntroduceReferenceWrapper>
<IntroduceReference>
<label htmlFor="application-status">์‹ ์ฒญ ํ˜„ํ™ฉ :</label>
<span id="application-status">
{`${participants.length} / ${personnel}`}
</span>
</IntroduceReference>
<IntroduceReference>
<label htmlFor="apply-end">์ ‘์ˆ˜ ๋งˆ๊ฐ ์ผ์ž :</label>
<span id="apply-end">{applyEndDate}</span>
</IntroduceReference>
</IntroduceReferenceWrapper>
<IntroduceContentTitle>
์†Œ๊ฐœ
</IntroduceContentTitle>
{/* TODO: dangerouslySetInnerHTML์œผ๋กœ ๋ณ€๊ฒฝํ•˜๊ธฐ */}
<IntroduceContent>
{contents}
</IntroduceContent>
Comment on lines +94 to +119
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • Refactoring์ด ํ•„์š”ํ•  ๋“ฏ ํ•˜๋‹ค.
  • ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฆฌํ•˜๊ธฐ.

<Tags tags={tags} />
</StudyIntroduceWrapper>
);
Expand Down
26 changes: 12 additions & 14 deletions src/components/introduce/StudyIntroduceForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { render } from '@testing-library/react';

import StudyIntroduceForm from './StudyIntroduceForm';

import STUDY_GROUP from '../../../fixtures/study-group';

describe('StudyIntroduceForm', () => {
const renderStudyIntroduceForm = ({ group }) => render((
<MemoryRouter>
Expand All @@ -16,19 +18,15 @@ describe('StudyIntroduceForm', () => {
));

it('renders study group title and contents', () => {
const group = {
id: 1,
moderatorId: 'user1',
title: '์Šคํ„ฐ๋””๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค. 1',
personnel: 5,
applyEndDate: null,
contents: '์šฐ๋ฆฌ๋Š” ์Šคํ„ฐ๋””ํ•ฉ๋‹ˆ๋‹ค.',
tags: [],
};

const { container } = renderStudyIntroduceForm({ group });

expect(container).toHaveTextContent('์Šคํ„ฐ๋””๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค. 1');
expect(container).toHaveTextContent('์šฐ๋ฆฌ๋Š” ์Šคํ„ฐ๋””ํ•ฉ๋‹ˆ๋‹ค.');
const { container } = renderStudyIntroduceForm({ group: STUDY_GROUP });

expect(container).toHaveTextContent('์Šคํ„ฐ๋””๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.2');
expect(container).toHaveTextContent('์šฐ๋ฆฌ๋Š” ์ด๊ฒƒ์ €๊ฒƒ ํ•ฉ๋‹ˆ๋‹ค.2');
});

it('renders links of tags', () => {
const { container } = renderStudyIntroduceForm({ group: STUDY_GROUP });

expect(container.innerHTML).toContain('<a ');
});
});
1 change: 1 addition & 0 deletions src/components/main/StudyGroups.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { render } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';

import StudyGroups from './StudyGroups';

import STUDY_GROUPS from '../../../fixtures/study-groups';

describe('StudyGroups', () => {
Expand Down
9 changes: 0 additions & 9 deletions src/containers/groups/StudyGroupsContainer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ import { render, fireEvent } from '@testing-library/react';

import StudyGroupsContainer from './StudyGroupsContainer';

const mockSearch = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation() {
return { search: mockSearch };
},
}));

describe('StudyGroupsContainer', () => {
const dispatch = jest.fn();

Expand Down
11 changes: 3 additions & 8 deletions src/containers/introduce/IntroduceContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import React, { useEffect } from 'react';

import { useDispatch, useSelector } from 'react-redux';

import styled from '@emotion/styled';

import { loadStudyGroup } from '../../reducers/slice';
import { get } from '../../../utils';
import StudyIntroduceForm from '../../components/introduce/StudyIntroduceForm';
import { loadStudyGroup } from '../../reducers/slice';

const IntroduceContainerWrapper = styled.div``;
import StudyIntroduceForm from '../../components/introduce/StudyIntroduceForm';

const IntroduceContainer = ({ groupId }) => {
const dispatch = useDispatch();
Expand All @@ -26,9 +23,7 @@ const IntroduceContainer = ({ groupId }) => {
}

return (
<IntroduceContainerWrapper>
<StudyIntroduceForm group={group} />
</IntroduceContainerWrapper>
<StudyIntroduceForm group={group} />
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/containers/introduce/IntroduceContainer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { render } from '@testing-library/react';

import { MemoryRouter } from 'react-router-dom';

import IntroduceContainer from './IntroduceContainer';

describe('IntroduceContainer', () => {
Expand Down Expand Up @@ -32,6 +33,7 @@ describe('IntroduceContainer', () => {
moderatorId: 'user1',
title: '์Šคํ„ฐ๋””๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค. 1',
personnel: 7,
participants: [],
contents: '์šฐ๋ฆฌ๋Š” ์ด๊ฒƒ์ €๊ฒƒ ํ•ฉ๋‹ˆ๋‹ค.1',
tags: [
'JavaScript',
Expand Down
10 changes: 3 additions & 7 deletions src/pages/IntroducePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import React from 'react';

import { useParams } from 'react-router-dom';

import styled from '@emotion/styled';

import Responsive from '../styles/Responsive';
import IntroduceContainer from '../containers/introduce/IntroduceContainer';

const IntroducePageWrapper = styled.div``;

const IntroducePage = ({ params }) => {
const { id } = params || useParams();

return (
<IntroducePageWrapper>
<h2>์Šคํ„ฐ๋”” ์†Œ๊ฐœ</h2>
<Responsive>
<IntroduceContainer groupId={id} />
</IntroducePageWrapper>
</Responsive>
);
};
export default IntroducePage;
1 change: 1 addition & 0 deletions src/pages/IntroducePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('IntroducePage', () => {
title: '์Šคํ„ฐ๋””๋ฅผ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค. 1',
personnel: 7,
contents: '์šฐ๋ฆฌ๋Š” ์ด๊ฒƒ์ €๊ฒƒ ํ•ฉ๋‹ˆ๋‹ค.1',
participants: [],
tags: [
'JavaScript',
'React',
Expand Down