공개페이지 완료
This commit is contained in:
@@ -851,7 +851,7 @@ class EventService with ChangeNotifier {
|
||||
// 서버 미지원/404 시 로컬 저장소에서 로드 시도
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final key = 'local_teams_' + eventId;
|
||||
final key = 'local_teams_$eventId';
|
||||
final raw = prefs.getString(key);
|
||||
if (raw != null && raw.isNotEmpty) {
|
||||
final List<dynamic> jsonList = jsonDecode(raw);
|
||||
@@ -945,7 +945,7 @@ class EventService with ChangeNotifier {
|
||||
// 서버 미지원/404 시 로컬로 저장
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final key = 'local_teams_' + eventId;
|
||||
final key = 'local_teams_$eventId';
|
||||
final raw = jsonEncode(teams.map((t) => t.toJson()).toList());
|
||||
await prefs.setString(key, raw);
|
||||
_teams = teams;
|
||||
@@ -1091,7 +1091,7 @@ class EventService with ChangeNotifier {
|
||||
data: formData,
|
||||
);
|
||||
if (data is Map) {
|
||||
final map = Map<String, dynamic>.from(data as Map);
|
||||
final map = Map<String, dynamic>.from(data);
|
||||
// 서버 응답: { message, file: { filename, originalname, ... } }
|
||||
if (map['file'] is Map) {
|
||||
final fm = Map<String, dynamic>.from(map['file'] as Map);
|
||||
@@ -1201,8 +1201,9 @@ class EventService with ChangeNotifier {
|
||||
String? rawStatus = payloadEvent['status']?.toString();
|
||||
if (rawStatus != null && rawStatus.isNotEmpty) {
|
||||
final s = rawStatus.toLowerCase();
|
||||
if (['active', '활성'].contains(s)) payloadEvent['status'] = 'active';
|
||||
else if (['ready', '대기', '준비', 'draft'].contains(s)) payloadEvent['status'] = 'ready';
|
||||
if (['active', '활성'].contains(s)) {
|
||||
payloadEvent['status'] = 'active';
|
||||
} else if (['ready', '대기', '준비', 'draft'].contains(s)) payloadEvent['status'] = 'ready';
|
||||
else if (['completed', '완료', 'done', 'finished'].contains(s)) payloadEvent['status'] = 'completed';
|
||||
else if (['canceled', 'cancelled', '취소'].contains(s)) payloadEvent['status'] = 'canceled';
|
||||
else if (['deleted', '삭제'].contains(s)) payloadEvent['status'] = 'deleted';
|
||||
@@ -1212,8 +1213,9 @@ class EventService with ChangeNotifier {
|
||||
String? rawType = payloadEvent['eventType']?.toString();
|
||||
if (rawType != null && rawType.isNotEmpty) {
|
||||
final t = rawType.toLowerCase();
|
||||
if (['regular','일반'].contains(t)) payloadEvent['eventType'] = 'regular';
|
||||
else if (['lightning','번개'].contains(t)) payloadEvent['eventType'] = 'lightning';
|
||||
if (['regular','일반'].contains(t)) {
|
||||
payloadEvent['eventType'] = 'regular';
|
||||
} else if (['lightning','번개'].contains(t)) payloadEvent['eventType'] = 'lightning';
|
||||
else if (['practice','연습'].contains(t)) payloadEvent['eventType'] = 'practice';
|
||||
else if (['exchange','교류전'].contains(t)) payloadEvent['eventType'] = 'exchange';
|
||||
else if (['event','행사'].contains(t)) payloadEvent['eventType'] = 'event';
|
||||
|
||||
@@ -42,7 +42,7 @@ class PublicEventService {
|
||||
@visibleForTesting
|
||||
PublicEventService.forTest(this._http);
|
||||
|
||||
static String tokenKey(String publicHash) => 'event_token_' + publicHash;
|
||||
static String tokenKey(String publicHash) => 'event_token_$publicHash';
|
||||
|
||||
String? getSavedToken(String publicHash) {
|
||||
return WebStorage.getItem(tokenKey(publicHash));
|
||||
@@ -58,14 +58,14 @@ class PublicEventService {
|
||||
|
||||
Map<String, dynamic>? _authHeader(String? token) {
|
||||
if (token == null || token.isEmpty) return null;
|
||||
return { 'Authorization': 'Bearer ' + token };
|
||||
return { 'Authorization': 'Bearer $token' };
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> fetchEvent(String publicHash) async {
|
||||
final saved = getSavedToken(publicHash);
|
||||
// 백엔드는 GET이 아니라 POST('/:publicHash')로 최초 진입/토큰 인증을 처리함
|
||||
final res = await _http.post(
|
||||
'/public/' + publicHash,
|
||||
'/public/$publicHash',
|
||||
data: {},
|
||||
headers: _authHeader(saved),
|
||||
);
|
||||
@@ -83,7 +83,7 @@ class PublicEventService {
|
||||
try {
|
||||
// 우선 저장된 토큰으로 시도, 실패 시 비밀번호로 재시도는 서버가 처리
|
||||
final res = await _http.post(
|
||||
'/public/' + publicHash,
|
||||
'/public/$publicHash',
|
||||
data: password != null ? { 'password': password } : {},
|
||||
headers: _authHeader(saved),
|
||||
);
|
||||
@@ -119,7 +119,7 @@ class PublicEventService {
|
||||
if (comment != null) 'comment': comment,
|
||||
};
|
||||
await _http.post(
|
||||
'/public/' + publicHash + '/participant',
|
||||
'/public/$publicHash/participant',
|
||||
data: payload,
|
||||
headers: _authHeader(token),
|
||||
);
|
||||
@@ -139,7 +139,7 @@ class PublicEventService {
|
||||
if (average != null) 'average': average,
|
||||
};
|
||||
await _http.post(
|
||||
'/public/' + publicHash + '/guest',
|
||||
'/public/$publicHash/guest',
|
||||
data: payload,
|
||||
headers: _authHeader(token),
|
||||
);
|
||||
@@ -161,7 +161,7 @@ class PublicEventService {
|
||||
if (teamNumber != null) 'teamNumber': teamNumber,
|
||||
};
|
||||
await _http.put(
|
||||
'/public/' + publicHash + '/score',
|
||||
'/public/$publicHash/score',
|
||||
data: payload,
|
||||
headers: _authHeader(token),
|
||||
);
|
||||
@@ -173,7 +173,7 @@ class PublicEventService {
|
||||
}) async {
|
||||
final token = getSavedToken(publicHash);
|
||||
await _http.put(
|
||||
'/public/' + publicHash + '/team/' + teamNumber.toString() + '/handicap',
|
||||
'/public/$publicHash/team/$teamNumber/handicap',
|
||||
data: { 'teamNumber': teamNumber, 'handicap': handicap },
|
||||
headers: _authHeader(token),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user