Company Module
The Company Module in E-Trans Dashboard allows administrators to add, update, and manage company details. This is an admin-only module used to maintain the companies using the dashboard.
πΉ Features
- Add new companies
- Edit existing company details
- Mobile number validation (Indian 10-digit format)
- GSTIN validation
- Prefix and Suffix for company codes
- Real-time toast notifications for success, warning, or error
- Automatic redirection after save/update
π₯οΈ Form Fields
| Field | Type | Description |
|---|---|---|
| Name | Text | Name of the company (Required) |
| Address | Text | Full address of the company (Required) |
| Mobile No | Text | Indian mobile number, 10 digits starting with 6-9 (Required) |
| GSTIN | Text | Company GST Identification Number (Required) |
| Prefix | Text | Code prefix for company documents (Required) |
| Suffix | Text | Code suffix for company documents (Required) |
β‘ Validations
Mobile Number
- Must be 10 digits
- Must start with 6,7,8, or 9
- Regex:
^[6-9]\d{9}$
GSTIN
- Must follow the Indian GSTIN format
- Regex:
^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$
π Example Usage (Vue 3 + Pinia)
import { ref } from 'vue'
import apiClient from '@/axios'
const company = ref({
name: 'ABC Pvt Ltd',
address: '123, Industrial Area, Mumbai',
mobileNo: '9876543210',
gstin: '27ABCDE1234F2Z5',
prefix: 'ABC',
suffix: '001'
})
const saveCompany = async () => {
try {
await apiClient.post('/dashboard/company', company.value)
console.log('Company added successfully')
} catch (error) {
console.error('Error saving company', error)
}
}
π API Endpoints
| Action | Method | Endpoint | Description |
|---|---|---|---|
| Add Company | POST | /dashboard/company |
Add a new company |
| Update Company | PUT | /dashboard/company/{id} |
Update existing company |
| Get Company | GET | /dashboard/company/{id} |
Fetch a single companyβs details |
| List Companies | GET | /dashboard/company |
Fetch all companies |
β Workflow
- Navigate to Company Module from the sidebar (Admin only).
- Click Add Company or Edit an existing company.
- Fill in all required fields.
- Validation will prevent invalid Mobile Numbers or GSTIN.
- Click Save or Update.
-
Toast notifications will appear:
- β Success
- β Warning (e.g., duplicate company)
- β Error (validation failure or server error)
- On success, the page redirects to Dashboard or Company List.
π· Screenshot (Example)
