mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-01 02:54:52 +00:00
Refactor Omada actions and enhance payment processing
- Simplified fetchOmadaGroupProfiles function by removing unnecessary parameters and using environment variables for base URL and API key. - Improved error handling in fetchOmadaGroupProfiles to check for error codes in the response. - Updated addDevicesToGroup function to remove redundant parameters and streamline device addition logic. - Integrated formatMacAddress utility to ensure consistent MAC address formatting during payment verification. - Enhanced verifyPayment function to include device addition upon successful payment verification, with improved logging. - Refactored DevicesToPay component to clean up payment verification logic and improve UI responsiveness. These changes enhance the clarity and efficiency of device management and payment processing functionalities.
This commit is contained in:
10
lib/utils.ts
10
lib/utils.ts
@ -16,3 +16,13 @@ export const formatDate = (date: Date): string => {
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
};
|
||||
|
||||
export const formatMacAddress = (mac: string): string => {
|
||||
const formatted = mac
|
||||
.replace(/[^A-Fa-f0-9]/g, "")
|
||||
.toUpperCase()
|
||||
.match(/.{2}/g);
|
||||
|
||||
// Provide a fallback if formatted is null
|
||||
return formatted ? formatted.join("-") : "";
|
||||
};
|
||||
|
Reference in New Issue
Block a user