feat(dashboard): reset new member/group input after submit

This commit is contained in:
Jake/Rads 2022-06-24 08:00:35 +02:00
parent f14fee9ae1
commit 30f3dcf031
2 changed files with 5 additions and 4 deletions

View File

@ -30,7 +30,7 @@
dispatch('create', input); dispatch('create', input);
} }
let input: Group = defaultGroup; let input: Group = JSON.parse(JSON.stringify(defaultGroup));
async function submit() { async function submit() {
let data = input; let data = input;
@ -51,7 +51,7 @@
loading = true; loading = true;
try { try {
let res = await api().groups().post({data}); let res = await api().groups().post({data});
input = res; input = JSON.parse(JSON.stringify(defaultGroup));
err = []; err = [];
create(); create();
message = `Group ${data.name} successfully created!` message = `Group ${data.name} successfully created!`

View File

@ -33,7 +33,8 @@
] ]
}; };
let input: Member = defaultMember; // creating a deep copy here so that defaultMember doesn't get updated too
let input: Member = JSON.parse(JSON.stringify(defaultMember));
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -91,7 +92,7 @@
input = res; input = res;
err = []; err = [];
create(); create();
input = defaultMember; input = JSON.parse(JSON.stringify(defaultMember));;
message = `Member ${data.name} successfully created!` message = `Member ${data.name} successfully created!`
loading = false; loading = false;
} catch (error) { } catch (error) {