Skip to content

Commit

Permalink
Implement removeAccount function
Browse files Browse the repository at this point in the history
  • Loading branch information
arash817 committed Apr 22, 2024
1 parent 9527ecf commit 20813e2
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions mobile/src/screens/RemoveAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,32 @@ import {
theme,
} from "native-base";
import ScreenWrapper from "../components/ScreenWrapper";
import { paymentsApi } from "../utils/axios";
import { useAuth } from "../auth/AuthContext";
import { useNotification } from "../context/NotificationContext";

export function RemoveAccount() {
const auth = useAuth();
const [email, setEmail] = useState<string>("");
const [isLoading, setIsLoading] = useState(false);
const { showErrorNotification, showSuccessNotification } = useNotification();

const removeAccount = async () => {
setIsLoading(true);
// Temporary solution to simulate the removal of the account until the API is implemented
await new Promise((resolve) => setTimeout(resolve, 3000));
try {
const response = await paymentsApi.delete("/api/customers");
if (response.status === 201) {
showSuccessNotification("Account removed successfully");
} else {
showErrorNotification(
"Account removal failed. please contact support."
);
}
auth?.logout();
} catch (error) {
showErrorNotification("Account removal failed. please contact support.");
auth?.logout();
}
setIsLoading(false);
};

Expand Down

0 comments on commit 20813e2

Please sign in to comment.