Skip to content

Commit

Permalink
getting urls from env
Browse files Browse the repository at this point in the history
  • Loading branch information
shreya1mishra committed Aug 31, 2024
1 parent aeca783 commit e839964
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 29 deletions.
2 changes: 1 addition & 1 deletion App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import reducers from './src/reducers';
import { Provider } from 'react-redux';
import createSagaMiddleware from '@redux-saga/core';
import rootSaga from './src/sagas/rootSaga';

const sagaMiddleware = createSagaMiddleware();
const middleware = [sagaMiddleware];
export const store = compose(applyMiddleware(...middleware))(createStore)(
reducers,
);
sagaMiddleware.run(rootSaga);

const App = () => {
return (
<>
Expand Down
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ dependencies {
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
40 changes: 36 additions & 4 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"project_info": {
"project_number": "260594870079",
"firebase_url": "https://rds-backend-86606-default-rtdb.firebaseio.com",
"project_id": "rds-backend-86606",
"storage_bucket": "rds-backend-86606.appspot.com"
// "project_number": "260594870079",
// "firebase_url": "https://rds-backend-86606-default-rtdb.firebaseio.com",
// "project_id": "rds-backend-86606",
// "storage_bucket": "rds-backend-86606.appspot.com"
"project_number": "500338429689",
"project_id": "realdevsquad-10012",
"storage_bucket": "realdevsquad-10012.appspot.com"
},
"client": [
{
Expand Down Expand Up @@ -92,6 +95,35 @@
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:500338429689:android:3466042d6816e27fbcdc28",
"android_client_info": {
"package_name": "com.rdsapp"
}
},
"oauth_client": [
{
"client_id": "500338429689-bs60eaons6m17p788ka6tkffqthk5arl.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCCk2qqhDfeEm7_QWehc-r3H6me6_T0C5s"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "500338429689-bs60eaons6m17p788ka6tkffqthk5arl.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-native-circular-progress-indicator": "^4.4.2",
"react-native-collapsible": "^1.6.1",
"react-native-collapsible-tab-view": "^6.2.1",
"react-native-config": "^1.5.3",
"react-native-date-picker": "^4.2.13",
"react-native-datepicker": "^1.7.2",
"react-native-device-info": "^10.8.0",
Expand Down
2 changes: 0 additions & 2 deletions src/components/Notify/NotifyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const NotifyForm = ({ notifyHandler }: { notifyHandler: () => void }) => {

const getFCMToken = async () => {
const fcmToken_ = await firebase.messaging().getToken();
console.log('🚀 ~ getFCMToken ~ fcmToken_:', fcmToken_);

await postFcmToken(fcmToken_, token);
};
Expand All @@ -57,7 +56,6 @@ const NotifyForm = ({ notifyHandler }: { notifyHandler: () => void }) => {
notifyTo: selectedUser?.id,
});
await sendNotification(title, description, selectedUser?.id, token);
// LocalNotification();
};
useEffect(() => {
const fetchData = async () => {
Expand Down
8 changes: 3 additions & 5 deletions src/constants/apiConstant/AuthApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { STAGING_BASE_URL } from './BaseUrl';
// const basrUrl = 'https://api.realdevsquad.com'; //production
import Config from 'react-native-config';
const AuthApis = {
USER_DETAIL: 'https://api.realdevsquad.com/users/userId/',
QR_AUTH_API: 'https://api.realdevsquad.com/auth/qr-code-auth',
QR_AUTH_API_STAGING: `${STAGING_BASE_URL}/auth/qr-code-auth`,
USER_DETAIL: `${Config.BASE_URL}/users/userId/`,
QR_AUTH_API: `${Config.BASE_URL}/auth/qr-code-auth`,
GITHUB_AUTH_API: 'https://api.realdevsquad.com/auth/github/login',
};

Expand Down
7 changes: 3 additions & 4 deletions src/constants/apiConstant/NotifyApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LOCAL_URL, PROD_BASE_URL } from './BaseUrl';

export const SAVE_FCM_TOKEN = `${PROD_BASE_URL}/v1/fcm-tokens`;
export const NOTIFY_API = `${PROD_BASE_URL}/v1/notifications`;
import Config from 'react-native-config';
export const SAVE_FCM_TOKEN = `${Config.BASE_URL}/v1/fcm-tokens`;
export const NOTIFY_API = `${Config.BASE_URL}/v1/notifications`;
16 changes: 5 additions & 11 deletions src/screens/AuthScreen/AuthScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ import { AuthContext } from '../../context/AuthContext';
import { getUserData, goalsAuth, requestCameraPermission } from './Util';
import { storeData } from '../../utils/dataStore';
import AuthApis from '../../constants/apiConstant/AuthApi';
// import { AuthApisStaging } from '../../constants/apiConstant/AuthApi';
import { CameraScreen } from 'react-native-camera-kit';
import CustomModal from '../../components/Modal/CustomModal';
import LoadingScreen from '../../components/LoadingScreen';
import Tooltip from 'react-native-walkthrough-tooltip';
import { useSelector } from 'react-redux';
// import Github from '../../constants/images/Image';
import Images from '../../constants/images/Image';
import GithubSvg from '../../../assets/svgs/github_logo.js';
import WebSvg from '../../../assets/svgs/web';

const baseUrl = AuthApis.GITHUB_AUTH_API;
const AuthScreen = () => {
const { isProdEnvironment } = useSelector((store) => store.localFeatureFlag);
const { setLoggedInUserData, setGoalsData } = useContext(AuthContext);
const [loading, setLoading] = useState(false);
const [cameraActive, setCameraActive] = useState(false);
Expand Down Expand Up @@ -143,11 +139,8 @@ const AuthScreen = () => {
const qrCodeLogin = async () => {
const deviceId = await DeviceInfo.getUniqueId();

// const url = `${AuthApis.QR_AUTH_API}?device_id=${deviceId}`
const url = `${AuthApis.QR_AUTH_API}?device_id=${deviceId}`;

const url = isProdEnvironment
? `${AuthApis.QR_AUTH_API}?device_id=${deviceId}`
: `${AuthApis.QR_AUTH_API_STAGING}?device_id=${deviceId}`;
try {
const userInfo = await fetch(url);
console.log(userInfo, 'user info in rds app auth');
Expand Down Expand Up @@ -175,9 +168,8 @@ const AuthScreen = () => {
const getAuthStatus = async () => {
const deviceInfo = await DeviceInfo.getDeviceName();
const deviceId = await DeviceInfo.getUniqueId();
const url = isProdEnvironment
? AuthApis.QR_AUTH_API
: AuthApis.QR_AUTH_API_STAGING;
const url = AuthApis.QR_AUTH_API;
console.log('URL', url);
setLoading(true);
try {
const data = await fetch(url, {
Expand All @@ -191,6 +183,7 @@ const AuthScreen = () => {
device_id: deviceId,
}),
});
console.log('🚀 ~ getAuthStatus ~ data:', data);

if (data.ok) {
const dataJson = await data.json();
Expand All @@ -209,6 +202,7 @@ const AuthScreen = () => {
]);
} else {
await data.json();
console.log('dataa>>>', data.json());
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again',
Expand Down
7 changes: 5 additions & 2 deletions src/screens/AuthScreen/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
NOTIFY_API,
SAVE_FCM_TOKEN,
} from '../../constants/apiConstant/NotifyApi';
import Config from 'react-native-config';

export const getUserData = async (token: string) => {
try {
Expand Down Expand Up @@ -448,14 +449,16 @@ export const overallTaskProgress = async (
};

export const postFcmToken = async (fcmToken: string, token: string) => {
console.log('token is ', `${Config.RDS_SESSION}=${token}`);
try {
const response = await axios.post(
SAVE_FCM_TOKEN,
{ fcmToken: fcmToken },
{
headers: {
'Content-Type': 'application/json',
Cookie: `rds-session=${token}`,
Cookie:
'rds-session-staging=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI0ZG5EcjVJNVB0N0N2bGpSUmttMiIsImlhdCI6MTcyNTEyOTcxNSwiZXhwIjoxNzU2MjMzNzE1fQ.Xknq3-RBz5aKPWnQ6pXypEmSs2M91lr_jnijP4Ih_GW_hrU0GBT3HaHRGXKoLWvKieV086OeKPMbLYbOAD7JWTOfJY1ebXuEUUYTjTI3bO3IyOCWsw_KIswBONebmQCyAqvm9HfvHU9UoPg-30tb1Bec4J3wGp7ciVnKatr6noU',
},
},
);
Expand All @@ -481,7 +484,7 @@ export const sendNotification = async (
{
headers: {
'Content-Type': 'application/json',
Cookie: `rds-session=${token}`,
Cookie: `${Config.RDS_SESSION}${token}`,
},
},
);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7813,6 +7813,11 @@ react-native-collapsible@^1.6.1:
resolved "https://registry.npmjs.org/react-native-collapsible/-/react-native-collapsible-1.6.1.tgz"
integrity sha512-orF4BeiXd2hZW7fu9YcqIJXzN6TJcFcddY807D3MAOVktLuW9oQ+RIkrTJ5DR3v9ZOFfREkOjEmS79qeUTvkBQ==

react-native-config@^1.5.3:
version "1.5.3"
resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.5.3.tgz#1286c0c117adb367a948b31005430146e88c9c2e"
integrity sha512-3D05Abgk5DfDw9w258EzXvX5AkU7eqj3u9H0H0L4gUga4nYg/zuupcrpGbpF4QeXBcJ84jjs6g8JaEP6VBT7Pg==

react-native-date-picker@^4.2.13:
version "4.2.13"
resolved "https://registry.npmjs.org/react-native-date-picker/-/react-native-date-picker-4.2.13.tgz"
Expand Down

0 comments on commit e839964

Please sign in to comment.