useCustomerAutoComplete.js 754B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Inertia } from '@inertiajs/inertia'
  2. import { useDialog } from 'primevue/usedialog'
  3. import { dialogStyle } from './config'
  4. import CustomerCreate from './Components/Dialog/CustomerCreate.vue'
  5. export function useCustomerAutoComplete(form) {
  6. const dialog = useDialog()
  7. const customerOnComplete = (event) => {
  8. Inertia.reload({
  9. data: { customer: event.query },
  10. only: ['customers'],
  11. })
  12. }
  13. const customerOnSelected = (event) => {
  14. form.customer = event.value
  15. }
  16. const showCreateCustomer = () => {
  17. dialog.open(CustomerCreate, {
  18. props: {
  19. header: 'Tambah Pelanggan',
  20. ...dialogStyle,
  21. },
  22. })
  23. }
  24. return {
  25. customerOnComplete,
  26. customerOnSelected,
  27. showCreateCustomer,
  28. }
  29. }