Commit 55bae677 authored by Wei Han's avatar Wei Han

code update

parent 22ca578e
......@@ -11,7 +11,7 @@
44006126336D83DB220E7214 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
761780ED2CA45674006654EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761780EC2CA45674006654EE /* AppDelegate.swift */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
C23D2D55B148EE1D6FC72852 /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E39174A7BBC525ECB6AE459E /* libPods-example.a */; };
8B0987845C560FD781B650AE /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A2400CB7299C3614291226C /* libPods-example.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -19,11 +19,11 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = "<group>"; };
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = example/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
690F9972D97F745507217F02 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = "<group>"; };
57196ABB0FAFEBD2B74D07C7 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = "<group>"; };
761780EC2CA45674006654EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = example/AppDelegate.swift; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = example/LaunchScreen.storyboard; sourceTree = "<group>"; };
B9F2E44A1B314258ABABFD33 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = "<group>"; };
E39174A7BBC525ECB6AE459E /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8A2400CB7299C3614291226C /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E8EAD6F76E99A3EACFCAFAA5 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
......@@ -32,7 +32,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C23D2D55B148EE1D6FC72852 /* libPods-example.a in Frameworks */,
8B0987845C560FD781B650AE /* libPods-example.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -55,7 +55,7 @@
isa = PBXGroup;
children = (
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
E39174A7BBC525ECB6AE459E /* libPods-example.a */,
8A2400CB7299C3614291226C /* libPods-example.a */,
);
name = Frameworks;
sourceTree = "<group>";
......@@ -92,8 +92,8 @@
BBD78D7AC51CEA395F1C20DB /* Pods */ = {
isa = PBXGroup;
children = (
B9F2E44A1B314258ABABFD33 /* Pods-example.debug.xcconfig */,
690F9972D97F745507217F02 /* Pods-example.release.xcconfig */,
57196ABB0FAFEBD2B74D07C7 /* Pods-example.debug.xcconfig */,
E8EAD6F76E99A3EACFCAFAA5 /* Pods-example.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
......@@ -105,13 +105,13 @@
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */;
buildPhases = (
890064CE3093270C24794A65 /* [CP] Check Pods Manifest.lock */,
345C81D5C27EE395225881EA /* [CP] Check Pods Manifest.lock */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
7E9430E69C9A5F57AD35CC5A /* [CP] Embed Pods Frameworks */,
DB2FCD814B6946290F8F7B0A /* [CP] Copy Pods Resources */,
82A113167A34CAB220114EBD /* [CP] Embed Pods Frameworks */,
5366F480F3743B4AE3E10ADF /* [CP] Copy Pods Resources */,
);
buildRules = (
);
......@@ -183,24 +183,7 @@
shellPath = /bin/sh;
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
};
7E9430E69C9A5F57AD35CC5A /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
890064CE3093270C24794A65 /* [CP] Check Pods Manifest.lock */ = {
345C81D5C27EE395225881EA /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
......@@ -222,7 +205,7 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
DB2FCD814B6946290F8F7B0A /* [CP] Copy Pods Resources */ = {
5366F480F3743B4AE3E10ADF /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
......@@ -239,6 +222,23 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
82A113167A34CAB220114EBD /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
......@@ -255,7 +255,7 @@
/* Begin XCBuildConfiguration section */
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B9F2E44A1B314258ABABFD33 /* Pods-example.debug.xcconfig */;
baseConfigurationReference = 57196ABB0FAFEBD2B74D07C7 /* Pods-example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
......@@ -283,7 +283,7 @@
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 690F9972D97F745507217F02 /* Pods-example.release.xcconfig */;
baseConfigurationReference = E8EAD6F76E99A3EACFCAFAA5 /* Pods-example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
......
......@@ -8,32 +8,32 @@
<key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
......
......@@ -12,6 +12,7 @@
2FAEF09A2E8B7BC80086EDA3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FAEF0992E8B7BC80086EDA3 /* UIKit.framework */; };
2FAEF09C2E8B7BD40086EDA3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FAEF09B2E8B7BD40086EDA3 /* Foundation.framework */; };
2FB2922A2EAB04F400D9F164 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FB292292EAB04F400D9F164 /* AVFoundation.framework */; };
2FB975E02ED7F9AA00E64A87 /* EventKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FB975DF2ED7F9AA00E64A87 /* EventKit.framework */; };
2FD1557B2ECAC5CC00233981 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FD1557A2ECAC5CC00233981 /* WebKit.framework */; };
/* End PBXBuildFile section */
......@@ -22,6 +23,7 @@
2FAEF0992E8B7BC80086EDA3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
2FAEF09B2E8B7BD40086EDA3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
2FB292292EAB04F400D9F164 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; };
2FB975DF2ED7F9AA00E64A87 /* EventKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EventKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.1.sdk/System/Library/Frameworks/EventKit.framework; sourceTree = DEVELOPER_DIR; };
2FD1557A2ECAC5CC00233981 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.1.sdk/System/iOSSupport/System/Library/PrivateFrameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */
......@@ -52,6 +54,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2FB975E02ED7F9AA00E64A87 /* EventKit.framework in Frameworks */,
2FB2922A2EAB04F400D9F164 /* AVFoundation.framework in Frameworks */,
2F99420D2EA9C5F000622199 /* QuartzCore.framework in Frameworks */,
2FD1557B2ECAC5CC00233981 /* WebKit.framework in Frameworks */,
......@@ -84,6 +87,7 @@
2FAEF0982E8B7BC80086EDA3 /* Frameworks */ = {
isa = PBXGroup;
children = (
2FB975DF2ED7F9AA00E64A87 /* EventKit.framework */,
2FD1557A2ECAC5CC00233981 /* WebKit.framework */,
2FB292292EAB04F400D9F164 /* AVFoundation.framework */,
2F99420C2EA9C5F000622199 /* QuartzCore.framework */,
......
// AppointmentAPIClient.h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface AppointmentAPIClient : NSObject
+ (void)fetchAppointment:(void (^)(NSDictionary *data, NSError *error))completion;
+ (void)fetchGeneralInfo:(void (^)(NSDictionary *data, NSError *error))completion;
+ (void)submitAppointmentWithData:(NSDictionary *)appointmentData
+ (void)fetchAppointment:(void (^)(NSDictionary * _Nullable data, NSError * _Nullable error))completion;
+ (void)fetchGeneralInfo:(void (^)(NSDictionary * _Nullable data, NSError * _Nullable error))completion;
+ (void)submitAppointment:(NSDictionary *)appointmentData
completion:(void(^)(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error))completion;
+ (void)submitRepresentativeAppointmentWithData:(NSDictionary *)appointmentData
representativeData:(NSDictionary *)repData
+ (void)submitRepresentativeAppointment:(NSDictionary *)repData
completion:(void(^)(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error))completion;
+ (void)fetchCancelAppointment:(id)appointmentId
reason:(NSString *)reason
completion:(void (^)(NSDictionary *data, NSError *error))completion;
completion:(void (^)(NSDictionary * _Nullable data, NSError * _Nullable error))completion;
@end
NS_ASSUME_NONNULL_END
......@@ -133,7 +133,7 @@
[task resume];
}
+ (void)submitAppointmentWithData:(NSDictionary *)appointmentData
+ (void)submitAppointment:(NSDictionary *)appointmentData
completion:(void(^)(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error))completion {
NSString *urlString = @"https://kitadev.commudesk.com/api/owner/appointment/makeAppointment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA";
......@@ -193,57 +193,41 @@
[task resume];
}
+ (void)submitRepresentativeAppointmentWithData:(NSDictionary *)appointmentData
representativeData:(NSDictionary *)repData
+ (void)submitRepresentativeAppointment:(NSDictionary *)repData
completion:(void(^)(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error))completion {
NSString *urlString = @"https://kitadev.commudesk.com/api/owner/appointment/makeAppointment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImF0aGlyYWh6YWlkaUBjb252ZXAuY29tIiwicGFzc3dvcmQiOiIkMnkkMTAkNU9xYklqMnZ6UHJwckJrcVd5c3I2LmJCc1hVYS9Hd014eUhnL3RhUUhPUkNQcGdmTG8yakciLCJzdWIiOjIxNzAsImlzcyI6Imh0dHBzOi8va2l0YWRldi5jb21tdWRlc2suY29tL2FwaS9vd25lci9hdXRoL3Bhc3N3b3JkbGVzc19sb2dpbiIsImlhdCI6MTc2MDMxNTM1MiwiZXhwIjoyMDc1ODg0ODcyLCJuYmYiOjE3NjAzMTUzNTIsImp0aSI6IktoQmNyQnJEdDVNdDZlWmMifQ.JnxGbZ7hTeoOr6oibIzZMphgyKtTo2Aq9Efx6mrGfFA";
NSURL *url = [NSURL URLWithString:urlString];
NSLog(@"🌍 SUBMIT URL: %@", urlString);
NSLog(@"🌍 SUBMIT (REP) URL: %@", urlString);
NSLog(@"📦 SUBMIT (REP) Appointment Data: %@", appointmentData);
NSLog(@"📎 SUBMIT (REP) Representative Data: %@", repData);
// Create request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.HTTPMethod = @"POST";
// Multipart boundary
NSString *boundary = [NSString stringWithFormat:@"Boundary-%@", [[NSUUID UUID] UUIDString]];
[request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]
forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
// Add appointment fields
for (NSString *key in appointmentData) {
NSString *field = [self multipartFormField:key value:appointmentData[key] boundary:boundary];
[body appendData:[field dataUsingEncoding:NSUTF8StringEncoding]];
}
// Add representative fields
// Add repData fields as text fields
for (NSString *key in repData) {
id value = repData[key];
if ([value isKindOfClass:[NSDictionary class]] && value[@"filePath"]) {
NSLog(@"📎 Adding file for key '%@': %@", key, value[@"fileName"]);
[body appendData:[self multipartFormFile:value[@"filePath"]
fieldName:key
fileName:value[@"fileName"]
mimeType:value[@"mimeType"]
boundary:boundary]];
} else {
NSString *field = [self multipartFormField:key value:value boundary:boundary];
NSString *value = [NSString stringWithFormat:@"%@", repData[key]]; // ensure string
NSString *field = [NSString stringWithFormat:
@"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n",
boundary, key, value];
[body appendData:[field dataUsingEncoding:NSUTF8StringEncoding]];
}
}
// Close multipart
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
request.HTTPBody = body;
NSLog(@"🔄 SUBMIT (REP) Request started with multipart body (%lu bytes)", (unsigned long)body.length);
NSLog(@"🔄 Request started with body (%lu bytes)", (unsigned long)body.length);
// Send request
NSURLSessionDataTask *task = [[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
......@@ -267,8 +251,7 @@
return;
}
NSLog(@"✅ SUBMIT (REP) API Response:\n%@", json);
NSLog(@"✅ API Response:\n%@", json);
dispatch_async(dispatch_get_main_queue(), ^{
completion(YES, json, nil);
});
......@@ -333,7 +316,7 @@
if (jsonParseError) {
NSLog(@"⚠️ JSON Parse Error: %@", jsonParseError);
} else {
NSLog(@"✅ Void Issues API Response:\n%@", jsonResponse);
NSLog(@"✅ Fetch Cancel Appointment Response:\n%@", jsonResponse);
}
dispatch_async(dispatch_get_main_queue(), ^{
......
......@@ -32,6 +32,7 @@
@property (nonatomic, strong) UIButton *repToggleButton;
@property (nonatomic, strong) UIView *repOverlayContainer;
@property (nonatomic, strong) UIStackView *repInputsContainer;
@property (nonatomic, strong) NSString *repId;
@property (nonatomic, assign) BOOL blnTickRepresentative;
@property (nonatomic, strong) UIImageView *icPhotoView;
@property (nonatomic, strong) UIImageView *letterPhotoView;
......@@ -485,11 +486,12 @@
#pragma mark - representative
- (void)toggleRepresentative:(UIButton *)sender {
if (self.repInputsContainer.isHidden) {
// First tap → show picker
[self showRepresentativePicker];
self.blnTickRepresentative = YES;
} else {
// Already showing → hide
[self hideRepresentativeInputs];
self.blnTickRepresentative = NO;
}
}
......@@ -571,6 +573,7 @@
self.repICField.text = rep[@"ic_passport"] ?: @"";
self.repEmailField.text = rep[@"email"] ?: @"";
self.repContactField.text = rep[@"phone"] ?: @"";
self.repId = rep[@"id"] ?: @"";
self.icPhoto = rep[@"ic_photo"];
self.letterPhoto = rep[@"letter"];
[self loadImage:rep[@"ic_photo"] intoImageView:self.icPhotoView];
......@@ -598,6 +601,7 @@
self.repICField.text = @"";
self.repEmailField.text = @"";
self.repContactField.text = @"";
self.repId = @"";
// Hide overlay
[UIView animateWithDuration:0.25 animations:^{
......@@ -634,35 +638,89 @@
}
-(void)confirmPressed {
NSLog(@"⚡ Confirm pressed, blnTickRepresentative = %@", self.blnTickRepresentative ? @"YES" : @"NO");
if (self.blnTickRepresentative) {
NSDictionary *repData = @{
@"data[os]": @"AND",
@"data[project_id]": @"8",
@"data[appointment_type]": self.appointmentType,
@"data[drawing_plan_id]": @"135",
@"data[appointment_attendee_type]": @"representative",
@"data[slot_id]": self.slotId,
@"data[representative_id]": self.repId,
@"data[imei]": @"AND:2a2f13ff17b1cbb5",
};
[AppointmentAPIClient submitRepresentativeAppointment:repData completion:^(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Success"
message:@"Your appointment was submitted successfully."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
// Navigate away or dismiss
[self.navigationController popViewControllerAnimated:YES];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
} else {
NSString *errorMsg = error.localizedDescription ?: @"Failed to submit appointment.";
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error"
message:errorMsg
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:nil]; // stay on the page
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
});
}];
} else {
NSDictionary *appointmentData = @{
@"project_id": @"8",
@"slot_id": self.slotId,
@"appointment_type": self.appointmentType,
@"user_id": @"2170",
@"appointment_attendee_type": @"representative",
@"appointment_attendee_type": @"joint_owner",
@"drawing_plan_id": @"135",
};
if (self.blnTickRepresentative) {
NSDictionary *repData = @{
@"representative_name": self.repNameField.text,
@"representative_ic_passport": self.repICField.text,
@"representative_email": self.repEmailField.text,
@"representative_contact": self.repContactField.text,
// files example
@"ic_photo": self.icPhoto,
@"representative_letter": self.letterPhoto,
};
[AppointmentAPIClient submitAppointment:appointmentData completion:^(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error) {
[AppointmentAPIClient submitRepresentativeAppointmentWithData:appointmentData representativeData:repData completion:^(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error) {
// handle response
dispatch_async(dispatch_get_main_queue(), ^{
if (success) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Success"
message:@"Your appointment was submitted successfully."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[self.navigationController popViewControllerAnimated:YES];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
} else {
[AppointmentAPIClient submitAppointmentWithData:appointmentData completion:^(BOOL success, NSDictionary * _Nullable response, NSError * _Nullable error) {
// handle response
}];
NSString *errorMsg = error.localizedDescription ?: @"Failed to submit appointment.";
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error"
message:errorMsg
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
});
}];
}
}
- (void)setBlnTickRepresentative:(BOOL)blnTickRepresentative {
if (_blnTickRepresentative != blnTickRepresentative) {
NSLog(@"🔄 blnTickRepresentative changed: %@ -> %@", _blnTickRepresentative ? @"YES" : @"NO", blnTickRepresentative ? @"YES" : @"NO");
_blnTickRepresentative = blnTickRepresentative;
}
}
@end
......@@ -8,32 +8,32 @@
<key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>QmsPluginFramework.framework/QmsPluginFramework</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>QmsPluginFramework.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment