Skip to content

Commit

Permalink
[ORG-84] New register page with the new data (date of birth, study, w…
Browse files Browse the repository at this point in the history
…ork and information) (#76)

* modify the axios call for register

* utils added check date and for graduation year and for birth date

* Refactor Input component refactored and externed InputLabel

* Update tests

* Refactor checkdate to checkdatewithtime in create event

* New register page

* Login page is refactored

* more details
  • Loading branch information
carlotacb authored Jan 6, 2024
1 parent 82f848a commit 0263d93
Show file tree
Hide file tree
Showing 9 changed files with 441 additions and 98 deletions.
42 changes: 21 additions & 21 deletions organizator/__tests__/__snapshots__/input-components-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ exports[`renders correctly a input with label and value 1`] = `
"alignItems": "center",
"backgroundColor": "#eaeaea",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down Expand Up @@ -141,14 +141,14 @@ exports[`renders correctly a input with label and value and error 1`] = `
"alignItems": "center",
"backgroundColor": "#eaeaea",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down Expand Up @@ -225,14 +225,14 @@ exports[`renders correctly a input with label and value that is disabled 1`] = `
"alignItems": "center",
"backgroundColor": "#969696",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down Expand Up @@ -315,14 +315,14 @@ exports[`renders correctly a input with label and value that is password 1`] = `
"alignItems": "center",
"backgroundColor": "#eaeaea",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down Expand Up @@ -435,14 +435,14 @@ exports[`renders correctly a input with label and value that is required 1`] = `
"alignItems": "center",
"backgroundColor": "#eaeaea",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down Expand Up @@ -525,14 +525,14 @@ exports[`renders correctly a input with only label 1`] = `
"alignItems": "center",
"backgroundColor": "#eaeaea",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down Expand Up @@ -613,14 +613,14 @@ exports[`renders correctly a input with value and icon 1`] = `
"alignItems": "center",
"backgroundColor": "#eaeaea",
"borderColor": "#eaeaea",
"borderRadius": 20,
"borderRadius": 15,
"borderWidth": 2,
"display": "flex",
"flexDirection": "row",
"paddingBottom": 5,
"paddingBottom": 3,
"paddingLeft": 20,
"paddingRight": 20,
"paddingTop": 5,
"paddingTop": 3,
},
]
}
Expand Down
6 changes: 3 additions & 3 deletions organizator/app/(tabs)/(home)/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Input from "../../../components/Input";
import Button from "../../../components/ButtonWithIcon";
import { createEvent } from "../../../utils/api/axiosEvents";
import {
checkDate,
checkDateWithTime,
checkDateRange,
checkURL,
dateToPlainString,
Expand Down Expand Up @@ -89,7 +89,7 @@ export default function CreatePage() {
handleError("Please enter a starting date for the event", "startDate");
isValid = false;
} else {
const dateChecker = checkDate(inputs.startDate);
const dateChecker = checkDateWithTime(inputs.startDate);
if (!dateChecker.valid) {
handleError(dateChecker.error, "startDate");
isValid = false;
Expand All @@ -112,7 +112,7 @@ export default function CreatePage() {
handleError("Please enter a ending date for the event", "endDate");
isValid = false;
} else {
const dateChecker = checkDate(inputs.endDate);
const dateChecker = checkDateWithTime(inputs.endDate);
if (!dateChecker.valid) {
handleError(dateChecker.error, "endDate");
isValid = false;
Expand Down
35 changes: 24 additions & 11 deletions organizator/app/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SafeAreaView, Text, ScrollView, View, Pressable } from "react-native";
import { Link, router } from "expo-router";
import Toast from "react-native-toast-message";
import Input from "../components/Input";
import Button from "../components/StyledButton";
import Button from "../components/ButtonWithIcon";
import { loginUser } from "../utils/api/axiosUsers";
import { LoginResponse } from "../utils/interfaces/Users";
import { getToken, storeToken } from "../utils/sessionCalls";
Expand Down Expand Up @@ -39,11 +39,11 @@ const ButtonContainer = styled(View)`

const RegisterTextContainer = styled(View)`
display: flex;
flex-direction: row;
gap: 5px;
flex-direction: column;
gap: 10px;
align-items: center;
justify-content: center;
margin-top: 10px;
margin-top: 40px;
`;

const RegisterText = styled(Text)`
Expand All @@ -53,7 +53,9 @@ const RegisterText = styled(Text)`

const RegisterButton = styled(Text)`
font-weight: bold;
color: blue;
text-decoration: underline #6161e0;
font-size: 18px;
color: #6161e0;
`;

export default function LoginPage() {
Expand All @@ -76,24 +78,22 @@ export default function LoginPage() {
});

const validate = () => {
let isValid = false;
let isValid = true;

if (!inputs.username) {
handleError("Please enter your username", "username");
isValid = false;
} else {
handleError(undefined, "username");
}

if (!inputs.password) {
handleError("Please enter a password", "password");
isValid = false;
} else {
handleError(undefined, "password");
}

if (errors.username === undefined && errors.password === undefined) {
isValid = true;
}

if (isValid) {
login();
}
Expand Down Expand Up @@ -157,7 +157,12 @@ export default function LoginPage() {
password
/>
<ButtonContainer>
<Button title="Log in" onPress={validate} />
<Button
title="Log in"
onPress={validate}
iconName="sign-in"
color="#58a659"
/>
</ButtonContainer>
<RegisterTextContainer>
<RegisterText>You don't have an account yet? </RegisterText>
Expand All @@ -167,6 +172,14 @@ export default function LoginPage() {
</Pressable>
</Link>
</RegisterTextContainer>
<RegisterTextContainer>
<RegisterText>You don't to register now? </RegisterText>
<Link href="/" asChild>
<Pressable>
<RegisterButton>HomePage</RegisterButton>
</Pressable>
</Link>
</RegisterTextContainer>
</>
)}
</ScrollView>
Expand Down
Loading

0 comments on commit 0263d93

Please sign in to comment.