Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/118 #119

Merged
merged 4 commits into from
Mar 17, 2024
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
12 changes: 12 additions & 0 deletions src/app/(non-member)/signin/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactNode } from 'react';

import Header from '@/components/layout/Header';

export default function Layout({ children }: { children: ReactNode }) {
return (
<>
<Header />
{ children }
</>
);
}
12 changes: 12 additions & 0 deletions src/app/(non-member)/signup/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactNode } from 'react';

import Header from '@/components/layout/Header';

export default function Layout({ children }: { children: ReactNode }) {
return (
<>
<Header />
{ children }
</>
);
}
482 changes: 482 additions & 0 deletions src/app/(non-member)/tos/privacy/page.tsx

Large diffs are not rendered by default.

429 changes: 429 additions & 0 deletions src/app/(non-member)/tos/use/page.tsx

Large diffs are not rendered by default.

475 changes: 0 additions & 475 deletions src/app/(setting)/setting/tos/privacy/page.tsx

This file was deleted.

422 changes: 0 additions & 422 deletions src/app/(setting)/setting/tos/use/page.tsx

This file was deleted.

36 changes: 36 additions & 0 deletions src/components/common/Checkbox.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { screen } from '@testing-library/react';

import { renderWithProviders } from '@/utils/testHelper';

import Checkbox from './Checkbox';

jest.mock('usehooks-ts', () => ({
useDarkMode: () => ({ isDarkMode: false }),
}));

describe('Checkbox', () => {
const onChange = jest.fn();

const renderCheckbox = () => renderWithProviders(
<Checkbox
text="μ²΄ν¬λ°•μŠ€"
checked={given.checked}
onChange={onChange}
/>,
);

it('μ²΄ν¬λ°•μŠ€ ν…μŠ€νŠΈλ₯Ό λ‚˜νƒ€λ‚Έλ‹€.', () => {
given('checked', () => false);
renderCheckbox();

expect(screen.getByText(/μ²΄ν¬λ°•μŠ€/)).toBeInTheDocument();
});

it('μ²΄ν¬λ°•μŠ€λ₯Ό ν΄λ¦­ν•˜λ©΄ onChange ν•¨μˆ˜κ°€ μ‹€ν–‰λœλ‹€.', () => {
given('checked', () => false);
renderCheckbox();

screen.getByText(/μ²΄ν¬λ°•μŠ€/).click();
expect(onChange).toHaveBeenCalled();
});
});
77 changes: 77 additions & 0 deletions src/components/common/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import styled from 'styled-components';
import { useDarkMode } from 'usehooks-ts';

import CheckIconLight from '@/lib/assets/check-icon.svg';
import CheckIconDark from '@/lib/assets/check-icon-dark.svg';
import UncheckIcon from '@/lib/assets/check-icon-inactive.svg';

export type CheckboxProps = React.PropsWithChildren<{
checked: boolean,
text:string,
onChange:(value:boolean)=>void
}>;

export default function CheckBox({
checked, text, onChange, children,
}: CheckboxProps) {
const { isDarkMode } = useDarkMode();
const { CheckedIcon, checkedBorderColor, checkedTextColor } = isDarkMode ? {
CheckedIcon: CheckIconDark,
checkedBorderColor: '#FFFFFF',
checkedTextColor: '#FFFFFF',
} : {
CheckedIcon: CheckIconLight,
checkedBorderColor: '#000000',
checkedTextColor: '#000000',
};

const CheckIcon = checked ? CheckedIcon : UncheckIcon;
const borderColor = checked ? checkedBorderColor : '#A0A0A0';
const textColor = checked ? checkedTextColor : '#A0A0A0';

return (
<Container
$borderColor={borderColor}
>
<CheckboxContainer
onClick={() => {
onChange(!checked);
}}
>
{checked ? <CheckIcon /> : <UncheckIcon />}
<LabelText $textColor={textColor}>{text}</LabelText>
</CheckboxContainer>
{children && (
<Divider
$borderColor={borderColor}
/>
)}
{children}
</Container>
);
}

const Divider = styled.div<{ $borderColor:string }>`
width: 100%;
height: 1px;
background-color: ${({ $borderColor }) => $borderColor}
`;

