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

feat: 모두의 정원 등록 페이지 #362

Merged
merged 38 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a9c718b
chore: PetCard -> PetPlantCard 네이밍 변경
bassyu Sep 11, 2023
19613f8
chore: calendar URL 삭제
bassyu Sep 11, 2023
264e5b8
chore: 모두의 정원 등록 페이지 URL 추가
bassyu Sep 12, 2023
44d1a0f
refactor: InlineRadio에서 UI 분리
WaiNaat Sep 12, 2023
c455b71
chore: JSX 안쓰는 tsx 파일 ts로 변경
WaiNaat Sep 12, 2023
1937578
Merge branch 'develop' of https://github.com/woowacourse-teams/2023-p…
WaiNaat Sep 13, 2023
ba8ebcc
feat: 게시글 등록 api 로직
WaiNaat Sep 13, 2023
18f321e
feat: 게시글 등록 msw
WaiNaat Sep 13, 2023
8817587
feat: 등록 양식 마크업 작성
WaiNaat Sep 13, 2023
0d9c5fe
refactor: 식물 사전 상세 디자인 깨짐 수정
WaiNaat Sep 14, 2023
3e5b9f2
fix: Element type is invalid 오류 해결
WaiNaat Sep 14, 2023
d6610a1
test: 사전 식물 상세 스토리북 수정
WaiNaat Sep 14, 2023
83d7f2e
design: Inline Radio Option 디자인 수정
WaiNaat Sep 14, 2023
5cb5386
feat: 양식 디자인 및 기본 기능
WaiNaat Sep 14, 2023
f88cde2
feat: 라우터 설정
WaiNaat Sep 14, 2023
789a767
feat: 반려 식물 선택 페이지
WaiNaat Sep 14, 2023
443ee23
feat: 세션 검증 및 디자인 수정
WaiNaat Sep 14, 2023
5fb1695
refactor: 불필요한 async 삭제
WaiNaat Sep 14, 2023
fa66ab6
feat: 서버 통신 로직과 결합
WaiNaat Sep 14, 2023
a64dc75
feat: 식물 삭제 버튼 위치 변경
WaiNaat Sep 14, 2023
edf25e6
feat: 모두의 정원 등록 버튼
WaiNaat Sep 14, 2023
7a9e487
Merge branch 'develop' of https://github.com/woowacourse-teams/2023-p…
WaiNaat Sep 15, 2023
fdcb427
refactor: 등록 성공 후 목록으로 이동
WaiNaat Sep 15, 2023
8bccf2f
fix: 등록 버튼 가려지는 문제 해결
WaiNaat Sep 15, 2023
5ed132a
design: '글쓰기'를 '기록하기'로 변경
WaiNaat Sep 15, 2023
8bb6014
refactor: alt에서 불필요한 내용 삭제
WaiNaat Sep 15, 2023
d06855a
chore: 파일명 변경
WaiNaat Sep 15, 2023
3466ee2
feat: 난이도를 선택하지 않았으면 게시글에 노출 안함
WaiNaat Sep 15, 2023
56d645c
feat: 양식 제출 검사 및 내용 입력 필수
WaiNaat Sep 15, 2023
3fad939
refactor: 절대경로 사용
WaiNaat Sep 15, 2023
4a2cfbe
feat: 반려식물 요약 프로필 자세하게 변경
WaiNaat Sep 15, 2023
4eef772
feat: 반려 식물 정보 수정 취소 시 뒤로가기
WaiNaat Sep 15, 2023
c2427c9
feat: 반려 식물 삭제 버튼 롤백
WaiNaat Sep 15, 2023
de773c3
design: 정보수정 링크 hover 색 변경
WaiNaat Sep 18, 2023
06e14b9
design: 등록하기 -> 기록하기 변경
WaiNaat Sep 18, 2023
7605a8e
fix: typo
WaiNaat Sep 18, 2023
45bd549
Merge `develop` into this branch
WaiNaat Sep 18, 2023
5a95f25
feat: profile에 suspense 적용
WaiNaat Sep 18, 2023
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
23 changes: 23 additions & 0 deletions frontend/src/apis/garden.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { GardenRegisterForm } from 'types/garden';
import { BASE_URL } from 'constants/index';

