pr feedback

This commit is contained in:
martabal 2023-11-13 16:46:30 +01:00
parent af0f2f005b
commit ac9e2cd316
No known key found for this signature in database
GPG key ID: C00196E3148A52BD
19 changed files with 57 additions and 464 deletions

View file

@ -2357,10 +2357,10 @@ export interface OAuthConfigResponseDto {
export interface PartnerResponseDto {
/**
*
* @type {string}
* @type {UserAvatarColor}
* @memberof PartnerResponseDto
*/
'avatarColor': PartnerResponseDtoAvatarColorEnum;
'avatarColor': UserAvatarColor;
/**
*
* @type {string}
@ -2447,20 +2447,6 @@ export interface PartnerResponseDto {
'updatedAt': string;
}
export const PartnerResponseDtoAvatarColorEnum = {
Primary: 'primary',
Pink: 'pink',
Red: 'red',
Yellow: 'yellow',
Blue: 'blue',
Green: 'green',
Purple: 'purple',
Orange: 'orange',
Gray: 'gray',
Amber: 'amber'
} as const;
export type PartnerResponseDtoAvatarColorEnum = typeof PartnerResponseDtoAvatarColorEnum[keyof typeof PartnerResponseDtoAvatarColorEnum];
/**
*
@ -4496,10 +4482,10 @@ export type UserAvatarColor = typeof UserAvatarColor[keyof typeof UserAvatarColo
export interface UserDto {
/**
*
* @type {string}
* @type {UserAvatarColor}
* @memberof UserDto
*/
'avatarColor': UserDtoAvatarColorEnum;
'avatarColor': UserAvatarColor;
/**
*
* @type {string}
@ -4526,20 +4512,6 @@ export interface UserDto {
'profileImagePath': string;
}
export const UserDtoAvatarColorEnum = {
Primary: 'primary',
Pink: 'pink',
Red: 'red',
Yellow: 'yellow',
Blue: 'blue',
Green: 'green',
Purple: 'purple',
Orange: 'orange',
Gray: 'gray',
Amber: 'amber'
} as const;
export type UserDtoAvatarColorEnum = typeof UserDtoAvatarColorEnum[keyof typeof UserDtoAvatarColorEnum];
/**
*
@ -4549,10 +4521,10 @@ export type UserDtoAvatarColorEnum = typeof UserDtoAvatarColorEnum[keyof typeof
export interface UserResponseDto {
/**
*
* @type {string}
* @type {UserAvatarColor}
* @memberof UserResponseDto
*/
'avatarColor': UserResponseDtoAvatarColorEnum;
'avatarColor': UserAvatarColor;
/**
*
* @type {string}
@ -4633,20 +4605,6 @@ export interface UserResponseDto {
'updatedAt': string;
}
export const UserResponseDtoAvatarColorEnum = {
Primary: 'primary',
Pink: 'pink',
Red: 'red',
Yellow: 'yellow',
Blue: 'blue',
Green: 'green',
Purple: 'purple',
Orange: 'orange',
Gray: 'gray',
Amber: 'amber'
} as const;
export type UserResponseDtoAvatarColorEnum = typeof UserResponseDtoAvatarColorEnum[keyof typeof UserResponseDtoAvatarColorEnum];
/**
*

View file

@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**avatarColor** | **String** | |
**avatarColor** | [**UserAvatarColor**](UserAvatarColor.md) | |
**createdAt** | [**DateTime**](DateTime.md) | |
**deletedAt** | [**DateTime**](DateTime.md) | |
**email** | **String** | |

View file

@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**avatarColor** | **String** | |
**avatarColor** | [**UserAvatarColor**](UserAvatarColor.md) | |
**email** | **String** | |
**id** | **String** | |
**name** | **String** | |

View file

@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**avatarColor** | **String** | |
**avatarColor** | [**UserAvatarColor**](UserAvatarColor.md) | |
**createdAt** | [**DateTime**](DateTime.md) | |
**deletedAt** | [**DateTime**](DateTime.md) | |
**email** | **String** | |

View file

@ -30,7 +30,7 @@ class PartnerResponseDto {
required this.updatedAt,
});
PartnerResponseDtoAvatarColorEnum avatarColor;
UserAvatarColor avatarColor;
DateTime createdAt;
@ -160,7 +160,7 @@ class PartnerResponseDto {
final json = value.cast<String, dynamic>();
return PartnerResponseDto(
avatarColor: PartnerResponseDtoAvatarColorEnum.fromJson(json[r'avatarColor'])!,
avatarColor: UserAvatarColor.fromJson(json[r'avatarColor'])!,
createdAt: mapDateTime(json, r'createdAt', '')!,
deletedAt: mapDateTime(json, r'deletedAt', ''),
email: mapValueOfType<String>(json, r'email')!,
@ -238,101 +238,3 @@ class PartnerResponseDto {
};
}
class PartnerResponseDtoAvatarColorEnum {
/// Instantiate a new enum with the provided [value].
const PartnerResponseDtoAvatarColorEnum._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const primary = PartnerResponseDtoAvatarColorEnum._(r'primary');
static const pink = PartnerResponseDtoAvatarColorEnum._(r'pink');
static const red = PartnerResponseDtoAvatarColorEnum._(r'red');
static const yellow = PartnerResponseDtoAvatarColorEnum._(r'yellow');
static const blue = PartnerResponseDtoAvatarColorEnum._(r'blue');
static const green = PartnerResponseDtoAvatarColorEnum._(r'green');
static const purple = PartnerResponseDtoAvatarColorEnum._(r'purple');
static const orange = PartnerResponseDtoAvatarColorEnum._(r'orange');
static const gray = PartnerResponseDtoAvatarColorEnum._(r'gray');
static const amber = PartnerResponseDtoAvatarColorEnum._(r'amber');
/// List of all possible values in this [enum][PartnerResponseDtoAvatarColorEnum].
static const values = <PartnerResponseDtoAvatarColorEnum>[
primary,
pink,
red,
yellow,
blue,
green,
purple,
orange,
gray,
amber,
];
static PartnerResponseDtoAvatarColorEnum? fromJson(dynamic value) => PartnerResponseDtoAvatarColorEnumTypeTransformer().decode(value);
static List<PartnerResponseDtoAvatarColorEnum>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <PartnerResponseDtoAvatarColorEnum>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = PartnerResponseDtoAvatarColorEnum.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [PartnerResponseDtoAvatarColorEnum] to String,
/// and [decode] dynamic data back to [PartnerResponseDtoAvatarColorEnum].
class PartnerResponseDtoAvatarColorEnumTypeTransformer {
factory PartnerResponseDtoAvatarColorEnumTypeTransformer() => _instance ??= const PartnerResponseDtoAvatarColorEnumTypeTransformer._();
const PartnerResponseDtoAvatarColorEnumTypeTransformer._();
String encode(PartnerResponseDtoAvatarColorEnum data) => data.value;
/// Decodes a [dynamic value][data] to a PartnerResponseDtoAvatarColorEnum.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
PartnerResponseDtoAvatarColorEnum? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'primary': return PartnerResponseDtoAvatarColorEnum.primary;
case r'pink': return PartnerResponseDtoAvatarColorEnum.pink;
case r'red': return PartnerResponseDtoAvatarColorEnum.red;
case r'yellow': return PartnerResponseDtoAvatarColorEnum.yellow;
case r'blue': return PartnerResponseDtoAvatarColorEnum.blue;
case r'green': return PartnerResponseDtoAvatarColorEnum.green;
case r'purple': return PartnerResponseDtoAvatarColorEnum.purple;
case r'orange': return PartnerResponseDtoAvatarColorEnum.orange;
case r'gray': return PartnerResponseDtoAvatarColorEnum.gray;
case r'amber': return PartnerResponseDtoAvatarColorEnum.amber;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [PartnerResponseDtoAvatarColorEnumTypeTransformer] instance.
static PartnerResponseDtoAvatarColorEnumTypeTransformer? _instance;
}

View file

@ -20,7 +20,7 @@ class UserDto {
required this.profileImagePath,
});
UserDtoAvatarColorEnum avatarColor;
UserAvatarColor avatarColor;
String email;
@ -68,7 +68,7 @@ class UserDto {
final json = value.cast<String, dynamic>();
return UserDto(
avatarColor: UserDtoAvatarColorEnum.fromJson(json[r'avatarColor'])!,
avatarColor: UserAvatarColor.fromJson(json[r'avatarColor'])!,
email: mapValueOfType<String>(json, r'email')!,
id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!,
@ -128,101 +128,3 @@ class UserDto {
};
}
class UserDtoAvatarColorEnum {
/// Instantiate a new enum with the provided [value].
const UserDtoAvatarColorEnum._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const primary = UserDtoAvatarColorEnum._(r'primary');
static const pink = UserDtoAvatarColorEnum._(r'pink');
static const red = UserDtoAvatarColorEnum._(r'red');
static const yellow = UserDtoAvatarColorEnum._(r'yellow');
static const blue = UserDtoAvatarColorEnum._(r'blue');
static const green = UserDtoAvatarColorEnum._(r'green');
static const purple = UserDtoAvatarColorEnum._(r'purple');
static const orange = UserDtoAvatarColorEnum._(r'orange');
static const gray = UserDtoAvatarColorEnum._(r'gray');
static const amber = UserDtoAvatarColorEnum._(r'amber');
/// List of all possible values in this [enum][UserDtoAvatarColorEnum].
static const values = <UserDtoAvatarColorEnum>[
primary,
pink,
red,
yellow,
blue,
green,
purple,
orange,
gray,
amber,
];
static UserDtoAvatarColorEnum? fromJson(dynamic value) => UserDtoAvatarColorEnumTypeTransformer().decode(value);
static List<UserDtoAvatarColorEnum>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <UserDtoAvatarColorEnum>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = UserDtoAvatarColorEnum.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [UserDtoAvatarColorEnum] to String,
/// and [decode] dynamic data back to [UserDtoAvatarColorEnum].
class UserDtoAvatarColorEnumTypeTransformer {
factory UserDtoAvatarColorEnumTypeTransformer() => _instance ??= const UserDtoAvatarColorEnumTypeTransformer._();
const UserDtoAvatarColorEnumTypeTransformer._();
String encode(UserDtoAvatarColorEnum data) => data.value;
/// Decodes a [dynamic value][data] to a UserDtoAvatarColorEnum.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
UserDtoAvatarColorEnum? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'primary': return UserDtoAvatarColorEnum.primary;
case r'pink': return UserDtoAvatarColorEnum.pink;
case r'red': return UserDtoAvatarColorEnum.red;
case r'yellow': return UserDtoAvatarColorEnum.yellow;
case r'blue': return UserDtoAvatarColorEnum.blue;
case r'green': return UserDtoAvatarColorEnum.green;
case r'purple': return UserDtoAvatarColorEnum.purple;
case r'orange': return UserDtoAvatarColorEnum.orange;
case r'gray': return UserDtoAvatarColorEnum.gray;
case r'amber': return UserDtoAvatarColorEnum.amber;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [UserDtoAvatarColorEnumTypeTransformer] instance.
static UserDtoAvatarColorEnumTypeTransformer? _instance;
}

View file

@ -29,7 +29,7 @@ class UserResponseDto {
required this.updatedAt,
});
UserResponseDtoAvatarColorEnum avatarColor;
UserAvatarColor avatarColor;
DateTime createdAt;
@ -144,7 +144,7 @@ class UserResponseDto {
final json = value.cast<String, dynamic>();
return UserResponseDto(
avatarColor: UserResponseDtoAvatarColorEnum.fromJson(json[r'avatarColor'])!,
avatarColor: UserAvatarColor.fromJson(json[r'avatarColor'])!,
createdAt: mapDateTime(json, r'createdAt', '')!,
deletedAt: mapDateTime(json, r'deletedAt', ''),
email: mapValueOfType<String>(json, r'email')!,
@ -221,101 +221,3 @@ class UserResponseDto {
};
}
class UserResponseDtoAvatarColorEnum {
/// Instantiate a new enum with the provided [value].
const UserResponseDtoAvatarColorEnum._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const primary = UserResponseDtoAvatarColorEnum._(r'primary');
static const pink = UserResponseDtoAvatarColorEnum._(r'pink');
static const red = UserResponseDtoAvatarColorEnum._(r'red');
static const yellow = UserResponseDtoAvatarColorEnum._(r'yellow');
static const blue = UserResponseDtoAvatarColorEnum._(r'blue');
static const green = UserResponseDtoAvatarColorEnum._(r'green');
static const purple = UserResponseDtoAvatarColorEnum._(r'purple');
static const orange = UserResponseDtoAvatarColorEnum._(r'orange');
static const gray = UserResponseDtoAvatarColorEnum._(r'gray');
static const amber = UserResponseDtoAvatarColorEnum._(r'amber');
/// List of all possible values in this [enum][UserResponseDtoAvatarColorEnum].
static const values = <UserResponseDtoAvatarColorEnum>[
primary,
pink,
red,
yellow,
blue,
green,
purple,
orange,
gray,
amber,
];
static UserResponseDtoAvatarColorEnum? fromJson(dynamic value) => UserResponseDtoAvatarColorEnumTypeTransformer().decode(value);
static List<UserResponseDtoAvatarColorEnum>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <UserResponseDtoAvatarColorEnum>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = UserResponseDtoAvatarColorEnum.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [UserResponseDtoAvatarColorEnum] to String,
/// and [decode] dynamic data back to [UserResponseDtoAvatarColorEnum].
class UserResponseDtoAvatarColorEnumTypeTransformer {
factory UserResponseDtoAvatarColorEnumTypeTransformer() => _instance ??= const UserResponseDtoAvatarColorEnumTypeTransformer._();
const UserResponseDtoAvatarColorEnumTypeTransformer._();
String encode(UserResponseDtoAvatarColorEnum data) => data.value;
/// Decodes a [dynamic value][data] to a UserResponseDtoAvatarColorEnum.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
UserResponseDtoAvatarColorEnum? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'primary': return UserResponseDtoAvatarColorEnum.primary;
case r'pink': return UserResponseDtoAvatarColorEnum.pink;
case r'red': return UserResponseDtoAvatarColorEnum.red;
case r'yellow': return UserResponseDtoAvatarColorEnum.yellow;
case r'blue': return UserResponseDtoAvatarColorEnum.blue;
case r'green': return UserResponseDtoAvatarColorEnum.green;
case r'purple': return UserResponseDtoAvatarColorEnum.purple;
case r'orange': return UserResponseDtoAvatarColorEnum.orange;
case r'gray': return UserResponseDtoAvatarColorEnum.gray;
case r'amber': return UserResponseDtoAvatarColorEnum.amber;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [UserResponseDtoAvatarColorEnumTypeTransformer] instance.
static UserResponseDtoAvatarColorEnumTypeTransformer? _instance;
}

View file

@ -16,7 +16,7 @@ void main() {
// final instance = PartnerResponseDto();
group('test PartnerResponseDto', () {
// String avatarColor
// UserAvatarColor avatarColor
test('to test the property `avatarColor`', () async {
// TODO
});

View file

@ -16,7 +16,7 @@ void main() {
// final instance = UserDto();
group('test UserDto', () {
// String avatarColor
// UserAvatarColor avatarColor
test('to test the property `avatarColor`', () async {
// TODO
});

View file

@ -16,7 +16,7 @@ void main() {
// final instance = UserResponseDto();
group('test UserResponseDto', () {
// String avatarColor
// UserAvatarColor avatarColor
test('to test the property `avatarColor`', () async {
// TODO
});

View file

@ -7656,19 +7656,8 @@
"PartnerResponseDto": {
"properties": {
"avatarColor": {
"enum": [
"primary",
"pink",
"red",
"yellow",
"blue",
"green",
"purple",
"orange",
"gray",
"amber"
],
"type": "string"
"$ref": "#/components/schemas/UserAvatarColor",
"nullable": true
},
"createdAt": {
"format": "date-time",
@ -7720,11 +7709,11 @@
}
},
"required": [
"avatarColor",
"id",
"name",
"email",
"profileImagePath",
"avatarColor",
"storageLabel",
"externalPath",
"shouldChangePassword",
@ -9262,19 +9251,8 @@
"UserDto": {
"properties": {
"avatarColor": {
"enum": [
"primary",
"pink",
"red",
"yellow",
"blue",
"green",
"purple",
"orange",
"gray",
"amber"
],
"type": "string"
"$ref": "#/components/schemas/UserAvatarColor",
"nullable": true
},
"email": {
"type": "string"
@ -9290,30 +9268,19 @@
}
},
"required": [
"avatarColor",
"id",
"name",
"email",
"profileImagePath",
"avatarColor"
"profileImagePath"
],
"type": "object"
},
"UserResponseDto": {
"properties": {
"avatarColor": {
"enum": [
"primary",
"pink",
"red",
"yellow",
"blue",
"green",
"purple",
"orange",
"gray",
"amber"
],
"type": "string"
"$ref": "#/components/schemas/UserAvatarColor",
"nullable": true
},
"createdAt": {
"format": "date-time",
@ -9362,11 +9329,11 @@
}
},
"required": [
"avatarColor",
"id",
"name",
"email",
"profileImagePath",
"avatarColor",
"storageLabel",
"externalPath",
"shouldChangePassword",

View file

@ -1,8 +1,11 @@
import { UserAvatarColor, UserEntity } from '@app/infra/entities';
import { Optional } from '@nestjs/common';
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum } from 'class-validator';
export const getRandomAvatarColor = (): UserAvatarColor => {
export const getRandomAvatarColor = (value: number): UserAvatarColor => {
const values = Object.values(UserAvatarColor);
const randomIndex = Math.floor(Math.random() * values.length);
const randomIndex = Math.floor(value % values.length);
return values[randomIndex] as UserAvatarColor;
};
@ -11,7 +14,10 @@ export class UserDto {
name!: string;
email!: string;
profileImagePath!: string;
avatarColor!: UserAvatarColor;
@IsEnum(UserAvatarColor)
@Optional()
@ApiProperty({ enumName: 'UserAvatarColor', enum: UserAvatarColor })
avatarColor!: UserAvatarColor | null;
}
export class UserResponseDto extends UserDto {
@ -32,7 +38,7 @@ export const mapSimpleUser = (entity: UserEntity): UserDto => {
email: entity.email,
name: entity.name,
profileImagePath: entity.profileImagePath,
avatarColor: entity.avatarColor,
avatarColor: entity.avatarColor ?? getRandomAvatarColor(entity.email.length),
};
};

View file

@ -4,7 +4,6 @@ import path from 'path';
import sanitize from 'sanitize-filename';
import { AuthUserDto } from '../auth';
import { ICryptoRepository, ILibraryRepository, IUserRepository } from '../repositories';
import { getRandomAvatarColor } from './response-dto/user-response.dto';
const SALT_ROUNDS = 10;
@ -99,7 +98,6 @@ export class UserCore {
if (payload.storageLabel) {
payload.storageLabel = sanitize(payload.storageLabel);
}
payload.avatarColor = getRandomAvatarColor();
const userEntity = await this.userRepository.create(payload);
await this.libraryRepository.create({
owner: { id: userEntity.id } as UserEntity,

View file

@ -31,8 +31,8 @@ export class UserEntity {
@Column({ default: '' })
name!: string;
@Column({ type: 'varchar', default: UserAvatarColor.PRIMARY })
avatarColor!: UserAvatarColor;
@Column({ type: 'varchar', default: null })
avatarColor!: UserAvatarColor | null;
@Column({ default: false })
isAdmin!: boolean;

View file

@ -1,10 +1,10 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddAvatarColor1698847820950 implements MigrationInterface {
name = 'AddAvatarColor1698847820950'
export class AddAvatarColor1699889987493 implements MigrationInterface {
name = 'AddAvatarColor1699889987493'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "users" ADD "avatarColor" character varying NOT NULL DEFAULT 'primary'`);
await queryRunner.query(`ALTER TABLE "users" ADD "avatarColor" character varying`);
}
public async down(queryRunner: QueryRunner): Promise<void> {

View file

@ -2357,10 +2357,10 @@ export interface OAuthConfigResponseDto {
export interface PartnerResponseDto {
/**
*
* @type {string}
* @type {UserAvatarColor}
* @memberof PartnerResponseDto
*/
'avatarColor': PartnerResponseDtoAvatarColorEnum;
'avatarColor': UserAvatarColor;
/**
*
* @type {string}
@ -2447,20 +2447,6 @@ export interface PartnerResponseDto {
'updatedAt': string;
}
export const PartnerResponseDtoAvatarColorEnum = {
Primary: 'primary',
Pink: 'pink',
Red: 'red',
Yellow: 'yellow',
Blue: 'blue',
Green: 'green',
Purple: 'purple',
Orange: 'orange',
Gray: 'gray',
Amber: 'amber'
} as const;
export type PartnerResponseDtoAvatarColorEnum = typeof PartnerResponseDtoAvatarColorEnum[keyof typeof PartnerResponseDtoAvatarColorEnum];
/**
*
@ -4496,10 +4482,10 @@ export type UserAvatarColor = typeof UserAvatarColor[keyof typeof UserAvatarColo
export interface UserDto {
/**
*
* @type {string}
* @type {UserAvatarColor}
* @memberof UserDto
*/
'avatarColor': UserDtoAvatarColorEnum;
'avatarColor': UserAvatarColor;
/**
*
* @type {string}
@ -4526,20 +4512,6 @@ export interface UserDto {
'profileImagePath': string;
}
export const UserDtoAvatarColorEnum = {
Primary: 'primary',
Pink: 'pink',
Red: 'red',
Yellow: 'yellow',
Blue: 'blue',
Green: 'green',
Purple: 'purple',
Orange: 'orange',
Gray: 'gray',
Amber: 'amber'
} as const;
export type UserDtoAvatarColorEnum = typeof UserDtoAvatarColorEnum[keyof typeof UserDtoAvatarColorEnum];
/**
*
@ -4549,10 +4521,10 @@ export type UserDtoAvatarColorEnum = typeof UserDtoAvatarColorEnum[keyof typeof
export interface UserResponseDto {
/**
*
* @type {string}
* @type {UserAvatarColor}
* @memberof UserResponseDto
*/
'avatarColor': UserResponseDtoAvatarColorEnum;
'avatarColor': UserAvatarColor;
/**
*
* @type {string}
@ -4633,20 +4605,6 @@ export interface UserResponseDto {
'updatedAt': string;
}
export const UserResponseDtoAvatarColorEnum = {
Primary: 'primary',
Pink: 'pink',
Red: 'red',
Yellow: 'yellow',
Blue: 'blue',
Green: 'green',
Purple: 'purple',
Orange: 'orange',
Gray: 'gray',
Amber: 'amber'
} as const;
export type UserResponseDtoAvatarColorEnum = typeof UserResponseDtoAvatarColorEnum[keyof typeof UserResponseDtoAvatarColorEnum];
/**
*

View file

@ -1,7 +1,7 @@
<script lang="ts">
import Button from '$lib/components/elements/buttons/button.svelte';
import { AppRoute } from '$lib/constants';
import { api, UserDtoAvatarColorEnum, type UserResponseDto } from '@api';
import { api, UserAvatarColor, type UserResponseDto } from '@api';
import { createEventDispatcher } from 'svelte';
import Icon from '$lib/components/elements/icon.svelte';
import { fade } from 'svelte/transition';
@ -17,7 +17,7 @@
const dispatch = createEventDispatcher();
const handleSaveProfile = async (color: UserDtoAvatarColorEnum) => {
const handleSaveProfile = async (color: UserAvatarColor) => {
try {
if (user.profileImagePath !== '') {
await api.userApi.deleteProfileImage();

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { mdiClose } from '@mdi/js';
import { createEventDispatcher } from 'svelte';
import { UserDtoAvatarColorEnum, UserResponseDto } from '@api';
import { UserAvatarColor, UserResponseDto } from '@api';
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
import FullScreenModal from '../full-screen-modal.svelte';
import UserAvatar from '../user-avatar.svelte';
@ -9,7 +9,7 @@
export let user: UserResponseDto;
const dispatch = createEventDispatcher();
const colors: Array<UserDtoAvatarColorEnum> = Object.values(UserDtoAvatarColorEnum);
const colors: UserAvatarColor[] = Object.values(UserAvatarColor);
</script>
<FullScreenModal on:clickOutside={() => dispatch('close')} on:escape={() => dispatch('close')}>

View file

@ -4,18 +4,18 @@
<script lang="ts">
import { imageLoad } from '$lib/utils/image-load';
import { UserDtoAvatarColorEnum, api } from '@api';
import { UserAvatarColor, api } from '@api';
interface User {
id: string;
name: string;
email: string;
profileImagePath: string;
avatarColor: UserDtoAvatarColorEnum;
avatarColor: UserAvatarColor;
}
export let user: User;
export let color: UserDtoAvatarColorEnum = user.avatarColor;
export let color: UserAvatarColor = user.avatarColor;
export let size: Size = 'full';
export let rounded = true;
export let interactive = false;
@ -24,7 +24,7 @@
let showFallback = true;
const colorClasses: Record<UserDtoAvatarColorEnum, string> = {
const colorClasses: Record<UserAvatarColor, string> = {
primary: 'bg-immich-primary dark:bg-immich-dark-primary text-immich-dark-fg dark:text-immich-fg',
pink: 'bg-pink-400 text-immich-bg',
red: 'bg-red-500 text-immich-bg',