2022-12-26 10:35:52 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import {
|
|
|
|
|
notificationController,
|
|
|
|
|
NotificationType,
|
|
|
|
|
} from '$lib/components/shared-components/notification/notification';
|
2024-02-22 15:36:14 +01:00
|
|
|
import SettingInputField, {
|
|
|
|
|
SettingInputFieldType,
|
|
|
|
|
} from '$lib/components/shared-components/settings/setting-input-field.svelte';
|
2024-05-26 18:15:52 -04:00
|
|
|
import { user } from '$lib/stores/user.store';
|
|
|
|
|
import { updateMyUser } from '@immich/sdk';
|
|
|
|
|
import { cloneDeep } from 'lodash-es';
|
|
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
import { handleError } from '../../utils/handle-error';
|
|
|
|
|
import Button from '../elements/buttons/button.svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
let editedUser = cloneDeep($user);
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleSaveProfile = async () => {
|
|
|
|
|
try {
|
2024-05-26 18:15:52 -04:00
|
|
|
const data = await updateMyUser({
|
|
|
|
|
userUpdateMeDto: {
|
2024-02-13 02:47:26 +01:00
|
|
|
email: editedUser.email,
|
|
|
|
|
name: editedUser.name,
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
|
|
|
|
});
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
Object.assign(editedUser, data);
|
|
|
|
|
$user = data;
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
notificationController.show({
|
2024-06-04 21:53:00 +02:00
|
|
|
message: $t('saved_profile'),
|
2023-07-01 00:50:47 -04:00
|
|
|
type: NotificationType.Info,
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
2024-06-04 21:53:00 +02:00
|
|
|
handleError(error, $t('errors.unable_to_save_profile'));
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
};
|
2022-12-26 10:35:52 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<section class="my-4">
|
2023-07-01 00:50:47 -04:00
|
|
|
<div in:fade={{ duration: 500 }}>
|
|
|
|
|
<form autocomplete="off" on:submit|preventDefault>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="ml-4 mt-4 flex flex-col gap-4">
|
2023-07-01 00:50:47 -04:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.TEXT}
|
2024-06-04 21:53:00 +02:00
|
|
|
label={$t('user_id').toUpperCase()}
|
2024-02-13 02:47:26 +01:00
|
|
|
bind:value={editedUser.id}
|
2023-07-01 00:50:47 -04:00
|
|
|
disabled={true}
|
|
|
|
|
/>
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-06-04 21:53:00 +02:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.EMAIL}
|
|
|
|
|
label={$t('email').toUpperCase()}
|
|
|
|
|
bind:value={editedUser.email}
|
|
|
|
|
/>
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2024-02-13 02:47:26 +01:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.TEXT}
|
2024-06-04 21:53:00 +02:00
|
|
|
label={$t('name').toUpperCase()}
|
2024-02-13 02:47:26 +01:00
|
|
|
bind:value={editedUser.name}
|
|
|
|
|
required={true}
|
|
|
|
|
/>
|
2022-12-26 10:35:52 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<SettingInputField
|
|
|
|
|
inputType={SettingInputFieldType.TEXT}
|
2024-06-04 21:53:00 +02:00
|
|
|
label={$t('storage_label').toUpperCase()}
|
2023-07-01 00:50:47 -04:00
|
|
|
disabled={true}
|
2024-02-13 02:47:26 +01:00
|
|
|
value={editedUser.storageLabel || ''}
|
2023-07-01 00:50:47 -04:00
|
|
|
required={false}
|
|
|
|
|
/>
|
2023-05-21 23:18:10 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="flex justify-end">
|
2024-06-04 21:53:00 +02:00
|
|
|
<Button type="submit" size="sm" on:click={() => handleSaveProfile()}>{$t('save')}</Button>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2022-12-26 10:35:52 -05:00
|
|
|
</section>
|