Skip to content

Commit fd68acf

Browse files
committed
fix: add enum in socialType
1 parent e62222a commit fd68acf

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

lib/domain/use-cases/delete_user_use_case.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:injectable/injectable.dart';
22
import 'package:on_time_front/domain/repositories/user_repository.dart';
3+
import 'package:on_time_front/presentation/shared/constants/constants.dart';
34

45
@Injectable()
56
class DeleteUserUseCase {
@@ -12,10 +13,11 @@ class DeleteUserUseCase {
1213
await _userRepository.postFeedback(feedbackMessage);
1314
} catch (_) {}
1415

15-
final socialType = await _userRepository.getUserSocialType();
16-
if (socialType == 'GOOGLE') {
16+
final socialTypeString = await _userRepository.getUserSocialType();
17+
final socialType = socialTypeFromString(socialTypeString);
18+
if (socialType == SocialType.google) {
1719
await _userRepository.deleteGoogleUser();
18-
} else if (socialType == 'APPLE') {
20+
} else if (socialType == SocialType.apple) {
1921
await _userRepository.deleteAppleUser();
2022
} else {
2123
await _userRepository.deleteUser();

lib/presentation/shared/constants/constants.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,33 @@ enum PreparationStateEnum {
55
now, // 진행 중
66
done, // 완료됨
77
}
8+
9+
enum SocialType {
10+
normal,
11+
google,
12+
apple,
13+
}
14+
15+
SocialType socialTypeFromString(String? value) {
16+
if (value == null) return SocialType.normal;
17+
final normalized = value.trim().toLowerCase();
18+
switch (normalized) {
19+
case 'google':
20+
return SocialType.google;
21+
case 'apple':
22+
return SocialType.apple;
23+
default:
24+
return SocialType.normal;
25+
}
26+
}
27+
28+
String socialTypeToString(SocialType type) {
29+
switch (type) {
30+
case SocialType.normal:
31+
return 'normal';
32+
case SocialType.google:
33+
return 'google';
34+
case SocialType.apple:
35+
return 'apple';
36+
}
37+
}

0 commit comments

Comments
 (0)