Files
exchange-2.0/resources/assets/vue/components/settings/forms/AddCurrencyFormComponent.vue
T

77 lines
3.1 KiB
Vue

<template>
<div class="row">
<div class="col">
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
<div class="row" v-show="!isLoading">
<div class="col">
<div class="row m-b-10">
<div class="col">
<h3 class="all-caps m-b-5 bold no-margin">New Currency</h3>
<div class="fs-11">Select a country below to add its currency to the system</div>
</div>
</div>
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
<div class="col">
<small class="bold fs-10 text-danger">{{ error }}</small>
</div>
</div>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component selectable :validator="v$.parameters.country_short_code">
<label>Currency</label>
<selectable-component :endpoint="route('api.service.list.countries')" section="countriesListSection" valueColumn="iso_3166_1_alpha2" :labelColumn="['currency', 'name']" v-model="parameters.country_short_code"></selectable-component>
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-5">
<div class="col text-right">
<div class="fs-8 muted">** Added currencies need to be activate for services before they become transferable</div>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Not Now</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm">Add Currency</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useFormHandler } from '@/composables/useFormHandler';
import { useVuelidate } from '@vuelidate/core';
import { required } from '@vuelidate/validators';
import route from '@/general/functions/router';
interface Props {
section: string;
}
const props = defineProps<Props>();
const { parameters, submit, error, isLoading } = useFormHandler({
section: props.section,
data: {
country_short_code: ''
}
});
const rules = {
parameters: {
country_short_code: { required }
}
};
const v$ = useVuelidate(rules, { parameters });
const submitForm = async () => {
const isValid = await v$.value.$validate();
if (!isValid) return;
submit(route('api.currency.create'), 'post', props.section, true, false, parameters.value);
};
</script>