Modificacion para que tome todas las lineas y cambio de remote config
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"project_info": {
|
||||
"project_number": "473250290916",
|
||||
"project_id": "smartstop-7a69d",
|
||||
"storage_bucket": "smartstop-7a69d.appspot.com"
|
||||
"project_number": "649637283755",
|
||||
"project_id": "smartstop-e9b90",
|
||||
"storage_bucket": "smartstop-e9b90.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:473250290916:android:6153a7d8264a90b963e0f1",
|
||||
"mobilesdk_app_id": "1:649637283755:android:02f9b01c4acf051ca174ee",
|
||||
"android_client_info": {
|
||||
"package_name": "com.smartstop"
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
|||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAI7Q2y3XOAO8qQfnOZAOfFGqzS4pjbD7k"
|
||||
"current_key": "AIzaSyCvcskItwpjqoA2wiNv4xwHhNoYsinfU2s"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"project_info": {
|
||||
"project_number": "473250290916",
|
||||
"project_id": "smartstop-7a69d",
|
||||
"storage_bucket": "smartstop-7a69d.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:473250290916:android:6153a7d8264a90b963e0f1",
|
||||
"android_client_info": {
|
||||
"package_name": "com.smartstop"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAI7Q2y3XOAO8qQfnOZAOfFGqzS4pjbD7k"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 30 KiB |
|
@ -18,7 +18,7 @@
|
|||
"moment": "^2.29.4",
|
||||
"react": "18.2.0",
|
||||
"react-native": "0.72.6",
|
||||
"react-native-device-info": "^10.11.0",
|
||||
"react-native-device-info": "^10.13.1",
|
||||
"react-native-vector-icons": "^10.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -12,8 +12,11 @@ class BusStopInfoService {
|
|||
|
||||
getLines(): LineDetail[] {
|
||||
return this.lines;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
getLinesByNumber(lineNumber: string): LineDetail {
|
||||
const line = this.lines.find(bus => bus.lineNumber === lineNumber);
|
||||
|
||||
|
@ -40,9 +43,9 @@ class BusStopInfoService {
|
|||
compareTime.set('minute', getMinutes(arrival.estimatedGPS));
|
||||
compareTime.set('second', getSeconds(arrival.estimatedGPS));
|
||||
|
||||
if (compareTime.isAfter(currentTime)) {
|
||||
//if (compareTime.isAfter(currentTime)) {
|
||||
return arrival;
|
||||
}
|
||||
// }
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class AuthAPI {
|
|||
this.baseURL = baseURL;
|
||||
}
|
||||
|
||||
async auth({username, password}: AuthRequest): Promise<AuthResponse> {
|
||||
async auth({username, password,rut}: AuthRequest): Promise<AuthResponse> {
|
||||
if (!username) {
|
||||
throw new Error('username is required');
|
||||
}
|
||||
|
@ -18,12 +18,15 @@ class AuthAPI {
|
|||
if (!password) {
|
||||
throw new Error('password is required');
|
||||
}
|
||||
|
||||
if (!rut) {
|
||||
throw new Error('rut is required');
|
||||
}
|
||||
const {data} = await axios.post<AuthResponse>(
|
||||
`${this.baseURL}${LOGIN_METHOD}`,
|
||||
{
|
||||
username,
|
||||
password,
|
||||
rut,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ describe('AuthAPI tests', () => {
|
|||
const token = await authAPI.auth({
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
rut:'rut',
|
||||
});
|
||||
|
||||
expect(token).toMatchObject({token: 'token'});
|
||||
|
@ -31,6 +32,7 @@ describe('AuthAPI tests', () => {
|
|||
authAPI.auth({
|
||||
password: 'password',
|
||||
username: '',
|
||||
rut:'rut',
|
||||
}),
|
||||
).rejects.toThrow('username is required');
|
||||
});
|
||||
|
@ -40,6 +42,7 @@ describe('AuthAPI tests', () => {
|
|||
authAPI.auth({
|
||||
username: 'username',
|
||||
password: '',
|
||||
rut:'rut',
|
||||
}),
|
||||
).rejects.toThrow('password is required');
|
||||
});
|
||||
|
@ -53,6 +56,7 @@ describe('AuthAPI tests', () => {
|
|||
authAPI.auth({
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
rut:'rut',
|
||||
}),
|
||||
).rejects.toThrow('Request failed with status code 400');
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
interface AuthRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
rut:string;
|
||||
}
|
||||
|
||||
export default AuthRequest;
|
||||
|
|
|
@ -11,6 +11,7 @@ import RemoteConfigKeys from '../../utils/RemoteConfigKeys';
|
|||
import {Line} from '../../presentation/components/Table';
|
||||
import Status from '../../utils/Status';
|
||||
import {BUSES_BY_PAGE} from '../../domain/const';
|
||||
//import DeviceInfo from 'react-native-device-info';
|
||||
|
||||
export interface State {
|
||||
status: Status;
|
||||
|
@ -20,8 +21,8 @@ export interface State {
|
|||
stopMessage: string;
|
||||
stopName: string;
|
||||
}
|
||||
|
||||
const DEVICE_ID = 'TTM543870hyt';
|
||||
//const deviceId = DeviceInfo.getUniqueId();
|
||||
const DEVICE_ID ='TTM543870hyt';// String(deviceId);
|
||||
|
||||
const useDevices = () => {
|
||||
const [state, setState] = useState<State>({
|
||||
|
@ -35,10 +36,12 @@ const useDevices = () => {
|
|||
|
||||
const baseURL = remoteConfig().getString(RemoteConfigKeys.BASE_URL);
|
||||
const username = remoteConfig().getString(RemoteConfigKeys.USER);
|
||||
const password = remoteConfig().getString(RemoteConfigKeys.PASS);
|
||||
const password = remoteConfig().getString(RemoteConfigKeys.PASSWORD);
|
||||
const rut = remoteConfig().getString(RemoteConfigKeys.RUT);
|
||||
const changePageInterval = remoteConfig().getNumber(
|
||||
RemoteConfigKeys.CHANGE_PAGE_INTERVAL,
|
||||
);
|
||||
|
||||
const updateBusesListInterval = remoteConfig().getNumber(
|
||||
RemoteConfigKeys.UPDATE_BUSES_LIST_INTERVAL,
|
||||
);
|
||||
|
@ -49,6 +52,7 @@ const useDevices = () => {
|
|||
() => new DevicesRepositoryImpl(deviceApi),
|
||||
[deviceApi],
|
||||
);
|
||||
|
||||
const authRepository = useMemo(
|
||||
() => new AuthRepositoryImpl(authApi),
|
||||
[authApi],
|
||||
|
@ -56,6 +60,7 @@ const useDevices = () => {
|
|||
|
||||
const setDisplayedLines = useCallback(
|
||||
(lineDetails: LineDetail[], stopMessage: string, stopName: string) => {
|
||||
|
||||
if (!lineDetails || !stopName) {
|
||||
return;
|
||||
}
|
||||
|
@ -66,8 +71,9 @@ const useDevices = () => {
|
|||
const linesWithArrivals = lineDetails
|
||||
.map(line => {
|
||||
try {
|
||||
if (line.arrivals && line.arrivals.length > 0) {
|
||||
busStopInfoService.getNextArraival(line.lineNumber);
|
||||
|
||||
}
|
||||
return line;
|
||||
} catch (error) {
|
||||
return undefined;
|
||||
|
@ -75,19 +81,29 @@ const useDevices = () => {
|
|||
})
|
||||
.filter((line): line is LineDetail => line !== undefined);
|
||||
|
||||
|
||||
|
||||
busStopInfoService = new BusStopInfoService(linesWithArrivals);
|
||||
|
||||
var estimatedArrivalTimeInMinutes="";
|
||||
const linesToDisplay: Line[] = busStopInfoService
|
||||
.pruneBusList(state.currentIndex, BUSES_BY_PAGE)
|
||||
.map(line => {
|
||||
try {
|
||||
|
||||
|
||||
if (line.arrivals && line.arrivals.length > 0)
|
||||
{
|
||||
const nextArraival = busStopInfoService.getNextArraival(
|
||||
line.lineNumber,
|
||||
);
|
||||
|
||||
const estimatedArrivalTimeInMinutes =
|
||||
busStopInfoService.checkArraivalTime(nextArraival);
|
||||
|
||||
estimatedArrivalTimeInMinutes =busStopInfoService.checkArraivalTime(nextArraival);
|
||||
}
|
||||
else
|
||||
{
|
||||
estimatedArrivalTimeInMinutes = "Sin información";
|
||||
}
|
||||
const lineLetter =
|
||||
busStopInfoService.getLineLetterFromDescription(
|
||||
line.description,
|
||||
|
@ -150,7 +166,7 @@ const useDevices = () => {
|
|||
status: Status.LOADING,
|
||||
}));
|
||||
|
||||
const token = await authRepository.auth({username, password});
|
||||
const token = await authRepository.auth({username, password, rut});
|
||||
|
||||
const {lineDetails, stopMessage} =
|
||||
await devicesRepository.getDeviceInfo({
|
||||
|
@ -201,6 +217,7 @@ const useDevices = () => {
|
|||
password,
|
||||
updateBusesListInterval,
|
||||
username,
|
||||
rut,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -19,15 +19,17 @@ const useRemoteConfig = () => {
|
|||
HEADER_IMAGE_URL:
|
||||
'https://cdn-icons-png.flaticon.com/512/8371/8371047.png',
|
||||
USER: 'usuario1',
|
||||
PASS: 'usuario1',
|
||||
PASSWORD: 'usuario1',
|
||||
RUT:'11111111-1',
|
||||
CHANGE_PAGE_INTERVAL: 20000, // in miliseconds
|
||||
UPDATE_BUSES_LIST_INTERVAL: 600000, // in miliseconds
|
||||
UPDATE_BUSES_LIST_INTERVAL: 60000, // in miliseconds
|
||||
});
|
||||
|
||||
await remoteConfig().fetchAndActivate();
|
||||
|
||||
setStatus(Status.SUCCESS);
|
||||
} catch (error) {
|
||||
console.log(error );
|
||||
setStatus(Status.ERROR);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('AuthRepositoryImpl tests', () => {
|
|||
|
||||
const repo = new AuthRepositoryImpl(mockedAuthAPI);
|
||||
|
||||
const token = await repo.auth({username: 'username', password: 'password'});
|
||||
const token = await repo.auth({username: 'username', password: 'password',rut:'rut'});
|
||||
|
||||
expect(token).toBe('TOKEN');
|
||||
});
|
||||
|
|
|
@ -8,14 +8,28 @@ import {
|
|||
import {ViewStyle} from 'react-native';
|
||||
import Table, {Line} from './Table';
|
||||
import Status from '../../utils/Status';
|
||||
|
||||
//import DeviceInfo from 'react-native-device-info';
|
||||
import remoteConfig from '@react-native-firebase/remote-config';
|
||||
import RemoteConfigKeys from '../../utils/RemoteConfigKeys';
|
||||
interface BusListProps {
|
||||
buses: Line[];
|
||||
status: Status;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
const ERROR_MESSAGE = 'Ha ocurrido un error';
|
||||
/* let deviceId = null;
|
||||
try {
|
||||
deviceId = DeviceInfo.getUniqueId();
|
||||
} catch (error) {
|
||||
console.error('Error al obtener el ID del dispositivo:', error);
|
||||
}
|
||||
|
||||
const DEVICE_ID = deviceId ? String(deviceId) : 'No se pudo obtener el ID del dispositivo';
|
||||
const ERROR_MESSAGE = 'Ha ocurrido un error. El ID del dispositivo es: ' + DEVICE_ID;
|
||||
*/
|
||||
|
||||
//const ERROR_MESSAGE = 'Ha ocurrido un error.' ;
|
||||
const ERROR_MESSAGE = remoteConfig().getString(RemoteConfigKeys.BASE_URL);
|
||||
const EMPTY_MESSAGE = 'No buses available';
|
||||
|
||||
const BusList = ({buses, status, style}: BusListProps) => {
|
||||
|
|
|
@ -7,7 +7,7 @@ const ERROR_MESSAGE = 'Ha ocurrido un error';
|
|||
|
||||
const App = () => {
|
||||
const {status} = useRemoteConfig();
|
||||
|
||||
console.log(status);
|
||||
if (status === Status.LOADING) {
|
||||
return (
|
||||
<SafeAreaView style={styles.centeredContainer}>
|
||||
|
@ -23,6 +23,8 @@ const App = () => {
|
|||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView style={styles.container}>
|
||||
<BusStopInfoScreen />
|
||||
|
|
|
@ -34,11 +34,11 @@ const BusStopInfoScreen = () => {
|
|||
style={styles.bodyContainer}
|
||||
status={status}
|
||||
/>
|
||||
<View style={styles.footerContainer}>
|
||||
<Image
|
||||
<View style={styles.headerContainer}>
|
||||
{/*footerContainer <Image
|
||||
source={require('../../../resources/images/footer.jpg')}
|
||||
style={styles.image}
|
||||
/>
|
||||
/> */}
|
||||
</View>
|
||||
</Container>
|
||||
);
|
||||
|
@ -58,7 +58,7 @@ const styles = StyleSheet.create({
|
|||
},
|
||||
bannerContainer: {
|
||||
flex: 0.5,
|
||||
backgroundColor: 'grey',
|
||||
backgroundColor: 'orange',
|
||||
},
|
||||
bodyContainer: {
|
||||
flex: 10,
|
||||
|
|
|
@ -4,7 +4,8 @@ enum RemoteConfigKeys {
|
|||
CHANGE_PAGE_INTERVAL = 'CHANGE_PAGE_INTERVAL',
|
||||
UPDATE_BUSES_LIST_INTERVAL = 'UPDATE_BUSES_LIST_INTERVAL',
|
||||
USER = 'USER',
|
||||
PASS = 'PASSWORD',
|
||||
PASSWORD = 'PASSWORD',
|
||||
RUT = 'RUT',
|
||||
}
|
||||
|
||||
export default RemoteConfigKeys;
|
||||
|
|
|
@ -6203,10 +6203,10 @@ react-is@^17.0.1:
|
|||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
|
||||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
|
||||
|
||||
react-native-device-info@^10.11.0:
|
||||
version "10.12.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-10.12.0.tgz#be4e71cbcc9a05e8643b1a419a4450d4cef9bbcc"
|
||||
integrity sha512-gnBkjyZNEqRd+5BNrdzuvmlraHTCH/to2x0Gp9rtDt0O9xWWW1MTYohUVWX9A0Ad2HVYcGanDCIvjWp4ngMZFg==
|
||||
react-native-device-info@^10.13.1:
|
||||
version "10.13.1"
|
||||
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-10.13.1.tgz#f87f44ba7b67933248be10ca302a4f2f6dbbdd4f"
|
||||
integrity sha512-j/7Z+Yl9Cesjp8vKaVzbuJQKJSVs4ojXATt5WjwipZ0Ss0mBJjqtbc4x5dfZLmQ4y55VVa7c0v8KHca1iqY/TQ==
|
||||
|
||||
react-native-vector-icons@^10.0.2:
|
||||
version "10.0.3"
|
||||
|
|