mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2024-11-17 06:19:27 +08:00
Update transaction entry to reflect borrower's course
This commit is contained in:
parent
564a7d41d8
commit
f9b4729ee7
5 changed files with 129 additions and 11 deletions
|
@ -11,6 +11,13 @@ import Button from "../Button/Button";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { RegisterAPI } from "../API/API";
|
import { RegisterAPI } from "../API/API";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
|
import {
|
||||||
|
Radio,
|
||||||
|
RadioGroup,
|
||||||
|
FormControlLabel,
|
||||||
|
FormControl,
|
||||||
|
FormLabel,
|
||||||
|
} from "@mui/material";
|
||||||
export default function RegisterModal() {
|
export default function RegisterModal() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
@ -20,6 +27,7 @@ export default function RegisterModal() {
|
||||||
last_name: "",
|
last_name: "",
|
||||||
username: "",
|
username: "",
|
||||||
email: "",
|
email: "",
|
||||||
|
course: "",
|
||||||
password: "",
|
password: "",
|
||||||
confirm_password: "",
|
confirm_password: "",
|
||||||
});
|
});
|
||||||
|
@ -78,6 +86,53 @@ export default function RegisterModal() {
|
||||||
value={user.email}
|
value={user.email}
|
||||||
placeholder={"Enter your email"}
|
placeholder={"Enter your email"}
|
||||||
/>
|
/>
|
||||||
|
<FormControl style={{ marginTop: "8px" }}>
|
||||||
|
<FormLabel style={styles.text_dark} id="status-selection">
|
||||||
|
Course
|
||||||
|
</FormLabel>
|
||||||
|
<RadioGroup
|
||||||
|
aria-labelledby="demo-radio-buttons-group-label"
|
||||||
|
value={user.course}
|
||||||
|
defaultValue="BS Chemistry"
|
||||||
|
name="radio-buttons-group"
|
||||||
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setUser({ ...user, course: e.target.value });
|
||||||
|
setError("");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
...styles.flex_column,
|
||||||
|
...{ overflowY: "scroll", maxHeight: "72px" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
value="BS Chemistry"
|
||||||
|
control={<Radio />}
|
||||||
|
label="BS Chemistry"
|
||||||
|
style={styles.text_dark}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
value="BS Food Technology"
|
||||||
|
control={<Radio />}
|
||||||
|
label="BS Food Technology"
|
||||||
|
style={styles.text_dark}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
value="BS Applied Physics"
|
||||||
|
control={<Radio />}
|
||||||
|
label="BS Applied Physics"
|
||||||
|
style={styles.text_dark}
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
value="BS Environmental Science"
|
||||||
|
control={<Radio />}
|
||||||
|
label="BS Environmental Science"
|
||||||
|
style={styles.text_dark}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormControl>
|
||||||
<TextField
|
<TextField
|
||||||
id="outlined-helperText"
|
id="outlined-helperText"
|
||||||
label="Username"
|
label="Username"
|
||||||
|
@ -181,6 +236,7 @@ export default function RegisterModal() {
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
confirm_password: "",
|
confirm_password: "",
|
||||||
|
course: "",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setError(JSON.stringify(status[1]));
|
setError(JSON.stringify(status[1]));
|
||||||
|
|
|
@ -59,6 +59,15 @@ export default function TransactionEntry(props: props) {
|
||||||
Borrower: {props.transaction.borrower.name}{" "}
|
Borrower: {props.transaction.borrower.name}{" "}
|
||||||
{`(ID:${props.transaction.borrower.id})`}
|
{`(ID:${props.transaction.borrower.id})`}
|
||||||
</p>
|
</p>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
...styles.text_dark,
|
||||||
|
...styles.text_S,
|
||||||
|
...{ textAlign: "left", margin: 0 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`(${props.transaction.borrower.course})`}
|
||||||
|
</p>
|
||||||
<p
|
<p
|
||||||
style={{
|
style={{
|
||||||
...styles.text_dark,
|
...styles.text_dark,
|
||||||
|
@ -69,6 +78,15 @@ export default function TransactionEntry(props: props) {
|
||||||
Teacher: {props.transaction.teacher.name}{" "}
|
Teacher: {props.transaction.teacher.name}{" "}
|
||||||
{`(ID:${props.transaction.teacher.id})`}
|
{`(ID:${props.transaction.teacher.id})`}
|
||||||
</p>
|
</p>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
...styles.text_dark,
|
||||||
|
...styles.text_S,
|
||||||
|
...{ textAlign: "left", margin: 0 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Subject: {props.transaction.subject}
|
||||||
|
</p>
|
||||||
<p
|
<p
|
||||||
style={{
|
style={{
|
||||||
...styles.text_dark,
|
...styles.text_dark,
|
||||||
|
|
|
@ -57,6 +57,16 @@ export default function TransactionPDF(props: props) {
|
||||||
Borrower: {props.transaction.borrower.name}{" "}
|
Borrower: {props.transaction.borrower.name}{" "}
|
||||||
{`(ID:${props.transaction.borrower.id})`}
|
{`(ID:${props.transaction.borrower.id})`}
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: colors.font_dark,
|
||||||
|
fontSize: 16,
|
||||||
|
textAlign: "left",
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`(${props.transaction.borrower.course})`}
|
||||||
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
color: colors.font_dark,
|
color: colors.font_dark,
|
||||||
|
@ -68,6 +78,16 @@ export default function TransactionPDF(props: props) {
|
||||||
Teacher: {props.transaction.teacher.name}{" "}
|
Teacher: {props.transaction.teacher.name}{" "}
|
||||||
{`(ID:${props.transaction.teacher.id})`}
|
{`(ID:${props.transaction.teacher.id})`}
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: colors.font_dark,
|
||||||
|
fontSize: 16,
|
||||||
|
textAlign: "left",
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Subject: {props.transaction.subject}
|
||||||
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
color: colors.font_dark,
|
color: colors.font_dark,
|
||||||
|
|
|
@ -4,6 +4,7 @@ export type RegisterType = {
|
||||||
password: string;
|
password: string;
|
||||||
first_name: string;
|
first_name: string;
|
||||||
last_name: string;
|
last_name: string;
|
||||||
|
course: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LoginType = {
|
export type LoginType = {
|
||||||
|
@ -113,6 +114,7 @@ export type TransactionType = {
|
||||||
borrower: {
|
borrower: {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
course: string;
|
||||||
};
|
};
|
||||||
teacher: {
|
teacher: {
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -125,6 +127,7 @@ export type TransactionType = {
|
||||||
transaction_status: string;
|
transaction_status: string;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
remarks: string;
|
remarks: string;
|
||||||
|
subject: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TransactionListType = Array<TransactionType>;
|
export type TransactionListType = Array<TransactionType>;
|
||||||
|
@ -134,6 +137,7 @@ export type TransactionCreateType = {
|
||||||
remarks: string;
|
remarks: string;
|
||||||
teacher: number;
|
teacher: number;
|
||||||
borrower: number;
|
borrower: number;
|
||||||
|
subject: string;
|
||||||
transaction_status: "Pending Approval";
|
transaction_status: "Pending Approval";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ export default function AddTransactionPage() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [selecteditems, SetSelectedItems] = useState<number[]>([]);
|
const [selecteditems, SetSelectedItems] = useState<number[]>([]);
|
||||||
const [selectedteacher, SetSelectedTeacher] = useState<number>(0);
|
const [selectedteacher, SetSelectedTeacher] = useState<number>(0);
|
||||||
|
const [subject, SetSubject] = useState("");
|
||||||
const [remarks, SetRemarks] = useState("");
|
const [remarks, SetRemarks] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
||||||
|
@ -129,7 +130,8 @@ export default function AddTransactionPage() {
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
SetSelectedTeacher(event.target.value as number)
|
SetSelectedTeacher(event.target.value as number)
|
||||||
}
|
}
|
||||||
input={<OutlinedInput label="Name" />}
|
label={"Assigned Teacher"}
|
||||||
|
input={<OutlinedInput label="Assigned Teacher" />}
|
||||||
>
|
>
|
||||||
{teachers.data?.map((teacher) => (
|
{teachers.data?.map((teacher) => (
|
||||||
<MenuItem key={teacher.id} value={teacher.id}>
|
<MenuItem key={teacher.id} value={teacher.id}>
|
||||||
|
@ -138,6 +140,21 @@ export default function AddTransactionPage() {
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
<FormControl style={{ marginTop: "8px" }}>
|
||||||
|
<FormLabel style={styles.text_dark}>Subject</FormLabel>
|
||||||
|
<TextField
|
||||||
|
style={styles.input_form}
|
||||||
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
SetSubject(e.target.value);
|
||||||
|
setError("");
|
||||||
|
}}
|
||||||
|
label={"Subject"}
|
||||||
|
value={subject}
|
||||||
|
placeholder={"The subject requiring the equipments"}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl style={{ marginTop: "8px" }}>
|
||||||
|
<FormLabel style={styles.text_dark}>Remarks</FormLabel>
|
||||||
<TextField
|
<TextField
|
||||||
multiline
|
multiline
|
||||||
style={styles.input_form}
|
style={styles.input_form}
|
||||||
|
@ -145,9 +162,11 @@ export default function AddTransactionPage() {
|
||||||
SetRemarks(e.target.value);
|
SetRemarks(e.target.value);
|
||||||
setError("");
|
setError("");
|
||||||
}}
|
}}
|
||||||
|
label={"Remarks"}
|
||||||
value={remarks}
|
value={remarks}
|
||||||
placeholder={"Optionally add a brief description of the request"}
|
placeholder={"Optionally add a brief description of the request"}
|
||||||
/>
|
/>
|
||||||
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
<p style={{ ...styles.text_dark, ...styles.text_M }}>{error}</p>
|
<p style={{ ...styles.text_dark, ...styles.text_M }}>{error}</p>
|
||||||
<div
|
<div
|
||||||
|
@ -167,6 +186,7 @@ export default function AddTransactionPage() {
|
||||||
const data = await TransactionCreateAPI({
|
const data = await TransactionCreateAPI({
|
||||||
equipments: selecteditems,
|
equipments: selecteditems,
|
||||||
teacher: selectedteacher,
|
teacher: selectedteacher,
|
||||||
|
subject: subject,
|
||||||
remarks: remarks || " ",
|
remarks: remarks || " ",
|
||||||
transaction_status: "Pending Approval",
|
transaction_status: "Pending Approval",
|
||||||
borrower: user.data?.id || 0,
|
borrower: user.data?.id || 0,
|
||||||
|
|
Loading…
Reference in a new issue