diff --git a/ProjectClock/AccountViewController.swift b/ProjectClock/AccountViewController.swift
index fbcd201..75f5497 100644
--- a/ProjectClock/AccountViewController.swift
+++ b/ProjectClock/AccountViewController.swift
@@ -262,16 +262,23 @@ class FamilyVC: UIViewController
}
/**
- Called when the user clicks the leave family button
+ Called when the user clicks the leave or delete family button
*/
- @IBAction func btnLeave(_ sender: Any)
+ @IBAction func btnLeave(_ sender: UIButton)
{
+ let i = sender.tag
+ let action = ["Leave", "Delete"][i]
+ let title = ["Leaving...", "Deleting..."][i]
+ let msg = ["You left the family.", "You deleted the family."][i]
+
enterPin()
{
- self.sendReq(APIs.familyChangePin, title: "Leaving...", params: ["pin": $0]) { it in
+ self.sendReq(APIs.familyAction, title: title, params: ["pin": $0, "action": action]) { it in
- localStorage.removeObject(forKey: "family")
- self.msg("Leave Success!", "You left the family.")
+ // Leave or delete, clear local storage's family section
+ if i == 0 || i == 1 { localStorage.removeObject(forKey: "family") }
+
+ self.msg("\(action) Success!", msg)
}
}
}
diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard
index ebd3215..5c90cdc 100644
--- a/ProjectClock/Base.lproj/Main.storyboard
+++ b/ProjectClock/Base.lproj/Main.storyboard
@@ -1075,7 +1075,7 @@
-
+