Files
crater/resources/scripts/admin/views/settings/customization/payments/PaymentsTabDefaultFormats.vue
Yash Kanakiya a32d36363d Dark mode add in BaseSettingsCard & BaseHeading (#1183)
* add dark mode in BaseSettingCard

* add dark mode in base heading
2023-03-28 16:14:30 +05:30

114 lines
2.5 KiB
Vue

<template>
<form @submit.prevent="submitForm">
<BaseHeading
type="heading-title"
:subtitle="
$t('settings.customization.payments.default_formats_description')
"
>
{{ $t('settings.customization.payments.default_formats') }}
</BaseHeading>
<BaseInputGroup
:label="$t('settings.customization.payments.default_payment_email_body')"
class="mt-6 mb-4"
>
<BaseCustomInput
v-model="formatSettings.payment_mail_body"
:fields="mailFields"
/>
</BaseInputGroup>
<BaseInputGroup
:label="$t('settings.customization.payments.company_address_format')"
class="mt-6 mb-4"
>
<BaseCustomInput
v-model="formatSettings.payment_company_address_format"
:fields="companyFields"
/>
</BaseInputGroup>
<BaseInputGroup
:label="
$t('settings.customization.payments.from_customer_address_format')
"
class="mt-6 mb-4"
>
<BaseCustomInput
v-model="formatSettings.payment_from_customer_address_format"
:fields="customerAddressFields"
/>
</BaseInputGroup>
<BaseButton
:loading="isSaving"
:disabled="isSaving"
variant="primary"
type="submit"
class="mt-4"
>
<template #left="slotProps">
<BaseIcon v-if="!isSaving" :class="slotProps.class" name="SaveIcon" />
</template>
{{ $t('settings.customization.save') }}
</BaseButton>
</form>
</template>
<script setup>
import { ref, reactive, inject } from 'vue'
import { useCompanyStore } from '@/scripts/admin/stores/company'
const companyStore = useCompanyStore()
const utils = inject('utils')
const mailFields = ref([
'customer',
'customerCustom',
'company',
'payment',
'paymentCustom',
])
const customerAddressFields = ref([
'billing',
'customer',
'customerCustom',
'paymentCustom',
])
const companyFields = ref(['company', 'paymentCustom'])
let isSaving = ref(false)
const formatSettings = reactive({
payment_mail_body: null,
payment_company_address_format: null,
payment_from_customer_address_format: null,
})
utils.mergeSettings(formatSettings, {
...companyStore.selectedCompanySettings,
})
async function submitForm() {
isSaving.value = true
let data = {
settings: {
...formatSettings,
},
}
await companyStore.updateCompanySettings({
data,
message: 'settings.customization.payments.payment_settings_updated',
})
isSaving.value = false
return true
}
</script>