parent
178c2579d5
commit
3a4575f251
@ -2,6 +2,7 @@
|
||||
import { _ } from "svelte-i18n";
|
||||
import isEmail from "validator/es/lib/isEmail";
|
||||
import { MeService } from "@odit/lfk-client-js";
|
||||
import Toastify from "toastify-js";
|
||||
$: data_loaded = false;
|
||||
$: original_data = {};
|
||||
$: editable = {};
|
||||
@ -11,10 +12,31 @@
|
||||
$: save_enabled = changes_performed && isEmail(editable.email);
|
||||
const user_promise = MeService.meControllerGet().then((data) => {
|
||||
data_loaded = true;
|
||||
data.groups = data.groups.map(g => g.id);
|
||||
data.groups = data.groups.map((g) => g.id);
|
||||
data.permissions = [0]
|
||||
original_data = Object.assign(original_data, data);
|
||||
editable = Object.assign(editable, original_data);
|
||||
});
|
||||
function submit() {
|
||||
if (data_loaded === true && save_enabled) {
|
||||
Toastify({
|
||||
text: "Updating your profile...",
|
||||
duration: 2500,
|
||||
}).showToast();
|
||||
console.log(editable)
|
||||
MeService.meControllerPut(editable)
|
||||
.then((resp) => {
|
||||
console.log(resp)
|
||||
original_data = Object.assign(original_data, editable);
|
||||
Toastify({
|
||||
text: "Profile updated!",
|
||||
duration: 2500,
|
||||
backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
|
||||
}).showToast();
|
||||
})
|
||||
.catch((err) => {});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="pt-12 px-4 sm:px-6 lg:px-8 lg:pt-20 bg-gray-900 pb-12">
|
||||
@ -57,7 +79,7 @@
|
||||
<img
|
||||
alt={$_('profile-picture')}
|
||||
class="h-20 w-20 rounded-full overflow-hidden bg-gray-100"
|
||||
src={editable.profilePic || "https://lauf-fuer-kaya.de/lfk-logo.png"} />
|
||||
src={editable.profilePic || 'https://lauf-fuer-kaya.de/lfk-logo.png'} />
|
||||
</span>
|
||||
<!-- <button
|
||||
type="button"
|
||||
@ -136,6 +158,7 @@
|
||||
type="submit"
|
||||
disabled={!save_enabled}
|
||||
class:opacity-50={!save_enabled}
|
||||
on:click={submit}
|
||||
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
|
||||
{$_('save-changes')}
|
||||
</button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user