Files
InvoiceShelf/resources/scripts/components/base/BaseCustomerSelectInput.vue
Darko Gjorgjijoski 71388ec6a5 Rename resources/scripts-v2 to resources/scripts and drop @v2 alias
Now that the legacy v1 frontend (commit 064bdf53) is gone, the v2 directory is the only frontend and the v2 suffix is just noise. Renames resources/scripts-v2 to resources/scripts via git mv (so git records the move as renames, preserving blame and log --follow), then bulk-rewrites the 152 files that imported via @v2/... to use @/scripts/... instead. The existing @ alias (resources/) covers the new path with no extra config needed.

Drops the now-unused @v2 alias from vite.config.js and points the laravel-vite-plugin entry at resources/scripts/main.ts. Updates the only blade reference (resources/views/app.blade.php) to match. The package.json test script (eslint ./resources/scripts) automatically targets the right place after the rename without any edit.

Verified: npm run build exits clean and the Vite warning lines now reference resources/scripts/plugins/i18n.ts, confirming every import resolved through the new path. git log --follow on any moved file walks back through its scripts-v2 history.
2026-04-07 12:50:16 +02:00

105 lines
2.6 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useCustomerStore } from '../../features/company/customers/store'
import { useModalStore } from '../../stores/modal.store'
import { useUserStore } from '../../stores/user.store'
import { ABILITIES } from '../../config/abilities'
import CustomerModal from '../../features/company/customers/components/CustomerModal.vue'
interface Props {
modelValue?: string | number | Record<string, unknown> | null
fetchAll?: boolean
showAction?: boolean
}
const props = withDefaults(defineProps<Props>(), {
modelValue: '',
fetchAll: false,
showAction: false,
})
const emit = defineEmits<{
(e: 'update:modelValue', value: string | number | Record<string, unknown> | null): void
}>()
const { t } = useI18n()
const modalStore = useModalStore()
const customerStore = useCustomerStore()
const userStore = useUserStore()
const selectedCustomer = computed({
get: () => props.modelValue,
set: (value) => {
emit('update:modelValue', value as string | number | Record<string, unknown> | null)
},
})
async function searchCustomers(search: string) {
const data: Record<string, unknown> = { search }
if (props.fetchAll) {
data.limit = 'all'
}
const response = await customerStore.fetchCustomers(data)
const results = response.data ?? []
if (results.length > 0 && customerStore.editCustomer) {
const customerFound = results.find(
(c: Record<string, unknown>) => c.id === customerStore.editCustomer?.id
)
if (!customerFound) {
const editCopy = { ...customerStore.editCustomer }
results.unshift(editCopy as typeof results[0])
}
}
return results
}
function addCustomer(): void {
customerStore.resetCurrentCustomer()
modalStore.openModal({
title: t('customers.add_new_customer'),
componentName: 'CustomerModal',
})
}
</script>
<template>
<BaseMultiselect
v-model="selectedCustomer"
v-bind="$attrs"
track-by="name"
value-prop="id"
label="name"
:filter-results="false"
resolve-on-load
:delay="500"
:searchable="true"
:options="searchCustomers"
label-value="name"
:placeholder="$t('customers.type_or_click')"
:can-deselect="false"
class="w-full"
>
<template v-if="showAction" #action>
<BaseSelectAction
v-if="userStore.hasAbilities(ABILITIES.CREATE_CUSTOMER)"
@click="addCustomer"
>
<BaseIcon
name="UserPlusIcon"
class="h-4 mr-2 -ml-2 text-center text-primary-400"
/>
{{ $t('customers.add_new_customer') }}
</BaseSelectAction>
</template>
</BaseMultiselect>
<CustomerModal />
</template>