Skip to content

Commit 64ef13c

Browse files
authored
Merge pull request #156 from EAT-SSU/refactor/#61
[#61] enum ๊ฐ’์„ ํ†ตํ•œ ์‹๋‹น ๊ด€๋ฆฌ ๋ฐ ๋ฐฉํ•™์—ฌ๋ถ€ ํ™•์ธํ•˜์—ฌ isVacation ์ ์šฉ
2 parents 1e6b25a + dffb1c4 commit 64ef13c

File tree

4 files changed

+74
-15
lines changed

4 files changed

+74
-15
lines changed

โ€ŽEATSSU_MVC/EATSSU_MVC/Sources/Data/Firebase/FirebaseRemoteConfig.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Firebase
1212
class FirebaseRemoteConfig {
1313
static let shared = FirebaseRemoteConfig()
1414
var remoteConfig: RemoteConfig
15+
var isVacationPeriod = false
1516

1617
private init() {
1718
remoteConfig = RemoteConfig.remoteConfig()
@@ -59,7 +60,7 @@ class FirebaseRemoteConfig {
5960

6061
func fetchRestaurantInfo() {
6162
// 1. fetch
62-
remoteConfig.fetch() { (status, error) -> Void in
63+
remoteConfig.fetch(withExpirationDuration: 0) { (status, error) -> Void in
6364
if status == .success {
6465
// 2. activate: ์ปจํ”ผ๊ทธ ๊ฐ’ ๊ฐ€์ ธ์˜ด
6566
self.remoteConfig.activate()
@@ -83,4 +84,17 @@ class FirebaseRemoteConfig {
8384
}
8485
}
8586
}
87+
88+
func fetchIsVacationPeriod() {
89+
remoteConfig.fetch(withExpirationDuration: 0) { (status, error) -> Void in
90+
if status == .success {
91+
self.remoteConfig.activate()
92+
93+
self.isVacationPeriod = self.remoteConfig["isVacationPeriod"].boolValue
94+
print("Is vacation period: \(self.isVacationPeriod)")
95+
} else {
96+
print("Error: \(error?.localizedDescription ?? "Unknown error")")
97+
}
98+
}
99+
}
86100
}

โ€ŽEATSSU_MVC/EATSSU_MVC/Sources/Presentation/Auth/ViewController/LoginViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class LoginViewController: BaseViewController {
2020
// MARK: - Properties
2121

2222
var loginAfterlooking = true
23+
static public let isVacationPeriod = false
2324

2425
// MARK: - UI Components
2526

@@ -66,6 +67,8 @@ final class LoginViewController: BaseViewController {
6667
}
6768

6869
private func setFirebaseTask() {
70+
FirebaseRemoteConfig.shared.fetchIsVacationPeriod()
71+
6972
#if DEBUG
7073
#else
7174
Analytics.logEvent("LoginViewControllerLoad", parameters: nil)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// RestaurantType.swift
3+
// EATSSU
4+
//
5+
// Created by ์ตœ์ง€์šฐ on 11/8/24.
6+
//
7+
8+
import Foundation
9+
10+
enum RestaurantType {
11+
case change
12+
case fix
13+
}
14+
15+
enum Restaurant {
16+
case dodamRestaurant
17+
case dormitoryRestaurant
18+
case studentRestaurant
19+
case snackCorner
20+
21+
var type: RestaurantType {
22+
switch self {
23+
case .dodamRestaurant, .dormitoryRestaurant, .studentRestaurant:
24+
return .change
25+
case .snackCorner:
26+
return .fix
27+
}
28+
}
29+
30+
var identifier: String {
31+
switch self {
32+
case .dodamRestaurant:
33+
return "DODAM"
34+
case .dormitoryRestaurant:
35+
return "DORMITORY"
36+
case .studentRestaurant:
37+
return "HAKSIK"
38+
case .snackCorner:
39+
return "SNACK_CORNER"
40+
}
41+
}
42+
}

โ€ŽEATSSU_MVC/EATSSU_MVC/Sources/Presentation/Home/ViewController/HomeRestaurantViewController.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,37 +107,37 @@ final class HomeRestaurantViewController: BaseViewController {
107107
}
108108

109109
func getSectionIndex(for restaurant: String) -> Int? {
110-
let restaurantRawValue = [TextLiteral.dormitoryRawValue,
111-
TextLiteral.dodamRawValue,
112-
TextLiteral.studentRestaurantRawValue,
113-
TextLiteral.snackCornerRawValue]
110+
let restaurantRawValue = [Restaurant.dormitoryRestaurant.identifier,
111+
Restaurant.dodamRestaurant.identifier,
112+
Restaurant.studentRestaurant.identifier,
113+
Restaurant.snackCorner.identifier]
114114
return restaurantRawValue.firstIndex(of: restaurant)
115115
}
116116

117117
func getSectionKey(for section: Int) -> String {
118-
let restaurantRawValue = [TextLiteral.dormitoryRawValue,
119-
TextLiteral.dodamRawValue,
120-
TextLiteral.studentRestaurantRawValue,
121-
TextLiteral.snackCornerRawValue]
118+
let restaurantRawValue = [Restaurant.dormitoryRestaurant.identifier,
119+
Restaurant.dodamRestaurant.identifier,
120+
Restaurant.studentRestaurant.identifier,
121+
Restaurant.snackCorner.identifier]
122122
return restaurantRawValue[section]
123123
}
124124

125125
func fetchData(date: Date, time: String) {
126126
let formatDate = changeDateFormat(date: date)
127-
getChageMenuData(date: formatDate, restaurant: TextLiteral.dormitoryRawValue, time: time) {}
128-
getChageMenuData(date: formatDate, restaurant: TextLiteral.dodamRawValue, time: time) {}
129-
getChageMenuData(date: formatDate, restaurant: TextLiteral.studentRestaurantRawValue, time: time) {}
127+
getChageMenuData(date: formatDate, restaurant: Restaurant.dormitoryRestaurant.identifier, time: time) {}
128+
getChageMenuData(date: formatDate, restaurant: Restaurant.dodamRestaurant.identifier, time: time) {}
129+
getChageMenuData(date: formatDate, restaurant: Restaurant.studentRestaurant.identifier, time: time) {}
130130

131131
let weekday = Weekday.from(date: date)
132132
isWeekend = weekday.isWeekend
133133

134134
if time == TextLiteral.lunchRawValue {
135135

136-
if !weekday.isWeekend {
136+
if !FirebaseRemoteConfig.shared.isVacationPeriod && !weekday.isWeekend {
137137
getFixMenuData(restaurant: TextLiteral.snackCornerRawValue) {}
138138
} else {
139-
currentRestaurant = TextLiteral.snackCornerRawValue
140-
self.fixMenuTableViewData[TextLiteral.snackCornerRawValue] = [MenuInformation(menuId: 0, name: "", mainRating: nil, price: nil)]
139+
currentRestaurant = Restaurant.snackCorner.identifier
140+
self.fixMenuTableViewData[Restaurant.snackCorner.identifier] = [MenuInformation(menuId: 0, name: "", mainRating: nil, price: nil)]
141141
}
142142
}
143143
}

0 commit comments

Comments
ย (0)