mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2025-05-18 20:38:14 +08:00
Added initial widgets in dashboard
This commit is contained in:
parent
45c9fd588a
commit
2c0ae6770c
5 changed files with 235 additions and 9 deletions
|
@ -2,9 +2,11 @@
|
|||
import axios from "axios";
|
||||
import {
|
||||
ActivationType,
|
||||
EquipmentListType,
|
||||
LoginType,
|
||||
RegisterType,
|
||||
ResetPasswordConfirmType,
|
||||
EquipmentInstanceListType,
|
||||
} from "../Types/Types";
|
||||
|
||||
const instance = axios.create({
|
||||
|
@ -106,6 +108,7 @@ export async function JWTRefreshAPI() {
|
|||
return true;
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("Error refreshing token");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
@ -119,7 +122,6 @@ export async function UserAPI() {
|
|||
})
|
||||
.catch(() => {
|
||||
console.log("Error retrieving user data");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,11 +130,9 @@ export function ActivationAPI(activation: ActivationType) {
|
|||
.post("api/v1/accounts/users/activation/", activation)
|
||||
.then(() => {
|
||||
console.log("Activation Success");
|
||||
return true;
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("Activation failed");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
export function ResetPasswordAPI(email: string) {
|
||||
|
@ -140,11 +140,9 @@ export function ResetPasswordAPI(email: string) {
|
|||
.post("api/v1/accounts/users/reset_password/", { email: email })
|
||||
.then(() => {
|
||||
console.log("Activation Success");
|
||||
return true;
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("Activation failed");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -153,10 +151,34 @@ export function ResetPasswordConfirmAPI(info: ResetPasswordConfirmType) {
|
|||
.post("api/v1/accounts/users/reset_password_confirm/", info)
|
||||
.then(() => {
|
||||
console.log("Reset Success");
|
||||
return true;
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("Reset failed");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Equipment APIs
|
||||
|
||||
export async function EquipmentsAPI() {
|
||||
const config = await GetConfig();
|
||||
return instance
|
||||
.get("api/v1/equipments/equipments/", config)
|
||||
.then((response) => {
|
||||
return response.data as EquipmentListType;
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("Error retrieving equipments");
|
||||
});
|
||||
}
|
||||
|
||||
export async function EquipmentInstancesAPI() {
|
||||
const config = await GetConfig();
|
||||
return instance
|
||||
.get("api/v1/equipments/equipment_instances/", config)
|
||||
.then((response) => {
|
||||
return response.data as EquipmentInstanceListType;
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("Error retrieving equipments");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ export default function Header(props: props) {
|
|||
}}
|
||||
/>
|
||||
</div>
|
||||
<p style={{ ...styles.text_light, ...styles.text_M, ...{ flex: 1 } }}>
|
||||
<p style={{ ...styles.text_light, ...styles.text_L, ...{ flex: 1 } }}>
|
||||
{props.label}
|
||||
</p>
|
||||
<div style={{ flex: 1 }} />
|
||||
|
|
|
@ -26,3 +26,26 @@ export type AddEquipmentType = {
|
|||
name: string;
|
||||
remarks: string;
|
||||
};
|
||||
|
||||
export type EquipmentType = {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
last_updated: string;
|
||||
last_updated_by: string;
|
||||
date_added: string;
|
||||
};
|
||||
|
||||
export type EquipmentListType = Array<EquipmentType>;
|
||||
|
||||
export type EquipmentInstanceType = {
|
||||
id: number;
|
||||
equipment: string;
|
||||
status: string;
|
||||
remarks: string;
|
||||
last_updated: string;
|
||||
last_updated_by: string;
|
||||
date_added: string;
|
||||
};
|
||||
|
||||
export type EquipmentInstanceListType = Array<EquipmentInstanceType>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue