feat: add platform assignment to user and vendor creation forms
User create page: - When role=admin, show super admin toggle - If not super admin, show platform multi-select - Admin users created via /api/v1/admin/admin-users endpoint - Vendor users created via existing /admin/users endpoint Vendor create page: - Add platform selection section - Vendors can be assigned to multiple platforms on creation - Update VendorCreate schema to accept platform_ids - Update AdminService.create_vendor() to create VendorPlatform records Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,9 @@ function adminVendorCreate() {
|
||||
companies: [],
|
||||
loadingCompanies: true,
|
||||
|
||||
// Platforms list for selection
|
||||
platforms: [],
|
||||
|
||||
// Form data matching VendorCreate schema
|
||||
formData: {
|
||||
company_id: '',
|
||||
@@ -32,7 +35,8 @@ function adminVendorCreate() {
|
||||
description: '',
|
||||
letzshop_csv_url_fr: '',
|
||||
letzshop_csv_url_en: '',
|
||||
letzshop_csv_url_de: ''
|
||||
letzshop_csv_url_de: '',
|
||||
platform_ids: []
|
||||
},
|
||||
|
||||
// UI state
|
||||
@@ -49,7 +53,10 @@ function adminVendorCreate() {
|
||||
|
||||
try {
|
||||
vendorCreateLog.info('Initializing vendor create page');
|
||||
await this.loadCompanies();
|
||||
await Promise.all([
|
||||
this.loadCompanies(),
|
||||
this.loadPlatforms()
|
||||
]);
|
||||
} catch (error) {
|
||||
vendorCreateLog.error('Failed to initialize vendor create:', error);
|
||||
}
|
||||
@@ -70,6 +77,18 @@ function adminVendorCreate() {
|
||||
}
|
||||
},
|
||||
|
||||
// Load platforms for selection
|
||||
async loadPlatforms() {
|
||||
try {
|
||||
const response = await apiClient.get('/admin/platforms');
|
||||
this.platforms = response.platforms || response.items || [];
|
||||
vendorCreateLog.debug('Loaded platforms:', this.platforms.length);
|
||||
} catch (error) {
|
||||
vendorCreateLog.error('Failed to load platforms:', error);
|
||||
this.platforms = [];
|
||||
}
|
||||
},
|
||||
|
||||
// Auto-generate subdomain from vendor name
|
||||
autoGenerateSubdomain() {
|
||||
if (!this.formData.name) {
|
||||
@@ -124,6 +143,11 @@ function adminVendorCreate() {
|
||||
payload.letzshop_csv_url_de = this.formData.letzshop_csv_url_de;
|
||||
}
|
||||
|
||||
// Add platform assignments
|
||||
if (this.formData.platform_ids && this.formData.platform_ids.length > 0) {
|
||||
payload.platform_ids = this.formData.platform_ids.map(id => parseInt(id));
|
||||
}
|
||||
|
||||
const response = await apiClient.post('/admin/vendors', payload);
|
||||
|
||||
vendorCreateLog.info('Vendor created successfully:', response.vendor_code);
|
||||
@@ -147,7 +171,8 @@ function adminVendorCreate() {
|
||||
description: '',
|
||||
letzshop_csv_url_fr: '',
|
||||
letzshop_csv_url_en: '',
|
||||
letzshop_csv_url_de: ''
|
||||
letzshop_csv_url_de: '',
|
||||
platform_ids: []
|
||||
};
|
||||
|
||||
// Scroll to top to show success message
|
||||
|
||||
Reference in New Issue
Block a user