export const GARDEN_URL = `${BASE_URL}/garden`;

const headers = {
'Content-Type': 'application/json',
};

const register = (form: GardenRegisterForm) => {
return fetch(GARDEN_URL, {
method: 'POST',
headers,
credentials: 'include',
body: JSON.stringify(form),
});
};

const GardenAPI = {
register,
};

export default GardenAPI;
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ const Wrapper = () => {
return (
<InlineRadio name="seasons" value={value} setValue={setValue}>
<InlineRadio.Option value="봄" />
<span>|</span>
<InlineRadio.Option value="여름" />
<span>|</span>
<InlineRadio.Option value="가을" />
<span>|</span>
<InlineRadio.Option value="겨울" />
</InlineRadio>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@ export const Wrapper = styled.span`
display: inline-flex;
font-size: 1.8rem;
`;

export const Division = styled.p`
display: inline-flex;
align-items: center;
`;
16 changes: 2 additions & 14 deletions frontend/src/components/@common/InlineRadio/ingredients/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import { Fragment } from 'react';
import { Division, Wrapper } from './Main.style';
import { Wrapper } from './Main.style';
import RadioProvider, { RadioProviderProps } from 'contexts/radioContext';
import getFilteredChildren from 'utils/getFilteredChildren';
import Option from './Option';

const Main = (props: RadioProviderProps) => {
const { value, setValue, children, name } = props;

const options = getFilteredChildren(<Option value="" />, children);

return (
<RadioProvider value={value} setValue={setValue} name={name}>
<Wrapper>
{options.map((option, index) => (
<Fragment key={index}>
{option}
{index < options.length - 1 ? <Division aria-hidden="true">|</Division> : null}
</Fragment>
))}
</Wrapper>
<Wrapper>{children}</Wrapper>
</RadioProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ export const HiddenRadio = styled.input`
export const Label = styled.label`
cursor: pointer;
display: inline-block;
padding: 3px 13px;

&:hover {
font-weight: bold;
}
`;

export const Content = styled.span`
display: inline-block;
`;
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useId } from 'react';
import { HiddenRadio, Label } from './Option.style';
import { HiddenRadio, Label, Content } from './Option.style';
import { useRadioContext } from 'hooks/useRadioContext';

interface OptionProps {
value: string;
}

const Option = (props: OptionProps) => {
const { value } = props;
const Option = (props: React.PropsWithChildren<OptionProps>) => {
const { value, children } = props;
const { value: contextValue, setValue, name } = useRadioContext();
const id = useId();

Expand All @@ -21,7 +21,7 @@ const Option = (props: OptionProps) => {
checked={value === contextValue}
onChange={() => setValue(value)}
/>
<span>{value}</span>
<Content>{children ? children : value}</Content>
</Label>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ export const ContentBox = styled.section`

width: 320px;
margin: 0 auto;
div {
font: ${(props) => props.theme.font.dictContent};
`;

export const InformationTagBox = styled.div`
font: ${(props) => props.theme.font.dictContent};

p {
font: ${(props) => props.theme.font.dictTitle};
}
p {
font: ${(props) => props.theme.font.dictTitle};
}
`;

Expand Down Expand Up @@ -82,14 +83,12 @@ export const ManageInfoBox = styled.div`
width: 100%;
padding: 16px;

font: ${(props) => props.theme.font.dictContent};

background: #ececec;
border-radius: 8px;

p {
& > p {
font: ${(props) => props.theme.font.dictTitle};
}

span {
font: ${(props) => props.theme.font.dictContent};
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ContentBox,
FamilyName,
HeaderBox,
InformationTagBox,
ManageInfoBox,
Name,
PropBox,
Expand Down Expand Up @@ -49,15 +50,15 @@ const DictionaryPlantContent = (props: DictionaryPlantExtendCycles) => {
</div>
</HeaderBox>
<ContentBox>
<div>
<InformationTagBox>
<TagSwitch title="물 주기" optionMap={waterOptions} />
</div>
<div>
</InformationTagBox>
<InformationTagBox>
<TagBox>
<TagBox.Title>추천 장소</TagBox.Title>
{place}
</TagBox>
</div>
</InformationTagBox>

<PropsBox>
<PropBox>
Expand Down Expand Up @@ -154,11 +155,9 @@ const DictionaryPlantContent = (props: DictionaryPlantExtendCycles) => {

<ManageInfoBox>
<p>특별 관리 정보</p>
<span>
<SeeMoreContentBox>
{specialManageInfo !== NO_INFORMATION ? specialManageInfo : '관련 정보가 없어요😇'}
</SeeMoreContentBox>
</span>
<SeeMoreContentBox>
{specialManageInfo !== NO_INFORMATION ? specialManageInfo : '관련 정보가 없어요😇'}
</SeeMoreContentBox>
</ManageInfoBox>
</ContentBox>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { styled } from 'styled-components';

export const Padding = styled.span`
padding: 3px 13px;
`;
12 changes: 9 additions & 3 deletions frontend/src/components/dictionaryPlant/TagSwitch/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useState } from 'react';
import { useState, Fragment } from 'react';
import InlineRadio from 'components/@common/InlineRadio';
import { TagVariantType } from 'components/@common/Tag';
import TagBox from 'components/dictionaryPlant/TagBox';
import { Padding } from './TagSwitch.style';

interface TagSwitchProps {
title: string;
Expand All @@ -23,8 +24,13 @@ const TagSwitch = (props: TagSwitchProps) => {
<TagBox.Title>
{title}
<InlineRadio name={title} value={selected} setValue={setSelected}>
{options.map((optionName) => (
<InlineRadio.Option key={optionName} value={optionName} />
{options.map((optionName, index) => (
<>
{index > 0 && <span>|</span>}
<Padding key={optionName}>
<InlineRadio.Option value={optionName} />
</Padding>
</>
))}
</InlineRadio>
</TagBox.Title>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/garden/GardenPostItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const GardenPostItem = ({
<TagArea>
<DictionaryPlantTag>{dictionaryPlantName}</DictionaryPlantTag>
<WaterCycleTag>물 주기: {petPlant.waterCycle}일</WaterCycleTag>
<ManageLevelTag>{manageLevel}에게 추천해요</ManageLevelTag>
{manageLevel !== '정보없음' && <ManageLevelTag>{manageLevel}에게 추천해요</ManageLevelTag>}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

</TagArea>
<Environment>
<EnvironmentItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Link } from 'react-router-dom';
import styled, { css } from 'styled-components';
import theme from 'style/theme.style';

const singleLineText = css`
overflow: hidden;
Expand Down Expand Up @@ -158,34 +159,57 @@ export const EnvironmentTitle = styled.span`
border-radius: 50%;
`;

export const EditLink = styled(StyledLink)`
export const ButtonArea = styled.div`
display: flex;
justify-content: space-between;
column-gap: 10px;
`;

const ButtonLink = styled(Link)`
display: inline-flex;
align-items: center;
justify-content: center;

margin-right: auto;
margin-left: 0;
width: 100%;
height: 36px;

font-size: 1.4rem;
color: ${({ theme }) => theme.color.grayDark};
font-size: 1.5rem;
font-weight: 500;
letter-spacing: 1px;

transition: color 0.2s linear;
border-radius: 4px;
`;

&:focus {
color: ${({ theme }) => theme.color.primary};
}
export const PrimaryLink = styled(ButtonLink)`
color: ${({ theme }) => theme.color.background};
background: ${(props) => props.theme.color.primary};
`;

export const SecondaryLink = styled(ButtonLink)`
color: ${({ theme }) => theme.color.sub};
background: ${(props) => props.theme.color.background};
border: 1px solid ${({ theme }) => theme.color.primary};
`;

export const DeleteButton = styled.button`
const tertiary = css`
display: inline-flex;
align-items: center;
justify-content: center;

font-size: 1.4rem;
color: ${({ theme }) => theme.color.grayDark};
font-size: 1.5rem;
color: ${theme.color.grayDark};
text-decoration: underline;

&:focus,
&:hover {
color: ${({ theme }) => theme.color.accent};
color: ${theme.color.accent};
}
`;

export const TertiaryButton = styled.button`
${tertiary}
`;

export const TertiaryLink = styled(Link)`
${tertiary}
`;
38 changes: 23 additions & 15 deletions frontend/src/components/petPlant/PetPlantDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import {
EnvironmentItem,
TimelineLinkArea,
TimelineLink,
EditLink,
DeleteButton,
PrimaryLink,
ButtonArea,
TertiaryButton,
TertiaryLink,
} from './PetPlantDetail.style';
import useDeletePetPlant from 'hooks/queries/petPlant/useDeletePetPlant';
import usePetPlantDetails from 'hooks/queries/petPlant/usePetPlantDetails';
Expand All @@ -37,16 +39,16 @@ interface PetDetailsProps {

const PetPlantDetail = ({ petPlantId }: PetDetailsProps) => {
const { data: petPlantDetails } = usePetPlantDetails(petPlantId);
const { mutate: deleteMutate } = useDeletePetPlant();
const confirm = useConfirm();
const { mutate } = useDeletePetPlant();

if (!petPlantDetails) return null;

const {
id,
imageUrl,
nickname,
dictionaryPlant: { id: dictId, name: dictName },
dictionaryPlant: { id: dictionaryPlantId, name: dictionaryPlantName },
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

birthDate,
daySince,
waterCycle,
Expand All @@ -66,7 +68,7 @@ const PetPlantDetail = ({ petPlantId }: PetDetailsProps) => {

if (!isConfirmed) return;

mutate(id);
deleteMutate(petPlantId);
};

const birthDateKorean = convertDateKorYear(birthDate);
Expand All @@ -79,16 +81,16 @@ const PetPlantDetail = ({ petPlantId }: PetDetailsProps) => {

return (
<Wrapper>
<Image type="wide" src={imageUrl} alt={`${nickname}(${dictName})`} size="300px" />
<Image type="wide" src={imageUrl} alt={`${nickname}(${dictionaryPlantName})`} size="300px" />
<Content>
<TitleArea>
<Title>
{nickname}
{isBirthday && <SvgFill icon="crown" aria-hidden="true" />}
</Title>
<StyledLink to={generatePath(URL_PATH.dictDetail, { id: dictId.toString() })}>
<StyledLink to={generatePath(URL_PATH.dictDetail, { id: dictionaryPlantId.toString() })}>
<SubTitle>
{dictName}
{dictionaryPlantName}
<SvgStroke icon="dictionary" aria-hidden="true" color={theme.color.grayDark} />
</SubTitle>
</StyledLink>
Expand Down Expand Up @@ -179,14 +181,20 @@ const PetPlantDetail = ({ petPlantId }: PetDetailsProps) => {
{wind}
</EnvironmentItem>
</Environment>
<ExpandedTextBox>
<EditLink to={generatePath(URL_PATH.petEdit, { id: petPlantId.toString() })}>
<ButtonArea>
<TertiaryLink to={generatePath(URL_PATH.petEdit, { id: petPlantId.toString() })}>
Copy link
Member

Choose a reason for hiding this comment

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

hover하면 붉은 색이어서 한번 확인해주세요~

정보 수정하기
</EditLink>
<DeleteButton type="button" onClick={deletePetPlant}>
식물 삭제하기
</DeleteButton>
</ExpandedTextBox>
</TertiaryLink>
<TertiaryButton type="button" onClick={deletePetPlant}>
삭제하기
</TertiaryButton>
</ButtonArea>
<PrimaryLink
to={generatePath(URL_PATH.gardenRegisterForm, { id: petPlantId.toString() })}
state={{ nickname, dictionaryPlantName, imageUrl }}
>
모두의 정원에 등록하기
Copy link
Member

Choose a reason for hiding this comment

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

기록하기 반영 해주시나요? 😃

Copy link
Member Author

Choose a reason for hiding this comment

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

앗 하나만 하고 나머지를 안했네요ㅋㅋㅋㅋ 👀

</PrimaryLink>
</Content>
</Wrapper>
);
Expand Down
Loading