Materials Module
The Materials Module in E-Trans Dashboard allows users to add, update, and manage materials handled or transported by vehicles. This module ensures proper tracking of materials associated with customer orders and routes.
๐น Features
- Add new materials
- Edit existing material descriptions
- Real-time toast notifications for success, warning, or error
- Automatic redirection after save/update
๐ฅ๏ธ Form Fields
| Field | Type | Description |
|---|---|---|
| Material Description | Text | Name or description of the material (Required) |
๐ Example Usage (Vue 3 + Pinia)
import { ref } from 'vue'
import apiClient from '@/axios'
const material = ref({
materialDesc: 'Cement Bags'
})
const saveMaterial = async () => {
try {
await apiClient.post('/material', material.value)
console.log('Material added successfully')
} catch (error) {
console.error('Error saving material', error)
}
}
๐ API Endpoints
| Action | Method | Endpoint | Description |
|---|---|---|---|
| Add Material | POST | /material |
Add a new material |
| Update Material | PUT | /material/{id} |
Update an existing material |
| Get Material | GET | /material/{id} |
Fetch a single materialโs details |
| List Materials | GET | /material |
Fetch all materials |
โ Workflow
- Navigate to Materials from the sidebar.
- Click Add Material or Edit an existing material.
- Fill in the Material Description field.
- Click Save or Update.
-
Toast notifications will appear:
- โ Success
- โ Warning (duplicate material)
- โ Error (validation or server error)
- On success, the page redirects to Materials List.
๐ท Screenshot (Example)