const Container = styled.div<{ $borderColor:string }>`
display: flex;
flex-direction: column;
${({ $borderColor }) => `border: 1px solid ${$borderColor};`}
`;

const CheckboxContainer = styled.div`
display: flex;
align-items: center;
padding: 10px;
gap:8px;
`;

const LabelText = styled.label<{ $textColor:string }>`
font-size: 14px;
line-height: 16px;
color: ${({ $textColor }) => ($textColor)};
`;
47 changes: 47 additions & 0 deletions src/components/common/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { usePathname, useRouter } from 'next/navigation';

import { fireEvent, screen } from '@testing-library/react';

import { renderWithProviders } from '@/utils/testHelper';

import Header from './Header';

jest.mock('next/navigation', () => ({
usePathname: jest.fn(),
useRouter: jest.fn(),
}));

describe('Header', () => {
const mockBack = jest.fn();

beforeEach(() => {
jest.clearAllMocks();

(usePathname as jest.Mock).mockImplementation(() => given.pathname);
(useRouter as jest.Mock).mockImplementation(() => ({
back: mockBack,
}));
});

const rendeHeader = () => renderWithProviders(<Header title="μ„€μ •" />);

context('제λͺ©μ΄ μ„€μ • 일 λ•Œ', () => {
it('μ„€μ • 타이틀이 보인닀.', () => {
rendeHeader();

expect(screen.getByText('μ„€μ •')).toBeInTheDocument();
});
});

context('λ’€λ‘œ κ°€κΈ° λ²„νŠΌμ„ λˆ„λ₯΄λ©΄', () => {
given('pathname', () => '/setting/tos');

it('νŽ˜μ΄μ§€κ°€ λ’€λ‘œκ°„λ‹€.', () => {
rendeHeader();

fireEvent.click(screen.getByTestId('back-button'));

expect(mockBack).toHaveBeenCalled();
});
});
});
50 changes: 50 additions & 0 deletions src/components/common/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use client';

import { useRouter } from 'next/navigation';

import styled from 'styled-components';

import BackIcon from '@/lib/assets/back-icon.svg';

type Props = {
title: string;
};

export default function Header({ title }:Props) {
const router = useRouter();

const onBack = () => router.back();

return (
<Container>
<BackButton data-testid="back-button" onClick={onBack} />
<Title>{title}</Title>
</Container>
);
}

const Container = styled.div`
position: relative;
display: flex;
width: 100%;
min-height: 72px;
height: 72px;
justify-content: center;
align-items: center;
`;

const BackButton = styled(BackIcon)`
position: absolute;
left: 16px;
top: 21px;
path{
fill: ${({ theme }) => theme.color.text.title02};
}
`;

const Title = styled.div`
font-weight: 500;
font-size: 18px;
line-height: 26px;
color: ${({ theme }) => theme.color.text.title01};
`;
40 changes: 3 additions & 37 deletions src/components/layout/SettingHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use client';

import { usePathname, useRouter } from 'next/navigation';
import { usePathname } from 'next/navigation';

import styled from 'styled-components';

import BackIcon from '@/lib/assets/back-icon.svg';
import Header from '../common/Header';

