jws-frontend/src/stores/options/index.ts
2024-06-24 11:10:28 +00:00

25 lines
572 B
TypeScript

import { ref } from 'vue';
import { defineStore } from 'pinia';
const useOptionStore = defineStore('optionStore', () => {
const globalOption = ref();
function mapOption(value: string) {
for (const category in globalOption.value) {
if (globalOption.value.hasOwnProperty(category)) {
const option = globalOption.value[category].find(
(opt: { value: string }) => opt.value === value,
);
if (option) return option.label;
}
}
}
return {
globalOption,
mapOption,
};
});
export default useOptionStore;