Skip to content

Commit

Permalink
Merge conflict fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
h1divp committed Feb 25, 2024
2 parents 259dacb + 4f90609 commit 06fc827
Show file tree
Hide file tree
Showing 39 changed files with 3,604 additions and 1,795 deletions.
95 changes: 0 additions & 95 deletions ApiChecklist.md

This file was deleted.

3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
3. Make your changes.
5. Push your changes to your fork.
6. Submit a pull request through GitHub.

# What do I work on?
See [DesignChecklist.md](https://github.com/ufosc/OSC-Proximity-Chat-App/blob/main/DesignChecklist.md) if you'd like to work on the frontend, or [ApiChecklist.md](https://github.com/ufosc/OSC-Proximity-Chat-App/blob/main/ApiChecklist.md) if you'd like to work on the backend.
61 changes: 0 additions & 61 deletions DesignChecklist.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Announcement: messages can now be sent and recieved between phones!
# Echologator
We're making an app that allows you to text with people within a set radius around you, anonymously. You could use this to easily chat with people at very populated places, like a library or dining hall on campus.

Expand Down
Binary file added client/assets/temp_front_page_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 112 additions & 0 deletions client/src/components/Auth/AuthenticationResponse.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React from "react";
import { StyleSheet, Text, Dimensions, TouchableOpacity} from "react-native";
import { FirebaseError } from "firebase/app";
import { User } from "firebase/auth";

//Type to handle Authentication Responses from firebase
export type AuthenticationResponse = {
user: User | null;
error?: undefined;
} | {
user?: undefined;
error: unknown;
}

export class CustomError {
public code: string;
public message: string;

constructor(code: string, message: string) {
this.code = code;
this.message = message;
}
}

//Custom responses
export const inValidEmailResponse = new CustomError("Invalid Email", "Please provide a valid email address")

//Function that decodes the error code
const decodeFirebaseError = (error: FirebaseError) => {
if(error.code === "auth/missing-email" || error.code === "auth/invalid-email") {
return "Please provide a valid email address";
}

if(error.code === "auth/weak-password") {
return "Password must be 6 characters or more";
}

if(error.code === "auth/missing-password") {
return "Please provide a password";
}

if(error.code === "auth/invalid-credential") {
return "The password or email is incorrect";
}

return "Unknown error"
}

const decodeCustomError = (error: CustomError) => {
return error.message;
}

//Function that handles the response depending on type
function handleResponse(response: AuthenticationResponse) {
if(response?.user) {
return "";
}

console.log(response.error)

if(response.error instanceof FirebaseError) {
return decodeFirebaseError(response.error);
}

if(response.error instanceof CustomError) {
return decodeCustomError(response.error);
}

return "Unknown error"
}

//Something
interface AuthenticationErrorMessageProps {
response: AuthenticationResponse | undefined;
onPress?: () => void;
}

export const AuthenticationErrorMessage: React.FC<AuthenticationErrorMessageProps> = ({ response, onPress }) => {
if( response === undefined ) {
return null;
}

const errorMessage = handleResponse(response)

return (
errorMessage &&
<TouchableOpacity style={styles.error_container} onPressIn={onPress}>
<Text style={styles.error_text}>{errorMessage}</Text>
</TouchableOpacity>
);
}


const styles = StyleSheet.create({
error_text: {
color: "white",
fontSize: Dimensions.get("window").height * 0.02,

},
error_container: {
display: "flex",
justifyContent: "center",
alignItems: "center",
backgroundColor: "red",
height: Dimensions.get("window").height * 0.05,
marginTop: Dimensions.get("window").height * 0.005,
width: Dimensions.get("window").width * 0.9,
borderRadius: 10,
padding: 10
}
});

Loading

0 comments on commit 06fc827

Please sign in to comment.