* refactor: Use fetchCustomAttributes for user profile custom attributes feat: Add optional filter for empty custom attributes simplify and fix types add again the request time, take into account errors test: Update fetchCustomAttributes tests for filterEmpty parameter feat: Add sort_order to CustomAttribute in fetchCustomAttributes feat: Add optional sort_order to CustomAttribute type fix: Add type definition for sort_order in CustomProfileField attrs feat: Add sorting function for custom profile attributes docs: Add JSDoc comment explaining sortCustomProfileAttributes function refactor: Improve sortCustomProfileAttributes with nullish coalescing and localeCompare add order to custom profile attributes * remove blank line * add ordering to edit_profile screen * keep types together * address code review
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import type ClientBase from './base';
|
|
import type {CustomProfileAttributeSimple, CustomProfileField} from '@typings/api/custom_profile_attributes';
|
|
|
|
export interface ClientCustomAttributesMix {
|
|
getCustomProfileAttributeFields: () => Promise<CustomProfileField[]>;
|
|
getCustomProfileAttributeValues: (userID: string) => Promise<CustomProfileAttributeSimple>;
|
|
updateCustomProfileAttributeValues: (values: CustomProfileAttributeSimple) => Promise<string>;
|
|
}
|
|
|
|
const ClientCustomAttributes = <TBase extends Constructor<ClientBase>>(superclass: TBase) => class extends superclass {
|
|
getCustomProfileAttributeFields = async () => {
|
|
return this.doFetch(
|
|
`${this.getCustomProfileAttributesRoute()}/fields`,
|
|
{method: 'get'},
|
|
);
|
|
};
|
|
|
|
getCustomProfileAttributeValues = async (userID: string) => {
|
|
return this.doFetch(
|
|
`${this.getUserCustomProfileAttributesRoute(userID)}`,
|
|
{method: 'get'},
|
|
);
|
|
};
|
|
updateCustomProfileAttributeValues = async (values: CustomProfileAttributeSimple) => {
|
|
return this.doFetch(
|
|
`${this.getCustomProfileAttributesRoute()}/values`,
|
|
{
|
|
method: 'patch',
|
|
body: values,
|
|
},
|
|
);
|
|
};
|
|
};
|
|
|
|
export default ClientCustomAttributes;
|