Fix: Set Slug when creating/updating first company

This commit is contained in:
lupus0802
2026-03-25 13:05:23 +01:00
parent 7e8f9e65fb
commit ed7af3fc3c

View File

@@ -164,6 +164,7 @@
<script setup> <script setup>
import { ref, computed, onMounted, reactive } from 'vue' import { ref, computed, onMounted, reactive } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { deburr } from 'lodash'
import { required, maxLength, helpers } from '@vuelidate/validators' import { required, maxLength, helpers } from '@vuelidate/validators'
import { useVuelidate } from '@vuelidate/core' import { useVuelidate } from '@vuelidate/core'
import { useGlobalStore } from '@/scripts/admin/stores/global' import { useGlobalStore } from '@/scripts/admin/stores/global'
@@ -180,6 +181,7 @@ let logoFileName = ref(null)
const companyForm = reactive({ const companyForm = reactive({
name: null, name: null,
slug: null,
tax_id: null, tax_id: null,
vat_id: null, vat_id: null,
address: { address: {
@@ -251,6 +253,18 @@ async function next() {
} }
isSaving.value = true isSaving.value = true
// Generate slug from company name (imitate Laravel's Str::slug)
if (companyForm.name) {
companyForm.slug = deburr(companyForm.name) // Remove accents etc.
.toLowerCase()
.trim()
.replace(/_/g, '-')
.replace(/[^a-z0-9\s-]/g, '') // Remove all non-alphanumeric chars
.replace(/[\s-]+/g, '-')
.replace(/^-+|-+$/g, '') // Trim dashes
}
let res = companyStore.updateCompany(companyForm) let res = companyStore.updateCompany(companyForm)
if (res) { if (res) {
if (logoFileBlob.value) { if (logoFileBlob.value) {