Skip to content

Commit

Permalink
add some prototype data for the stores
Browse files Browse the repository at this point in the history
  • Loading branch information
MaHaWo committed Aug 26, 2024
1 parent c7ec047 commit 7623939
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/stores/childrenData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
import { writable } from "svelte/store";
</script>
26 changes: 26 additions & 0 deletions src/lib/stores/contentStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { writable } from 'svelte/store';

let contentlist = {
childrenSurveys: {},
registrationForms: {}
};

const content = writable(contentlist);

function addContent(type, key, content) {
content.update((contentlist) => {
contentlist[type][key] = content;
});
}

function removeContent(type, key) {
content.update((contentlist) => {
delete contentlist[type][key];
});
}

function getContent(type, key) {
return content.value[type][key];
}

export { addContent, content, getContent, removeContent };
34 changes: 34 additions & 0 deletions src/lib/stores/userData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-nocheck
import { writable } from 'svelte/store';

// FIXME: there must be something that is used to validate input - prototype for user data or so.
// this will eventually go into the backend, but for now it must reside here.

let userlist = {};

const users = writable(userlist);

async function addUser(userToken, userData) {
users.update((userlist) => {
if (userToken in userlist) {
// raise some error
} else {
userData['token'] = userToken;
userlist[userToken] = userData;
}
});
}

async function removeUser(userToken) {
users.update((userlist) => {
if (userToken in userlist) {
delete userlist[userToken];
}
});
}

async function getUser(userToken) {
return users.value[userToken];
}

export { addUser, getUser, removeUser, users };

0 comments on commit 7623939

Please sign in to comment.