Fix bugs. Move api key to .env file

This commit is contained in:
Gabriel Brown 2024-07-19 08:11:18 -05:00
parent 259ed6da27
commit d496032e12
5 changed files with 150 additions and 24 deletions

View File

@ -201,7 +201,7 @@
attributes = { attributes = {
BuildIndependentTargetsInParallel = 1; BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1530; LastSwiftUpdateCheck = 1530;
LastUpgradeCheck = 1530; LastUpgradeCheck = 1600;
TargetAttributes = { TargetAttributes = {
03308F3F2BC2035300D59E96 = { 03308F3F2BC2035300D59E96 = {
CreatedOnToolsVersion = 15.3; CreatedOnToolsVersion = 15.3;
@ -452,7 +452,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 0.2.3; MARKETING_VERSION = 0.3;
PRODUCT_BUNDLE_IDENTIFIER = "GibbyB.Tech-Tracker"; PRODUCT_BUNDLE_IDENTIFIER = "GibbyB.Tech-Tracker";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@ -487,7 +487,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 0.2.3; MARKETING_VERSION = 0.3;
PRODUCT_BUNDLE_IDENTIFIER = "GibbyB.Tech-Tracker"; PRODUCT_BUNDLE_IDENTIFIER = "GibbyB.Tech-Tracker";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
@ -499,7 +499,6 @@
03308F682BC2035500D59E96 /* Debug */ = { 03308F682BC2035500D59E96 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
@ -519,7 +518,6 @@
03308F692BC2035500D59E96 /* Release */ = { 03308F692BC2035500D59E96 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
@ -539,7 +537,6 @@
03308F6B2BC2035500D59E96 /* Debug */ = { 03308F6B2BC2035500D59E96 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@ -558,7 +555,6 @@
03308F6C2BC2035500D59E96 /* Release */ = { 03308F6C2BC2035500D59E96 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03308F3F2BC2035300D59E96"
BuildableName = "Tech Tracker.app"
BlueprintName = "Tech Tracker"
ReferencedContainer = "container:Tech Tracker.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03308F4F2BC2035500D59E96"
BuildableName = "Tech TrackerTests.xctest"
BlueprintName = "Tech TrackerTests"
ReferencedContainer = "container:Tech Tracker.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03308F592BC2035500D59E96"
BuildableName = "Tech TrackerUITests.xctest"
BlueprintName = "Tech TrackerUITests"
ReferencedContainer = "container:Tech Tracker.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03308F3F2BC2035300D59E96"
BuildableName = "Tech Tracker.app"
BlueprintName = "Tech Tracker"
ReferencedContainer = "container:Tech Tracker.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "API_KEY"
value = "zAf4vYVN2pszrK"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03308F3F2BC2035300D59E96"
BuildableName = "Tech Tracker.app"
BlueprintName = "Tech Tracker"
ReferencedContainer = "container:Tech Tracker.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -10,5 +10,23 @@
<integer>0</integer> <integer>0</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>03308F3F2BC2035300D59E96</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>03308F4F2BC2035500D59E96</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>03308F592BC2035500D59E96</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict> </dict>
</plist> </plist>

View File

@ -86,7 +86,7 @@ struct StatusUpdateView: View {
.font(.headline) // Make the button text larger .font(.headline) // Make the button text larger
.padding() // Add padding around the button text to make the button larger .padding() // Add padding around the button text to make the button larger
.frame(minWidth: 0, maxWidth: .infinity) // Makes the button expand to full width .frame(minWidth: 0, maxWidth: .infinity) // Makes the button expand to full width
.background(Color.accent) // Sets the button background color to blue .background(Color.accentColor) // Sets the button background color to blue
.foregroundColor(.white) // Sets the button text color to white .foregroundColor(.white) // Sets the button text color to white
.cornerRadius(10) // Rounds the corners of the button .cornerRadius(10) // Rounds the corners of the button
} }
@ -102,7 +102,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -115,7 +115,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -129,7 +129,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -142,7 +142,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/) .frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -156,7 +156,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -169,7 +169,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -183,7 +183,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -196,7 +196,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -210,7 +210,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -223,7 +223,7 @@ struct StatusUpdateView: View {
.font(.headline) .font(.headline)
.padding() .padding()
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.background(Color.accent) .background(Color.accentColor)
.foregroundColor(.white) .foregroundColor(.white)
.cornerRadius(10) .cornerRadius(10)
} }
@ -243,9 +243,12 @@ class TechnicianViewModel: ObservableObject {
@Published var currentPage = 1 @Published var currentPage = 1
var totalPageCount = 1 var totalPageCount = 1
let apiKey = ProcessInfo.processInfo.environment["API_KEY"] ?? ""
// Fetch technicians function for Technicians API // Fetch technicians function for Technicians API
func fetchTechnicians() { func fetchTechnicians() {
let urlString = "https://techtracker.gibbyb.com/api/technicians?apikey=APIKEYHERE"
let urlString = "https://techtracker.gibbyb.com/api/technicians?apikey=" + apiKey
guard let url = URL(string: urlString) else { return } guard let url = URL(string: urlString) else { return }
URLSession.shared.dataTask(with: url) { [weak self] data, response, error in URLSession.shared.dataTask(with: url) { [weak self] data, response, error in
@ -281,7 +284,7 @@ class TechnicianViewModel: ObservableObject {
// Update Technician Status function for the Update API // Update Technician Status function for the Update API
func updateTechnicianStatus(name: String, newStatus: String) { func updateTechnicianStatus(name: String, newStatus: String) {
let urlString = "https://techtracker.gibbyb.com/api/update_technicians?apikey=APIKEYHERE" let urlString = "https://techtracker.gibbyb.com/api/update_technicians?apikey=" + apiKey
guard let url = URL(string: urlString) else { return } guard let url = URL(string: urlString) else { return }
let updateData = [TechnicianUpdate(name: name, status: newStatus)] let updateData = [TechnicianUpdate(name: name, status: newStatus)]
@ -325,7 +328,7 @@ class TechnicianViewModel: ObservableObject {
// Fetch Technician History Function for the History API. Very similar to Technician API // Fetch Technician History Function for the History API. Very similar to Technician API
// but with some added metadata // but with some added metadata
func fetchTechnicianHistory(page: Int = 1) { func fetchTechnicianHistory(page: Int = 1) {
let urlString = "https://techtracker.gibbyb.com/api/history?apikey=APIKEYHERE&page=\(page)" let urlString = "https://techtracker.gibbyb.com/api/history?apikey=" + apiKey + "&page=\(page)"
guard let url = URL(string: urlString) else { return } guard let url = URL(string: urlString) else { return }
URLSession.shared.dataTask(with: url) { [weak self] data, response, error in URLSession.shared.dataTask(with: url) { [weak self] data, response, error in
@ -395,10 +398,11 @@ struct ContentView: View {
List { List {
ForEach(viewModel.technicians) { technician in ForEach(viewModel.technicians) { technician in
Button(action: { Button(action: {
self.showingUpdateView = true viewModel.fetchTechnicians()
self.selectedTechnicianName = technician.name self.selectedTechnicianName = technician.name
self.selectedTechnicianCurrStatus = technician.status self.selectedTechnicianCurrStatus = technician.status
}) { self.showingUpdateView = true
}) {
HStack { HStack {
VStack(alignment: .leading, spacing: 5) { VStack(alignment: .leading, spacing: 5) {
Text(technician.name).bold() Text(technician.name).bold()
@ -428,7 +432,6 @@ struct ContentView: View {
viewModel.fetchTechnicians() viewModel.fetchTechnicians()
} }
.sheet(isPresented: $showingUpdateView) { .sheet(isPresented: $showingUpdateView) {
// Pass the selected technician name directly to an explicitly initialized StatusUpdateView
StatusUpdateView(isPresented: $showingUpdateView, StatusUpdateView(isPresented: $showingUpdateView,
technicianName: selectedTechnicianName, technicianName: selectedTechnicianName,
technicianStatus: selectedTechnicianCurrStatus, technicianStatus: selectedTechnicianCurrStatus,