Show success to user
This commit is contained in:
parent
c92557cd2a
commit
4d27aca6e5
|
@ -36,6 +36,7 @@
|
||||||
<button class="col-span-2" type="submit" :disabled="disabled">submit sell order</button>
|
<button class="col-span-2" type="submit" :disabled="disabled">submit sell order</button>
|
||||||
</form>
|
</form>
|
||||||
<div v-if="err" class="red text-center">{{ err }}</div>
|
<div v-if="err" class="red text-center">{{ err }}</div>
|
||||||
|
<div v-if="success" class="green text-center">{{ success }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -63,8 +64,9 @@ const toggleYes = () => {
|
||||||
const toggleNo = () => {
|
const toggleNo = () => {
|
||||||
selected.value = selected.value === 'NO' ? null : 'NO'
|
selected.value = selected.value === 'NO' ? null : 'NO'
|
||||||
}
|
}
|
||||||
// show errors below form
|
// show error and success below form
|
||||||
const err = ref(null)
|
const err = ref(null)
|
||||||
|
const success = ref(null)
|
||||||
// BUY or SELL?
|
// BUY or SELL?
|
||||||
const side = ref(route.query.side || 'BUY')
|
const side = ref(route.query.side || 'BUY')
|
||||||
|
|
||||||
|
@ -156,6 +158,10 @@ const submitSellForm = async () => {
|
||||||
})
|
})
|
||||||
const res = await fetch(url, { method: 'POST', headers: { 'Content-type': 'application/json' }, body })
|
const res = await fetch(url, { method: 'POST', headers: { 'Content-type': 'application/json' }, body })
|
||||||
const resBody = await res.json()
|
const resBody = await res.json()
|
||||||
|
if (res.status === 201) {
|
||||||
|
success.value = 'Order created'
|
||||||
|
return
|
||||||
|
}
|
||||||
if (res.status !== 402) {
|
if (res.status !== 402) {
|
||||||
err.value = `error: server responded with HTTP ${resBody.status}`
|
err.value = `error: server responded with HTTP ${resBody.status}`
|
||||||
return
|
return
|
||||||
|
|
|
@ -61,6 +61,9 @@ a.selected {
|
||||||
.red {
|
.red {
|
||||||
color: #ff7386;
|
color: #ff7386;
|
||||||
}
|
}
|
||||||
|
.green {
|
||||||
|
color: #35df8d;
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
background-color: rgba(245, 57, 94, .24);
|
background-color: rgba(245, 57, 94, .24);
|
||||||
|
|
Loading…
Reference in New Issue