Update transaction entry to reflect borrower's course

This commit is contained in:
Keannu Bernasol 2023-12-29 18:44:18 +08:00
parent 564a7d41d8
commit f9b4729ee7
5 changed files with 129 additions and 11 deletions

View file

@ -11,6 +11,13 @@ import Button from "../Button/Button";
import { useNavigate } from "react-router-dom";
import { RegisterAPI } from "../API/API";
import { toast } from "react-toastify";
import {
Radio,
RadioGroup,
FormControlLabel,
FormControl,
FormLabel,
} from "@mui/material";
export default function RegisterModal() {
const navigate = useNavigate();
const [showPassword, setShowPassword] = useState(false);
@ -20,6 +27,7 @@ export default function RegisterModal() {
last_name: "",
username: "",
email: "",
course: "",
password: "",
confirm_password: "",
});
@ -78,6 +86,53 @@ export default function RegisterModal() {
value={user.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
id="outlined-helperText"
label="Username"
@ -181,6 +236,7 @@ export default function RegisterModal() {
email: "",
password: "",
confirm_password: "",
course: "",
});
} else {
setError(JSON.stringify(status[1]));

View file

@ -59,6 +59,15 @@ export default function TransactionEntry(props: props) {
Borrower: {props.transaction.borrower.name}{" "}
{`(ID:${props.transaction.borrower.id})`}
</p>
<p
style={{
...styles.text_dark,
...styles.text_S,
...{ textAlign: "left", margin: 0 },
}}
>
{`(${props.transaction.borrower.course})`}
</p>
<p
style={{
...styles.text_dark,
@ -69,6 +78,15 @@ export default function TransactionEntry(props: props) {
Teacher: {props.transaction.teacher.name}{" "}
{`(ID:${props.transaction.teacher.id})`}
</p>
<p
style={{
...styles.text_dark,
...styles.text_S,
...{ textAlign: "left", margin: 0 },
}}
>
Subject: {props.transaction.subject}
</p>
<p
style={{
...styles.text_dark,

View file

@ -57,6 +57,16 @@ export default function TransactionPDF(props: props) {
Borrower: {props.transaction.borrower.name}{" "}
{`(ID:${props.transaction.borrower.id})`}
</Text>
<Text
style={{
color: colors.font_dark,
fontSize: 16,
textAlign: "left",
margin: 0,
}}
>
{`(${props.transaction.borrower.course})`}
</Text>
<Text
style={{
color: colors.font_dark,
@ -68,6 +78,16 @@ export default function TransactionPDF(props: props) {
Teacher: {props.transaction.teacher.name}{" "}
{`(ID:${props.transaction.teacher.id})`}
</Text>
<Text
style={{
color: colors.font_dark,
fontSize: 16,
textAlign: "left",
margin: 0,
}}
>
Subject: {props.transaction.subject}
</Text>
<Text
style={{
color: colors.font_dark,

View file

@ -4,6 +4,7 @@ export type RegisterType = {
password: string;
first_name: string;
last_name: string;
course: string;
};
export type LoginType = {
@ -113,6 +114,7 @@ export type TransactionType = {
borrower: {
id: number;
name: string;
course: string;
};
teacher: {
id: number;
@ -125,6 +127,7 @@ export type TransactionType = {
transaction_status: string;
timestamp: string;
remarks: string;
subject: string;
};
export type TransactionListType = Array<TransactionType>;
@ -134,6 +137,7 @@ export type TransactionCreateType = {
remarks: string;
teacher: number;
borrower: number;
subject: string;
transaction_status: "Pending Approval";
};

View file

@ -30,6 +30,7 @@ export default function AddTransactionPage() {
const queryClient = useQueryClient();
const [selecteditems, SetSelectedItems] = useState<number[]>([]);
const [selectedteacher, SetSelectedTeacher] = useState<number>(0);
const [subject, SetSubject] = useState("");
const [remarks, SetRemarks] = useState("");
const [error, setError] = useState("");
@ -129,7 +130,8 @@ export default function AddTransactionPage() {
onChange={(event) =>
SetSelectedTeacher(event.target.value as number)
}
input={<OutlinedInput label="Name" />}
label={"Assigned Teacher"}
input={<OutlinedInput label="Assigned Teacher" />}
>
{teachers.data?.map((teacher) => (
<MenuItem key={teacher.id} value={teacher.id}>
@ -138,16 +140,33 @@ export default function AddTransactionPage() {
))}
</Select>
</FormControl>
<TextField
multiline
style={styles.input_form}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
SetRemarks(e.target.value);
setError("");
}}
value={remarks}
placeholder={"Optionally add a brief description of the request"}
/>
<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
multiline
style={styles.input_form}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
SetRemarks(e.target.value);
setError("");
}}
label={"Remarks"}
value={remarks}
placeholder={"Optionally add a brief description of the request"}
/>
</FormControl>
</div>
<p style={{ ...styles.text_dark, ...styles.text_M }}>{error}</p>
<div
@ -167,6 +186,7 @@ export default function AddTransactionPage() {
const data = await TransactionCreateAPI({
equipments: selecteditems,
teacher: selectedteacher,
subject: subject,
remarks: remarks || " ",
transaction_status: "Pending Approval",
borrower: user.data?.id || 0,