@thunderstorefront/sdk
Version:
Create Nuxt extendable layer with this GitHub template.
23 lines (18 loc) • 643 B
text/typescript
import type { StoreConfig } from '@thunderstorefront/types';
import type { Ref } from 'vue';
export interface UseStoreConfig {
storeConfig: Ref<StoreConfig | null>;
updateStoreConfig: (storeId: string) => Promise<StoreConfig>;
}
export function useStoreConfig(): UseStoreConfig {
const storeConfig = useState<StoreConfig | null>('storeConfig', () => null);
const { fetchStoreConfig } = useStoreConfigApi();
async function updateStoreConfig(storeId: string): Promise<StoreConfig> {
storeConfig.value = await fetchStoreConfig(storeId);
return storeConfig.value;
}
return {
storeConfig,
updateStoreConfig
};
}