mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-07-18 06:45:20 +00:00
Removes three layered gates that kept the Danger Zone completely hidden unless the current user had more than one company: 1. SettingsLayoutView's showDangerZone computed no longer checks companies.length > 1 — just is_owner. 2. DangerZoneView drops the v-if that wrapped the delete button with the same check. 3. Admin\\CompaniesController::destroy() drops the companies_count <= 1 early-return that was enforcing the rule server-side (translation key You_cannot_delete_all_companies was inline in the controller, not in lang files or tests, so nothing else needs cleanup). The reasoning behind the old gate was that a user with zero companies would be stranded. That's a misread of how the app degrades: /admin/no-company already exists as a graceful fallback view, and the user can create a fresh company from there to recover. Hiding the entire delete flow just to avoid that fallback UX was overkill — the name-confirmation modal already prevents accidental deletion.
39 lines
1007 B
Vue
39 lines
1007 B
Vue
<script setup lang="ts">
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useModalStore } from '../../../../stores/modal.store'
|
|
import DeleteCompanyModal from '../components/DeleteCompanyModal.vue'
|
|
|
|
const { t } = useI18n()
|
|
const modalStore = useModalStore()
|
|
|
|
function removeCompany(): void {
|
|
modalStore.openModal({
|
|
title: t('settings.company_info.are_you_absolutely_sure'),
|
|
componentName: 'DeleteCompanyModal',
|
|
size: 'sm',
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<BaseSettingCard
|
|
:title="$t('settings.company_info.danger_zone')"
|
|
:description="$t('settings.company_info.delete_company_description')"
|
|
>
|
|
<div class="mt-6">
|
|
<BaseButton
|
|
variant="danger"
|
|
type="button"
|
|
@click="removeCompany"
|
|
>
|
|
<template #left="slotProps">
|
|
<BaseIcon name="TrashIcon" :class="slotProps.class" />
|
|
</template>
|
|
{{ $t('settings.company_info.delete_company') }}
|
|
</BaseButton>
|
|
</div>
|
|
</BaseSettingCard>
|
|
|
|
<DeleteCompanyModal />
|
|
</template>
|