mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-28 03:55:02 +03:00
Refactor to use full name instead of first and last name
Redesigned the user profile page to receive Full Name instead of First and Last name. The user update method was adjusted to handle this change. Inputs in the UI that took the first and last name as separate inputs have also been modified to only accept a single name input. Here's a summary of what was changed: - The First Name and Last Name fields were replaced with a Full Name field in the form. - The functions that submitted or processed first and last name data have been simplified to process full name data. - The client-side and server-side code handling the user update has also been updated to handle only full name. - Any relevant variable names were also updated to reflect this change. - The user object now only checks and assigns the `name` property, instead of `given_name` and `family_name`. As a note, this simplifies the form and the process but some user's may find the change limiting if they typically prefer to provide their names separately for their first and last names.
This commit is contained in:
parent
38cf33d7c6
commit
e9bc1f02d7
@ -153,16 +153,10 @@ export default (
|
|||||||
'X-Auth-Token': token
|
'X-Auth-Token': token
|
||||||
}
|
}
|
||||||
}).then(parseResponseJSON),
|
}).then(parseResponseJSON),
|
||||||
update: async (
|
update: async (token: string, params: { name?: string; picture?: File }) => {
|
||||||
token: string,
|
|
||||||
params: { given_name?: string; family_name?: string; picture?: File }
|
|
||||||
) => {
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if (params.given_name) {
|
if (params.name) {
|
||||||
formData.append('given_name', params.given_name);
|
formData.append('name', params.name);
|
||||||
}
|
|
||||||
if (params.family_name) {
|
|
||||||
formData.append('family_name', params.family_name);
|
|
||||||
}
|
}
|
||||||
if (params.picture) {
|
if (params.picture) {
|
||||||
formData.append('avatar', params.picture);
|
formData.append('avatar', params.picture);
|
||||||
|
@ -37,8 +37,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let newGivenName = '';
|
let newName = '';
|
||||||
let newFamilyName = '';
|
|
||||||
|
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
$: if ($user && !loaded) {
|
$: if ($user && !loaded) {
|
||||||
@ -46,8 +45,7 @@
|
|||||||
cloud.user.get($user?.access_token).then((cloudUser) => {
|
cloud.user.get($user?.access_token).then((cloudUser) => {
|
||||||
$user = cloudUser;
|
$user = cloudUser;
|
||||||
});
|
});
|
||||||
newGivenName = $user?.given_name || $user?.name;
|
newName = $user?.name || '';
|
||||||
newFamilyName = $user?.family_name || '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = async (e: SubmitEvent) => {
|
const onSubmit = async (e: SubmitEvent) => {
|
||||||
@ -60,8 +58,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$user = await cloud.user.update($user.access_token, {
|
$user = await cloud.user.update($user.access_token, {
|
||||||
given_name: newGivenName,
|
name: newName,
|
||||||
family_name: newFamilyName,
|
|
||||||
picture: picture
|
picture: picture
|
||||||
});
|
});
|
||||||
toasts.success('Profile updated');
|
toasts.success('Profile updated');
|
||||||
@ -166,31 +163,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="contact-info" class="flex flex-1 flex-wrap">
|
<div id="contact-info" class="flex flex-1 flex-wrap">
|
||||||
<div class="basis-1/2 pr-4">
|
<div class="basis-full pr-4">
|
||||||
<label for="firstName" class="text-zinc-400">First name</label>
|
<label for="fullName" class="text-zinc-400">Full name</label>
|
||||||
<input
|
<input
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
autocorrect="off"
|
autocorrect="off"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
name="firstName"
|
name="firstName"
|
||||||
bind:value={newGivenName}
|
bind:value={newName}
|
||||||
type="text"
|
type="text"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
placeholder="First name can't be empty"
|
placeholder="Name can't be empty"
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="basis-1/2 pr-4">
|
|
||||||
<label for="lastName" class="text-zinc-400">Last name</label>
|
|
||||||
<input
|
|
||||||
autocomplete="off"
|
|
||||||
autocorrect="off"
|
|
||||||
spellcheck="false"
|
|
||||||
name="lastName"
|
|
||||||
bind:value={newFamilyName}
|
|
||||||
type="text"
|
|
||||||
class="w-full"
|
|
||||||
placeholder="Last name can't be empty"
|
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user