This commit is contained in:
2025-08-27 12:46:16 -04:00
parent a641b4e2d1
commit dc0ea9d4c7
3 changed files with 66 additions and 66 deletions

View File

@ -49,7 +49,7 @@ const Applications: React.FC = () => {
token_renewal_duration: '24h',
max_token_duration: '168h',
owner: {
type: 'user',
type: 'individual',
name: 'Admin User',
owner: 'admin@example.com',
},
@ -82,17 +82,40 @@ const Applications: React.FC = () => {
}
};
const parseDuration = (duration: string): number => {
// Convert duration string like "24h" to seconds
const match = duration.match(/^(\d+)([hmd]?)$/);
if (!match) return 86400; // Default to 24h in seconds
const value = parseInt(match[1]);
const unit = match[2] || 'h';
switch (unit) {
case 'm': return value * 60; // minutes to seconds
case 'h': return value * 3600; // hours to seconds
case 'd': return value * 86400; // days to seconds
default: return value * 3600; // default to hours
}
};
const handleSubmit = async (values: CreateApplicationRequest) => {
try {
// Convert duration strings to seconds for API
const apiValues = {
...values,
token_renewal_duration: parseDuration(values.token_renewal_duration),
max_token_duration: parseDuration(values.max_token_duration),
};
if (editingApp) {
await apiService.updateApplication(editingApp.app_id, values);
await apiService.updateApplication(editingApp.app_id, apiValues);
notifications.show({
title: 'Success',
message: 'Application updated successfully',
color: 'green',
});
} else {
await apiService.createApplication(values);
await apiService.createApplication(apiValues);
notifications.show({
title: 'Success',
message: 'Application created successfully',
@ -164,11 +187,8 @@ const Applications: React.FC = () => {
};
const appTypeOptions = [
{ value: 'web', label: 'Web Application' },
{ value: 'mobile', label: 'Mobile Application' },
{ value: 'api', label: 'API Service' },
{ value: 'cli', label: 'CLI Tool' },
{ value: 'service', label: 'Background Service' },
{ value: 'static', label: 'Static' },
{ value: 'user', label: 'User' },
];
const rows = applications.map((app) => (