diff --git a/src/Components/StatusTextColor/StatusTextColor.tsx b/src/Components/StatusTextColor/StatusTextColor.tsx new file mode 100644 index 0000000..17695fb --- /dev/null +++ b/src/Components/StatusTextColor/StatusTextColor.tsx @@ -0,0 +1,18 @@ +import { colors } from "../../styles"; + +export default function StatusTextColor(status: string) { + if ( + status === "Pending Approval" || + status === "Returned: Pending Checking" + ) { + return colors.orange; + } else if ( + status === "Approved" || + status === "Finalized" || + status === "Borrowed" + ) { + return colors.green; + } else { + return colors.red; + } +} diff --git a/src/Components/TransactionEntry/TransactionEntry.tsx b/src/Components/TransactionEntry/TransactionEntry.tsx index e2b3940..167cbca 100644 --- a/src/Components/TransactionEntry/TransactionEntry.tsx +++ b/src/Components/TransactionEntry/TransactionEntry.tsx @@ -1,8 +1,8 @@ import styles from "../../styles"; import { colors } from "../../styles"; import { TransactionType } from "../Types/Types"; -import StatusText from "../TransactionStatusText/TransactionStatusText"; import { useNavigate } from "react-router-dom"; +import StatusTextColor from "../StatusTextColor/StatusTextColor"; export interface props { transaction: TransactionType; } @@ -119,7 +119,19 @@ export default function TransactionEntry(props: props) { - +

+ {`${props.transaction.transaction_status}`} +

); } diff --git a/src/Components/TransactionPDF/TransactionPDF.tsx b/src/Components/TransactionPDF/TransactionPDF.tsx index e43d7bf..285fdae 100644 --- a/src/Components/TransactionPDF/TransactionPDF.tsx +++ b/src/Components/TransactionPDF/TransactionPDF.tsx @@ -1,56 +1,27 @@ -import { StyleSheet, Document, Page, Text, View } from "@react-pdf/renderer"; +import { Document, Page, Text, View } from "@react-pdf/renderer"; import { TransactionType } from "../Types/Types"; -import styles, { colors } from "../../styles"; +import { colors } from "../../styles"; +import StatusTextColor from "../StatusTextColor/StatusTextColor"; type props = { transaction: TransactionType; }; -const pdf_styles = StyleSheet.create({ - container: { - alignSelf: "center", - justifySelf: "center", - width: "512px", - backgroundColor: colors.header_color, - borderRadius: 16, - margin: "8px", - padding: "8px", - }, - flex_row: { - display: "flex", - flexDirection: "row", - }, - flex_column: { - display: "flex", - flexDirection: "column", - }, - text_dark: { - color: colors.font_dark, - fontWeight: "bold", - }, - text_light: { - color: colors.font_light, - fontWeight: "bold", - }, - text_red: { - color: colors.red, - fontWeight: "bold", - }, - text_orange: { - color: colors.orange, - fontWeight: "bold", - }, - text_green: { - color: colors.green, - fontWeight: "bold", - }, -}); - export default function TransactionPDF(props: props) { return ( - - + + - ID: {props.transaction.id} + Transaction ID: {props.transaction.id} + + + + + Borrower: {props.transaction.borrower.name}{" "} + {`(ID:${props.transaction.borrower.id})`} + + + Teacher: {props.transaction.teacher.name}{" "} + {`(ID:${props.transaction.teacher.id})`} + + + {props.transaction.remarks} + + + + + Equipments: + + + {props.transaction.equipments.map((equipment) => ( + + {` - ${equipment.name} (ID:${equipment.id})`} + + ))} + + + + + + {`${props.transaction.transaction_status}`} + + diff --git a/src/Components/TransactionStatusText/TransactionStatusText.tsx b/src/Components/TransactionStatusText/TransactionStatusText.tsx deleted file mode 100644 index 4c50479..0000000 --- a/src/Components/TransactionStatusText/TransactionStatusText.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import styles, { colors } from "../../styles"; - -export default function StatusText(props: { status: string }) { - let color; - if ( - props.status === "Pending Approval" || - props.status === "Returned: Pending Checking" - ) { - color = colors.orange; - } else if ( - props.status === "Approved" || - props.status === "Finalized" || - props.status === "Borrowed" - ) { - color = colors.green; - } else { - color = colors.red; - } - return ( -

- {props.status} -

- ); -}