ForceExitForm -> script setup

This commit is contained in:
Matthias 2023-02-15 07:05:27 +01:00
parent 3884bc3f68
commit 9b009e8158

View File

@ -60,45 +60,42 @@
</div>
</template>
<script lang="ts">
<script setup lang="ts">
import { useBotStore } from '@/stores/ftbotwrapper';
import { ForceSellPayload, Trade } from '@/types';
import { defineComponent, ref, computed } from 'vue';
import { ref, computed } from 'vue';
export default defineComponent({
name: 'ForceExitForm',
props: {
const props = defineProps({
trade: {
type: Object as () => Trade,
required: true,
},
modelValue: { required: true, default: false, type: Boolean },
},
emits: ['update:modelValue'],
setup(props, { emit }) {
const botStore = useBotStore();
});
const emit = defineEmits(['update:modelValue']);
const botStore = useBotStore();
const form = ref<HTMLFormElement>();
const amount = ref<number | undefined>(undefined);
const ordertype = ref('limit');
const form = ref<HTMLFormElement>();
const amount = ref<number | undefined>(undefined);
const ordertype = ref('limit');
const checkFormValidity = () => {
const checkFormValidity = () => {
const valid = form.value?.checkValidity();
return valid;
};
};
const model = computed({
const model = computed({
get() {
return props.modelValue;
},
set(value: boolean) {
emit('update:modelValue', value);
},
});
});
const handleSubmit = () => {
const handleSubmit = () => {
// Exit when the form isn't valid
if (!checkFormValidity()) {
return;
@ -114,8 +111,8 @@ export default defineComponent({
}
botStore.activeBot.forceexit(payload);
model.value = false;
};
const resetForm = () => {
};
const resetForm = () => {
amount.value = props.trade.amount;
if (botStore.activeBot.botApiVersion > 1.1) {
ordertype.value =
@ -123,22 +120,10 @@ export default defineComponent({
botStore.activeBot.botState?.order_types?.exit ||
'limit';
}
};
};
const handleEntry = () => {
const handleEntry = () => {
// Trigger submit handler
handleSubmit();
};
return {
handleSubmit,
botStore,
form,
handleEntry,
resetForm,
amount,
ordertype,
model,
};
},
});
};
</script>