Skip to content

Commit

Permalink
Merge pull request #483 from bounswe/MOBILE-462
Browse files Browse the repository at this point in the history
fix(mobile): HTTP Request Issue + Register Bug
  • Loading branch information
YavizGuldalf authored Nov 6, 2024
2 parents 7ffc986 + 686ecec commit 20ac49b
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 68 deletions.
1 change: 1 addition & 0 deletions mobile/bulingo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ yarn-error.*
# typescript
*.tsbuildinfo


# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli

Expand Down
59 changes: 59 additions & 0 deletions mobile/bulingo/app.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export default {
expo: {
name: "bulingo",
slug: "bulingo",
version: "0.1.0",
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "myapp",
userInterfaceStyle: "automatic",
splash: {
image: "./assets/images/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff"
},
assetBundlePatterns: ["**/*"],
ios: {
supportsTablet: true,
bundleIdentifier: "no"
},
android: {
adaptiveIcon: {
foregroundImage: "./assets/images/adaptive-icon.png",
backgroundColor: "#ffffff"
},
permissions: ["ACCESS_NETWORK_STATE"],
package: "com.ahmetoguzengin.bulingo",
softwareKeyboardLayoutMode: "pan",
},

extra: {
eas: {
projectId: "665dbb53-e753-4d3a-bc77-e46e81151006"
},
router: {
origin: false
}
},
web: {
bundler: "metro",
output: "static",
favicon: "./assets/images/favicon.png"
},
plugins: [
"expo-router",
"expo-font",
[
"expo-build-properties",
{
android: {
usesCleartextTraffic: true
}
}
]
],
experiments: {
typedRoutes: true
}
}
};
49 changes: 0 additions & 49 deletions mobile/bulingo/app.json

This file was deleted.

36 changes: 21 additions & 15 deletions mobile/bulingo/app/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import {router} from 'expo-router'
import TokenManager from './TokenManager'; // Import the TokenManager


// const LOGIN_URL = "http://161.35.208.249:8000/login/";
const LOGIN_URL = "http://161.35.208.249:8000/login/";

export default function Home() {
const [email, setEmail] = useState(''); // State for email
const [password, setPassword] = useState(''); // State for password
const [isLoading, setIsLoading] = useState(false);
const [isErrorVisible, setIsErrorVisible] = useState(false);
const username = "Ahmet";

const username = "1";
const handleRegister = () => {
router.navigate('/register')
};
Expand All @@ -27,18 +26,25 @@ export default function Home() {
'email': email,
};
try {
// const response = await fetch(LOGIN_URL, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify(params),
// });
// const json = await response.json();
// const json = {"access": 'tmp', 'refresh': 'tmp'};
if (true){
const accessToken = '0';
const refreshToken = '0';
fetch('https://reactnative.dev/movies.json')
.then(response => response.json())
.then(json => {
// logic to perform if the request succeeds
})
.catch(error => {
console.error(error); // catching the error and handling it the way you see fit.
}); // retrieved from https://reactnative.dev/docs/network

const response = await fetch(LOGIN_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
});
const json = await response.json();
if ("access" in json){
const { accessToken, refreshToken } = json;
TokenManager.setTokens({ accessToken, refreshToken });
TokenManager.setUsername(username);
console.log(TokenManager.getTokens())
Expand Down
32 changes: 28 additions & 4 deletions mobile/bulingo/package-lock.json

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

2 changes: 2 additions & 0 deletions mobile/bulingo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
},
"dependencies": {
"@expo/vector-icons": "^14.0.0",
"@react-native-picker/picker": "^2.9.0",
"@react-navigation/native": "^6.1.17",
"@react-navigation/stack": "^6.3.29",
"axios": "^1.6.8",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"expo": "^51.0.38",
"expo-build-properties": "~0.12.5",
"expo-font": "~12.0.10",
"expo-linking": "~6.3.1",
"expo-router": "~3.5.23",
Expand Down

0 comments on commit 20ac49b

Please sign in to comment.