-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some prototype data for the stores
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script> | ||
import { writable } from "svelte/store"; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |