-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlocalStorageUtil.js
More file actions
35 lines (31 loc) · 788 Bytes
/
localStorageUtil.js
File metadata and controls
35 lines (31 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const dummy_Data = [
{
id: crypto.randomUUID(),
text: "Walk the dog",
complete: false,
createdAt: null,
deadline: new Date().setMinutes(new Date().getMinutes() + 10),
},
{
id: crypto.randomUUID(),
text: "Do homework",
complete: true,
createdAt: null,
deadline: null,
},
];
/**
* return saved wishes data from local-storage.
* if no data is saved to localstorage then return dummy data
*/
export function getWishes() {
const wishes = JSON.parse(localStorage.getItem("solid-bucket-list"));
return wishes ? wishes : dummy_Data;
}
// Save new wish to localstorage
export function saveWish(wishes) {
localStorage.setItem("solid-bucket-list", JSON.stringify(wishes));
}
export function setComplete(wishes) {
saveWish(wishes);
}