Allow mixed-company cart, add delete confirmations, and fix profile settings routes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useCatalogStore } from '@/stores/catalog'
|
||||
import { useCartStore } from '@/stores/cart'
|
||||
import BaseButton from '@/components/ui/BaseButton.vue'
|
||||
import IconParLogo from '@/components/icons/IconParLogo.vue'
|
||||
import IconFamBaftLogo from '@/components/icons/IconFamBaftLogo.vue'
|
||||
import MobileCompanySelect from '@/views/companies/components/MobileCompanySelect.vue'
|
||||
@@ -15,9 +13,6 @@ const catalogStore = useCatalogStore()
|
||||
const cartStore = useCartStore()
|
||||
|
||||
const companies = catalogStore.getActiveCompanies()
|
||||
const showSwitchDialog = ref(false)
|
||||
const pendingCompanyId = ref<string | null>(null)
|
||||
const switchMessage = ref('')
|
||||
|
||||
const displayMeta: Record<string, { description: string; logo: typeof IconParLogo }> = {
|
||||
par: { description: 'تولید و عرضه انواع پارچه', logo: IconParLogo },
|
||||
@@ -25,28 +20,11 @@ const displayMeta: Record<string, { description: string; logo: typeof IconParLog
|
||||
}
|
||||
|
||||
function selectCompany(companyId: string) {
|
||||
const check = cartStore.canSwitchToCompany(companyId)
|
||||
if (!check.allowed) {
|
||||
pendingCompanyId.value = companyId
|
||||
switchMessage.value = check.message ?? ''
|
||||
showSwitchDialog.value = true
|
||||
return
|
||||
}
|
||||
goToCompany(companyId)
|
||||
}
|
||||
|
||||
function goToCompany(companyId: string) {
|
||||
const company = catalogStore.getCompany(companyId)
|
||||
if (!company) return
|
||||
cartStore.initCartForCompany(company)
|
||||
router.push(`/companies/${companyId}/catalogs`)
|
||||
}
|
||||
|
||||
function confirmSwitch() {
|
||||
if (pendingCompanyId.value) {
|
||||
goToCompany(pendingCompanyId.value)
|
||||
}
|
||||
showSwitchDialog.value = false
|
||||
cartStore.selectCompany(company)
|
||||
router.push(`/companies/${companyId}/catalogs`)
|
||||
}
|
||||
|
||||
function cardVariant(slug: string) {
|
||||
@@ -80,28 +58,4 @@ function companyLogo(slug: string) {
|
||||
:company-logo="companyLogo"
|
||||
@select="selectCompany"
|
||||
/>
|
||||
|
||||
<div v-if="showSwitchDialog" class="dialog-overlay" @click.self="showSwitchDialog = false">
|
||||
<div class="dialog card">
|
||||
<h3>تغییر شرکت</h3>
|
||||
<p class="text-sm">{{ switchMessage }}</p>
|
||||
<div class="dialog-actions">
|
||||
<BaseButton variant="outline" @click="showSwitchDialog = false">انصراف</BaseButton>
|
||||
<BaseButton @click="confirmSwitch">سبد جدید</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dialog h3 {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.dialog-actions {
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user