const settingTitle:{ [key: string]: string } = {
'/setting': 'μ„€μ •',
Expand All @@ -21,42 +19,10 @@ const settingTitle:{ [key: string]: string } = {

export default function SettingHeader() {
const pathname = usePathname();
const router = useRouter();

const title = settingTitle[pathname || '/setting'];

const onBack = () => router.back();

return (
<Container>
<BackButton data-testid="back-button" onClick={onBack} />
<Title>{title}</Title>
</Container>
<Header title={title ?? ''} />
);
}

const Container = styled.div`
position: relative;
display: flex;
width: 100%;
min-height: 72px;
height: 72px;
justify-content: center;
align-items: center;
`;

const BackButton = styled(BackIcon)`
position: absolute;
left: 16px;
top: 21px;
path{
fill: ${({ theme }) => theme.color.text.title02};
}
`;

const Title = styled.div`
font-weight: 500;
font-size: 18px;
line-height: 26px;
color: ${({ theme }) => theme.color.text.title01};
`;
4 changes: 3 additions & 1 deletion src/components/relation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { useSearchParams } from 'next/navigation';

import { styled } from 'styled-components';
import { useDarkMode } from 'usehooks-ts';

import UserCard from '@/components/search/UserCard';
import useGetInfiniteFollow, { GET_INFINITE_FOLLOW_KEY } from '@/hooks/api/useGetInfiniteRelations';
import useToggleRelation from '@/hooks/api/useToggleRelation';

export default function Relation() {
const { isDarkMode } = useDarkMode();

Check warning on line 13 in src/components/relation/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

'isDarkMode' is assigned a value but never used

Check warning on line 13 in src/components/relation/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

'isDarkMode' is assigned a value but never used. Allowed unused vars must match /^_/u
const searchParams = useSearchParams();
const search = searchParams?.get('defaultType');
const [type, setType] = useState<'follower' | 'followee'>((search ?? 'follower') as ('follower' | 'followee'));
Expand Down Expand Up @@ -58,7 +60,7 @@
const TabItem = styled.div<{ active?: boolean }>`
font-size: 36px;
font-weight: 200;
color: ${({ active }) => (active ? '#000' : '#BDBDBD')};
color: ${({ theme, active }) => (active ? theme.color.text.title01 : theme.color.text.subTitle02)};
cursor: pointer;
`;

Expand Down
8 changes: 4 additions & 4 deletions src/components/signup/SignUpButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('StepButton', () => {
});

context('νšŒμ›κ°€μž… 첫 번째 νŽ˜μ΄μ§€μΌ 경우', () => {
given('step', () => 0);
given('step', () => 1);
it('"μ΄λ©”μΌλ‘œ 인증번호 전솑"λ²„νŠΌμ„ 화면에 보여쀀닀.', () => {
renderStepButton();

Expand All @@ -25,7 +25,7 @@ describe('StepButton', () => {
});

context('νšŒμ›κ°€μž… 두 번째 νŽ˜μ΄μ§€μΌ 경우', () => {
given('step', () => 1);
given('step', () => 2);
it('"확인"λ²„νŠΌμ„ 화면에 보여쀀닀.', () => {
renderStepButton();

Expand All @@ -34,7 +34,7 @@ describe('StepButton', () => {
});

context('νšŒμ›κ°€μž… λ§ˆμ§€λ§‰ νŽ˜μ΄μ§€μΌ 경우', () => {
given('step', () => 7);
given('step', () => 8);
it('"κ°€μž… μ™„λ£Œ"λ²„νŠΌμ„ 화면에 보여쀀닀.', () => {
renderStepButton();

Expand All @@ -43,7 +43,7 @@ describe('StepButton', () => {
});

context('κ·Έ μ™Έμ˜ νŽ˜μ΄μ§€μ˜ 경우', () => {
given('step', () => 5);
given('step', () => 6);
it('"λ‹€μŒ"λ²„νŠΌμ„ 화면에 보여쀀닀.', () => {
renderStepButton();

Expand Down
6 changes: 3 additions & 3 deletions src/components/signup/SignUpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ type SignUpButtonProps = {
};

const getButtonText = (step: number) => {
if (step === 0) {
if (step === 1) {
return 'μ΄λ©”μΌλ‘œ 인증번호 전솑';
}
if (step === 1) {
if (step === 2) {
return '확인';
}
if (step === 7) {
if (step === 8) {
return 'κ°€μž… μ™„λ£Œ';
}
return 'λ‹€μŒ';
Expand Down
5 changes: 3 additions & 2 deletions src/components/signup/SignUpForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ describe('SignUpForm', () => {
<SignUpForm
step={given.step}
formData={signupField}
onResend={jest.fn()}
/>,
);

context('νšŒμ›κ°€μž… 첫 번째 화면일 λ•Œ', () => {
given('step', () => 0);
given('step', () => 1);

it('이메일 μž…λ ₯ ν•„λ“œλ₯Ό 화면에 보여쀀닀.', () => {
renderSignUpForm();
Expand All @@ -24,7 +25,7 @@ describe('SignUpForm', () => {
});

context('νšŒμ›κ°€μž… λ„€ 번째 화면일 λ•Œ', () => {
given('step', () => 3);
given('step', () => 4);

it('이름 μž…λ ₯ ν•„λ“œλ₯Ό 화면에 보여쀀닀.', () => {
renderSignUpForm();
Expand Down
Loading
Loading