forked from milzipmoza-developers/tecobrary-admin-client-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[milzipmoza-developers#3] feat - 도서 상세 관리 페이지 리팩토링
- Loading branch information
1 parent
439b86f
commit 26f8387
Showing
7 changed files
with
207 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Badge} from "react-bootstrap"; | ||
import * as React from "react"; | ||
|
||
const BookRentStatusBadge = ({rentStatus}: any) => ( | ||
<div style={{fontSize: '24px', lineHeight: '24px'}}> | ||
{rentStatus | ||
? <Badge variant="warning">대여중</Badge> | ||
: <Badge variant="success">비치중</Badge>} | ||
</div> | ||
); | ||
|
||
export default BookRentStatusBadge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {ISerialInfo} from "../../models/interfaces"; | ||
import BookSerialElement from "./BookSerialElement"; | ||
import * as React from "react"; | ||
import {CSSProperties} from "react"; | ||
|
||
interface IProps { | ||
serials: ISerialInfo[] | ||
} | ||
|
||
const style: CSSProperties = { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
minHeight: '250px', | ||
maxHeight: '350px', | ||
height: 'fill-content', | ||
textAlign: 'center', | ||
overflow: 'scroll' | ||
}; | ||
|
||
const BookRentListCardBody = ({serials}: IProps) => ( | ||
<div style={style}> | ||
{serials.map((serial: ISerialInfo, i: number) => ( | ||
<BookSerialElement | ||
key={i} | ||
serialNumber={serial.serialNumber} | ||
rentStatus={serial.rentStatus} | ||
rentUser={serial.rentUser}/> | ||
))} | ||
</div> | ||
); | ||
|
||
export default BookRentListCardBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as React from "react"; | ||
import BookRentStatusBadge from "../atoms/BookRentStatusBadge"; | ||
import {Button} from "react-bootstrap"; | ||
import Divider from "../atoms/Divider"; | ||
import {CSSProperties} from "react"; | ||
|
||
interface IProps { | ||
serialNumber: number; | ||
rentStatus: boolean; | ||
rentUser: string; | ||
} | ||
|
||
const itemStyle: CSSProperties = { | ||
flex: 1, | ||
padding: '4px', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center' | ||
}; | ||
|
||
const BookSerialElement = ({serialNumber, rentStatus, rentUser}: IProps) => ( | ||
<div> | ||
<div style={{height: '50px', display: 'flex', flexDirection: 'row', padding: '4px'}}> | ||
<div style={itemStyle}> | ||
<div>{serialNumber}</div> | ||
</div> | ||
<div style={{flex: 2, padding: '4px', display: 'flex', flexDirection: 'column', justifyContent: 'center'}}> | ||
<BookRentStatusBadge rentStatus={rentStatus}/> | ||
</div> | ||
<div style={itemStyle}> | ||
<div>{rentUser ? rentUser : ''}</div> | ||
</div> | ||
<div style={itemStyle}> | ||
<div style={{display: 'flex', flexDirection: 'row', justifyContent: 'center'}}> | ||
<Button variant="primary" size="sm" style={{width: '71.25px'}} disabled={!rentStatus}>반납 요청</Button> | ||
<div style={{width: '16px'}}/> | ||
<Button variant="primary" size="sm" style={{width: '71.25px'}}>삭제</Button> | ||
</div> | ||
</div> | ||
</div> | ||
<Divider/> | ||
</div> | ||
); | ||
|
||
export default BookSerialElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {Button, Card} from "react-bootstrap"; | ||
import * as React from "react"; | ||
|
||
interface IProps { | ||
title: string; | ||
buttonName: string; | ||
buttonOnClick?: any; | ||
disabled?: boolean; | ||
} | ||
|
||
const CardButtonHeader = ({title, buttonName, buttonOnClick, disabled}: IProps) => ( | ||
<Card.Header as="h5"> | ||
<div style={{display: 'flex', flexDirection: 'row'}}> | ||
<div style={{flex: 13, display: 'flex', flexDirection: 'column', justifyContent: 'center'}}> | ||
<div style={{width: 'fit-content'}}>{title}</div> | ||
</div> | ||
<div style={{flex: 1, display: 'flex', flexDirection: 'column'}}> | ||
<Button variant="primary" size="sm" onClick={buttonOnClick} | ||
disabled={disabled ? disabled : false}>{buttonName}</Button> | ||
</div> | ||
</div> | ||
</Card.Header> | ||
); | ||
|
||
export default CardButtonHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {Card} from "react-bootstrap"; | ||
import CardButtonHeader from "../molecules/CardButtonHeader"; | ||
import BookRentListCardBody from "../molecules/BookRentListCardBody"; | ||
import * as React from "react"; | ||
import {ISerialInfo} from "../../models/interfaces"; | ||
import {useState} from "react"; | ||
import BookListCardFooter from "./BookListCardFooter"; | ||
import Divider from "../atoms/Divider"; | ||
|
||
interface IProps { | ||
bookId: string | string[]; | ||
onClick?: any; | ||
} | ||
|
||
const mockSerials: ISerialInfo[] = [ | ||
{serialNumber: 1, rentStatus: true, rentUser: '루피'}, | ||
{serialNumber: 2, rentStatus: false, rentUser: null}, | ||
{serialNumber: 3, rentStatus: true, rentUser: '루피'}, | ||
]; | ||
|
||
const BookRentListCard = ({bookId, onClick}: IProps) => { | ||
|
||
const [page, setPage] = useState(1); | ||
const [serials, setSerials] = useState<ISerialInfo[]>(mockSerials); | ||
|
||
const onPageDown = () => { | ||
if (page <= 1) { | ||
return; | ||
} | ||
setPage(page - 1); | ||
console.log('on Page Down'); | ||
}; | ||
|
||
const onPageUp = () => { | ||
console.log('on page up'); | ||
}; | ||
|
||
return ( | ||
<Card style={{marginTop: '20px'}}> | ||
<CardButtonHeader title="시리얼 정보" buttonName="추가" buttonOnClick={onClick}/> | ||
<BookRentListCardBody serials={serials}/> | ||
<Divider/> | ||
<BookListCardFooter page={page} onPageDown={onPageDown} onPageUp={onPageUp}/> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default BookRentListCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters