Skip to content

Commit

Permalink
Merge pull request #182 from FRONTENDSCHOOL5/feature-181
Browse files Browse the repository at this point in the history
[리팩토링] ProductUpload 페이지 헤더 변경
  • Loading branch information
snowkwon420 authored Oct 11, 2023
2 parents c0a5d79 + 8ec1348 commit c429e29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
22 changes: 12 additions & 10 deletions src/components/common/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,31 @@ export function HeaderBasicNav({ children, disabled }) {
//주소가 postupload 일 때만 업로드 버튼 랜더링
const pathName = window.location.pathname;
const isPostUpLoad = pathName == '/postupload';
const isProductUpLoad = pathName == '/product';

// 뒤로가기 버튼 구현하기;
return (
<HeaderDefaultStyle>
<Arrow />
{!isPostUpLoad ? (
{(!isPostUpLoad && !isProductUpLoad) ? (
<MoreIconButton />
) : (
<ButtonShort disabled={disabled}>{children}</ButtonShort>
)}

</HeaderDefaultStyle>
);
}

// export function HeaderUploadNav({ disabled, children }) {
// return (
// <HeaderDefaultStyle>
// <Arrow />
// <ButtonShort disabled={disabled}>{children}</ButtonShort>
// </HeaderDefaultStyle>
// );
// }

//상단 화살표 스타일
const arrow = () => {
return {
Expand Down Expand Up @@ -92,15 +103,6 @@ export function HeaderMainNav({ content }) {
);
}

export function HeaderUploadNav(props) {
const { disabled, content } = props;
return (
<HeaderDefaultStyle>
<Arrow />
<ButtonShort disabled={disabled} content={content} />
</HeaderDefaultStyle>
);
}

export function HeaderEditdNav({ content, isFormValid, handleSave }) {
return (
Expand Down
7 changes: 3 additions & 4 deletions src/components/common/button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ const ButtonMiddleStyle = styled.button`
`;

// 짧은 버튼
export const ButtonShort = props => {
const { disabled, handleSave, content, isFormValid } = props;
export const ButtonShort = ({disabled, children}) => {
return (
<ButtonShortStyle content={content} disabled={disabled} {...props}>
{props.children}
<ButtonShortStyle disabled={disabled}>
{children}
</ButtonShortStyle>
);
};
Expand Down
10 changes: 2 additions & 8 deletions src/pages/ProductPage/ProductPage.jsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import styled from 'styled-components';
import Input from '../../components/common/Input/Input';
import { useNavigate } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import BodyGlobal from '../../styles/BodyGlobal';
import authAtom from '../../atom/authToken';

import FileUploadInput from '../../components/common/Input/FileUploadInput';
import { HeaderUploadNav } from '../../components/common/Header/Header';
import { HeaderBasicNav } from '../../components/common/Header/Header';
import Layout from '../../styles/Layout';

import useFetchToken from "../../Hooks/UseFetchToken";
export default function ProductPage() {
const user = 'nigonego';
const navigate = useNavigate();

const [itemName, setItemName] = useState('');
const [price, setPrice] = useState('');
const [link, setLink] = useState('');
const [itemImage, setItemImage] = useState('');

const auth = useRecoilValue(authAtom);
const { postJoinImage, postProductUpload } = useFetchToken();

const [isFormValid, setIsFormValid] = useState(false);
// const [isBtnActive, setIsBtnActive] = useState(Boolean(false));

useEffect(() => {
if (itemName && price && link && itemImage) {
setIsFormValid(true);
// setIsBtnActive(Boolean(true))
}
}, [itemName, price, link, itemImage]);

Expand All @@ -57,7 +51,7 @@ export default function ProductPage() {
return (
<Layout>
<form onSubmit={handleSubmit}>
<HeaderUploadNav content="업로드" isFormValid={isFormValid} />
<HeaderBasicNav disabled={!isFormValid}>업로드</HeaderBasicNav>

<ul>
<li>
Expand Down

0 comments on commit c429e29

Please sign in to comment.