25 lines
572 B
TypeScript
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;
|