init
This commit is contained in:
commit
451223816b
338 changed files with 9938 additions and 0 deletions
38
src/lib/core/client/server.ts
Normal file
38
src/lib/core/client/server.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { get } from 'svelte/store';
|
||||
import { departmentStore } from '../stores/departments';
|
||||
import { sendMessage } from '../handlers/ws_messageSender';
|
||||
import { auth } from '../stores/auth';
|
||||
import { extractCookieOnNonBrowser } from '$lib/helpers/cookie';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export async function getRecipes() {
|
||||
if (browser && !get(departmentStore)) {
|
||||
console.log('cannot get dep', get(departmentStore));
|
||||
return [];
|
||||
}
|
||||
|
||||
let countryTarget = get(departmentStore);
|
||||
let country = '';
|
||||
|
||||
// if (!countryTarget && !browser) {
|
||||
// countryTarget = extractCookieOnNonBrowser()['department'];
|
||||
// }
|
||||
|
||||
// construct path. fetch (GET) {server}/recipe/{countryTarget}/{version}
|
||||
let idToken = await get(auth)?.getIdToken();
|
||||
|
||||
console.log('country target get recipe', country);
|
||||
|
||||
sendMessage({
|
||||
type: 'recipe',
|
||||
payload: {
|
||||
auth: idToken ?? '',
|
||||
partial: false,
|
||||
country: countryTarget ?? '',
|
||||
version: -1,
|
||||
parameters: ''
|
||||
}
|
||||
});
|
||||
|
||||
return [];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue