Compare commits

...

2 Commits

Author SHA1 Message Date
760df64876 precents 2023-07-26 11:22:25 +02:00
18dc329932 evepraisal id 2023-07-26 11:06:01 +02:00
6 changed files with 89 additions and 26 deletions

View File

@@ -3,3 +3,8 @@ export const iskFormater = new Intl.NumberFormat("is-IS", {
currency: "ISK",
minimumFractionDigits: 2,
});
export const percentFormater = new Intl.NumberFormat("en-US", {
style: "percent",
minimumFractionDigits: 0
});

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
import { iskFormater } from '@/utils';
import { useStorage } from '@vueuse/core';
import { ref } from 'vue';
import ReprocessInput from './ReprocessInput.vue';
import ReprocessResultTable from './ReprocessResultTable.vue';
import { ReprocessItemValues, reprocess } from './reprocess';
const items = ref("");
@@ -26,29 +26,13 @@ const send = async () => result.value = await reprocess(items.value, minerals.va
<ReprocessInput name="Item JSON" v-model="items" />
<ReprocessInput name="Mineral JSON" v-model="minerals" />
</div>
<div class="grid mt-2 px-4">
<div class="grid my-2 px-4">
<button class="py-0.5 px-2 justify-self-end border rounded bg-slate-200" @click="send">Send</button>
</div>
<div v-if="result.length > 0" class="grid mt-2 px-4">
<table class="table-auto border-collapse border w-full">
<thead>
<tr>
<th class="border bg-slate-200">Item</th>
<th class="border bg-slate-200">Buy</th>
<th class="border bg-slate-200">Buy reprocess</th>
<th class="border bg-slate-200">Sell</th>
<th class="border bg-slate-200">Sell reprocess</th>
</tr>
</thead>
<tbody>
<tr v-for="r in result" :key="r.typeID" :class="{'bg-green-200': r.buy_reprocess >= r.sell}">
<td class="border px-1">{{ r.typeID }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.buy) }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.buy_reprocess) }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.sell) }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.sell_reprocess) }}</td>
</tr>
</tbody>
</table>
</div>
<template v-if="result.length > 0">
<hr />
<div class="grid mt-2 px-4">
<ReprocessResultTable :result="result" />
</div>
</template>
</template>

View File

@@ -1,4 +1,5 @@
<script setup lang="ts">
import { evepraisalAxiosInstance } from '@/service';
import { useVModel } from '@vueuse/core';
interface Props {
@@ -16,11 +17,28 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits<Emits>();
const value = useVModel(props, 'modelValue', emit);
const loadFromId = async (e: Event) => {
const input = e.target as HTMLInputElement;
const id = input.value;
if (!id) {
return;
}
const response = await evepraisalAxiosInstance.get(`/a/${id}.json`);
if (response.status !== 200) {
return;
}
value.value = JSON.stringify(response.data);
input.value = '';
}
</script>
<template>
<div class="flex-1 mx-1">
<span>{{ name }}</span>
<textarea class="w-full border rounded" v-model="value" />
<span>{{ name }}</span><input type="text" class="border rounded ms-2 px-1" @change="loadFromId" placeholder="id evepraisal" />
<textarea class="w-full border rounded mt-1" v-model="value" />
</div>
</template>

View File

@@ -0,0 +1,42 @@
<script setup lang="ts">
import { iskFormater, percentFormater } from '@/formaters';
import { computed } from 'vue';
import { ReprocessItemValues } from './reprocess';
interface Props {
result?: ReprocessItemValues[];
}
const props = withDefaults(defineProps<Props>(), {
result: () => []
});
const computedResult = computed(() => props.result.map(r =>({
...r,
buy_ratio: (r.buy_reprocess / r.buy) - 1,
sell_ratio: (r.sell_reprocess / r.sell) - 1
})))
</script>
<template>
<table class="table-auto border-collapse border w-full">
<thead>
<tr>
<th class="border bg-slate-200">Item</th>
<th class="border bg-slate-200">Buy</th>
<th class="border bg-slate-200">Buy reprocess</th>
<th class="border bg-slate-200">Sell</th>
<th class="border bg-slate-200">Sell reprocess</th>
</tr>
</thead>
<tbody>
<tr v-for="r in computedResult" :key="r.typeID" :class="{'bg-green-200': r.buy_reprocess >= r.sell}">
<td class="border px-1">{{ r.typeID }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.buy) }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.buy_reprocess) }} ({{percentFormater.format(r.buy_ratio)}})</td>
<td class="border text-right px-1">{{ iskFormater.format(r.sell) }}</td>
<td class="border text-right px-1">{{ iskFormater.format(r.sell_reprocess) }} ({{percentFormater.format(r.sell_ratio)}})</td>
</tr>
</tbody>
</table>
</template>@/formaters

View File

@@ -6,4 +6,12 @@ export const apiAxiosInstance = axios.create({
'accept': 'application/json',
"Content-Type": "application/json"
},
})
export const evepraisalAxiosInstance = axios.create({
baseURL: '/appraisal/',
headers: {
'accept': 'application/json',
"Content-Type": "application/json"
},
})

View File

@@ -20,6 +20,12 @@ export default defineConfig({
changeOrigin: true,
followRedirects: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/appraisal/': {
target: 'https://evepraisal.shendai.rip/',
changeOrigin: true,
followRedirects: true,
rewrite: (path) => path.replace(/^\/appraisal/, ''),
}
}
},