From 128af0b81375b284a37e8560d14bc53514f23663 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Sun, 9 May 2021 15:00:39 +0200 Subject: [PATCH] Centralized urls --- .../Collapsible/CollapsibleComponent.tsx | 2 +- src/components/Screens/WebSectionList.tsx | 3 +- src/constants/AvailableWebsites.ts | 32 ------- src/constants/ProxiwashConstants.ts | 8 +- src/constants/Urls.tsx | 91 +++++++++++++++++++ src/managers/ServicesManager.ts | 91 ++++++------------- src/screens/About/AboutScreen.tsx | 26 ++---- src/screens/Amicale/LoginScreen.tsx | 8 +- src/screens/Amicale/ProfileScreen.tsx | 4 +- src/screens/Home/HomeScreen.tsx | 6 +- src/screens/Other/FeedbackScreen.tsx | 20 ++-- src/screens/Planning/PlanningScreen.tsx | 4 +- .../Proxiwash/ProxiwashAboutScreen.tsx | 7 +- .../Services/Proximo/ProximoAboutScreen.tsx | 9 +- .../Services/Proximo/ProximoMainScreen.tsx | 4 +- src/screens/Services/SelfMenuScreen.tsx | 6 +- src/screens/Services/WebsiteScreen.tsx | 12 +-- src/utils/WebData.ts | 6 +- 18 files changed, 166 insertions(+), 173 deletions(-) delete mode 100644 src/constants/AvailableWebsites.ts create mode 100644 src/constants/Urls.tsx diff --git a/src/components/Collapsible/CollapsibleComponent.tsx b/src/components/Collapsible/CollapsibleComponent.tsx index 5b2b59d..6aba7e5 100644 --- a/src/components/Collapsible/CollapsibleComponent.tsx +++ b/src/components/Collapsible/CollapsibleComponent.tsx @@ -34,7 +34,7 @@ export type CollapsibleComponentPropsType = { hasTab?: boolean; onScroll?: (event: NativeSyntheticEvent) => void; paddedProps?: (paddingTop: number) => Record; - headerColors: string; + headerColors?: string; }; type Props = CollapsibleComponentPropsType & { diff --git a/src/components/Screens/WebSectionList.tsx b/src/components/Screens/WebSectionList.tsx index b061d18..f8c0fe9 100644 --- a/src/components/Screens/WebSectionList.tsx +++ b/src/components/Screens/WebSectionList.tsx @@ -54,9 +54,8 @@ type PropsType = { data: RawData | null, isLoading?: boolean ) => SectionListDataType; - onScroll: (event: NativeSyntheticEvent) => void; - collapsibleStack: Collapsible; + onScroll?: (event: NativeSyntheticEvent) => void; showError?: boolean; itemHeight?: number | null; updateData?: number; diff --git a/src/constants/AvailableWebsites.ts b/src/constants/AvailableWebsites.ts deleted file mode 100644 index 664b991..0000000 --- a/src/constants/AvailableWebsites.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 - 2020 Arnaud Vergnet. - * - * This file is part of Campus INSAT. - * - * Campus INSAT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Campus INSAT is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Campus INSAT. If not, see . - */ - -export default { - websites: { - AMICALE: 'https://www.amicale-insat.fr/', - AVAILABLE_ROOMS: 'http://planex.insa-toulouse.fr/salles.php', - BIB: 'https://bibbox.insa-toulouse.fr/', - BLUEMIND: 'https://etud-mel.insa-toulouse.fr/webmail/', - ELUS_ETUDIANTS: 'https://etud.insa-toulouse.fr/~eeinsat/', - ENT: 'https://ent.insa-toulouse.fr/', - INSA_ACCOUNT: 'https://moncompte.insa-toulouse.fr/', - TUTOR_INSA: 'https://www.etud.insa-toulouse.fr/~tutorinsa/', - WIKETUD: 'https://wiki.etud.insa-toulouse.fr/', - }, -}; diff --git a/src/constants/ProxiwashConstants.ts b/src/constants/ProxiwashConstants.ts index d08185c..5f02836 100644 --- a/src/constants/ProxiwashConstants.ts +++ b/src/constants/ProxiwashConstants.ts @@ -17,6 +17,8 @@ * along with Campus INSAT. If not, see . */ +import Urls from './Urls'; + export enum MachineStates { AVAILABLE, RUNNING, @@ -45,8 +47,7 @@ export default { tarif: 'screens.proxiwash.washinsa.tariff', paymentMethods: 'screens.proxiwash.washinsa.paymentMethods', icon: 'school-outline', - url: - 'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json', + url: Urls.app.api + 'washinsa/washinsa_data.json', }, tripodeB: { id: 'tripodeB', @@ -56,7 +57,6 @@ export default { tarif: 'screens.proxiwash.tripodeB.tariff', paymentMethods: 'screens.proxiwash.tripodeB.paymentMethods', icon: 'domain', - url: - 'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json', + url: Urls.app.api + 'washinsa/tripode_b_data.json', }, }; diff --git a/src/constants/Urls.tsx b/src/constants/Urls.tsx new file mode 100644 index 0000000..d2c9343 --- /dev/null +++ b/src/constants/Urls.tsx @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019 - 2020 Arnaud Vergnet. + * + * This file is part of Campus INSAT. + * + * Campus INSAT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Campus INSAT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Campus INSAT. If not, see . + */ + +const STUDENT_SERVER = 'https://etud.insa-toulouse.fr/'; +const AMICALE_SERVER = 'https://www.amicale-insat.fr/'; +const GIT_SERVER = + 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/'; + +const AMICALE_ENDPOINT = AMICALE_SERVER + 'api/'; + +const APP_ENDPOINT = STUDENT_SERVER + '~amicale_app/v2/'; +const PROXIMO_ENDPOINT = STUDENT_SERVER + '~proximo/data/stock-v2.json'; +const APP_IMAGES_ENDPOINT = STUDENT_SERVER + '~amicale_app/images/'; + +export default { + amicale: { + api: APP_ENDPOINT, + resetPassword: AMICALE_SERVER + 'password/reset', + events: AMICALE_ENDPOINT + 'event/list', + }, + app: { + api: APP_ENDPOINT, + dashboard: APP_ENDPOINT + 'dashboard/dashboard_data.json', + menu: APP_ENDPOINT + 'menu/menu_data.json', + }, + proximo: PROXIMO_ENDPOINT, + images: { + proxiwash: APP_IMAGES_ENDPOINT + 'Proxiwash.png', + washer: APP_IMAGES_ENDPOINT + 'ProxiwashLaveLinge.png', + dryer: APP_IMAGES_ENDPOINT + 'ProxiwashSecheLinge.png', + proximo: APP_IMAGES_ENDPOINT + 'Proximo.png', + clubs: APP_IMAGES_ENDPOINT + 'Clubs.png', + profile: APP_IMAGES_ENDPOINT + 'ProfilAmicaliste.png', + equipment: APP_IMAGES_ENDPOINT + 'Materiel.png', + vote: APP_IMAGES_ENDPOINT + 'Vote.png', + amicale: APP_IMAGES_ENDPOINT + 'WebsiteAmicale.png', + wiketud: APP_IMAGES_ENDPOINT + 'Wiketud.png', + elusEtudiants: APP_IMAGES_ENDPOINT + 'EEC.png', + tutorInsa: APP_IMAGES_ENDPOINT + 'TutorINSA.png', + bib: APP_IMAGES_ENDPOINT + 'Bib.png', + menu: APP_IMAGES_ENDPOINT + 'RU.png', + availableRooms: APP_IMAGES_ENDPOINT + 'Salles.png', + bluemind: APP_IMAGES_ENDPOINT + 'Bluemind.png', + ent: APP_IMAGES_ENDPOINT + 'ENT.png', + insaAccount: APP_IMAGES_ENDPOINT + 'Account.png', + }, + websites: { + amicale: AMICALE_SERVER, + availableRooms: 'http://planex.insa-toulouse.fr/salles.php', + bib: 'https://bibbox.insa-toulouse.fr/', + bluemind: 'https://etud-mel.insa-toulouse.fr/webmail/', + elusEtudiants: STUDENT_SERVER + '~eeinsat/', + ent: 'https://ent.insa-toulouse.fr/', + insaAccount: 'https://moncompte.insa-toulouse.fr/', + tutorInsa: STUDENT_SERVER + '~tutorinsa/', + wiketud: 'https://wiki.etud.insa-toulouse.fr/', + }, + about: { + appstore: 'https://apps.apple.com/us/app/campus-amicale-insat/id1477722148', + playstore: + 'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application', + react: 'https://facebook.github.io/react-native/', + git: GIT_SERVER + 'src/branch/master/README.md', + changelog: GIT_SERVER + 'src/branch/master/Changelog.md', + license: GIT_SERVER + 'src/branch/master/LICENSE', + }, + feedback: { + git: GIT_SERVER, + trello: 'https://trello.com/b/RMej49Uq/application-campus-insa', + facebook: 'https://www.facebook.com/campus.insat', + mail: `mailto:app@amicale-insat.fr?subject=[FEEDBACK] Application CAMPUS +&body=Coucou Arnaud j'ai du feedback\n\n\n\nBien cordialement.`, + discord: 'https://discord.gg/W8MeTec', + }, +}; diff --git a/src/managers/ServicesManager.ts b/src/managers/ServicesManager.ts index c16bfc0..ff29d98 100644 --- a/src/managers/ServicesManager.ts +++ b/src/managers/ServicesManager.ts @@ -19,47 +19,10 @@ import i18n from 'i18n-js'; import { StackNavigationProp } from '@react-navigation/stack'; -import AvailableWebsites from '../constants/AvailableWebsites'; import ConnectionManager from './ConnectionManager'; import type { FullDashboardType } from '../screens/Home/HomeScreen'; import getStrippedServicesList from '../utils/Services'; - -// AMICALE -const CLUBS_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Clubs.png'; -const PROFILE_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/ProfilAmicaliste.png'; -const EQUIPMENT_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Materiel.png'; -const VOTE_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/Vote.png'; -const AMICALE_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/WebsiteAmicale.png'; - -// STUDENTS -const PROXIMO_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png'; -const WIKETUD_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Wiketud.png'; -const EE_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/EEC.png'; -const TUTORINSA_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/TutorINSA.png'; - -// INSA -const BIB_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/Bib.png'; -const RU_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/RU.png'; -const ROOM_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Salles.png'; -const EMAIL_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Bluemind.png'; -const ENT_IMAGE = 'https://etud.insa-toulouse.fr/~amicale_app/images/ENT.png'; -const ACCOUNT_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/Account.png'; - -// SPECIAL -const WASHER_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashLaveLinge.png'; -const DRYER_IMAGE = - 'https://etud.insa-toulouse.fr/~amicale_app/images/ProxiwashSecheLinge.png'; +import Urls from '../constants/Urls'; const AMICALE_LOGO = require('../../assets/amicale.png'); @@ -127,31 +90,31 @@ export default class ServicesManager { key: SERVICES_KEY.CLUBS, title: i18n.t('screens.clubs.title'), subtitle: i18n.t('screens.services.descriptions.clubs'), - image: CLUBS_IMAGE, + image: Urls.images.clubs, onPress: (): void => this.onAmicaleServicePress('club-list'), }, { key: SERVICES_KEY.PROFILE, title: i18n.t('screens.profile.title'), subtitle: i18n.t('screens.services.descriptions.profile'), - image: PROFILE_IMAGE, + image: Urls.images.profile, onPress: (): void => this.onAmicaleServicePress('profile'), }, { key: SERVICES_KEY.EQUIPMENT, title: i18n.t('screens.equipment.title'), subtitle: i18n.t('screens.services.descriptions.equipment'), - image: EQUIPMENT_IMAGE, + image: Urls.images.equipment, onPress: (): void => this.onAmicaleServicePress('equipment-list'), }, { key: SERVICES_KEY.AMICALE_WEBSITE, title: i18n.t('screens.websites.amicale'), subtitle: i18n.t('screens.services.descriptions.amicaleWebsite'), - image: AMICALE_IMAGE, + image: Urls.images.amicale, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.AMICALE, + host: Urls.websites.amicale, title: i18n.t('screens.websites.amicale'), }), }, @@ -159,7 +122,7 @@ export default class ServicesManager { key: SERVICES_KEY.VOTE, title: i18n.t('screens.vote.title'), subtitle: i18n.t('screens.services.descriptions.vote'), - image: VOTE_IMAGE, + image: Urls.images.vote, onPress: (): void => this.onAmicaleServicePress('vote'), }, ]; @@ -168,7 +131,7 @@ export default class ServicesManager { key: SERVICES_KEY.PROXIMO, title: i18n.t('screens.proximo.title'), subtitle: i18n.t('screens.services.descriptions.proximo'), - image: PROXIMO_IMAGE, + image: Urls.images.proximo, onPress: (): void => nav.navigate('proximo'), badgeFunction: (dashboard: FullDashboardType): number => dashboard.proximo_articles, @@ -177,10 +140,10 @@ export default class ServicesManager { key: SERVICES_KEY.WIKETUD, title: 'Wiketud', subtitle: i18n.t('screens.services.descriptions.wiketud'), - image: WIKETUD_IMAGE, + image: Urls.images.wiketud, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.WIKETUD, + host: Urls.websites.wiketud, title: 'Wiketud', }), }, @@ -188,10 +151,10 @@ export default class ServicesManager { key: SERVICES_KEY.ELUS_ETUDIANTS, title: 'Élus Étudiants', subtitle: i18n.t('screens.services.descriptions.elusEtudiants'), - image: EE_IMAGE, + image: Urls.images.elusEtudiants, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.ELUS_ETUDIANTS, + host: Urls.websites.elusEtudiants, title: 'Élus Étudiants', }), }, @@ -199,10 +162,10 @@ export default class ServicesManager { key: SERVICES_KEY.TUTOR_INSA, title: "Tutor'INSA", subtitle: i18n.t('screens.services.descriptions.tutorInsa'), - image: TUTORINSA_IMAGE, + image: Urls.images.tutorInsa, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.TUTOR_INSA, + host: Urls.websites.tutorInsa, title: "Tutor'INSA", }), badgeFunction: (dashboard: FullDashboardType): number => @@ -214,7 +177,7 @@ export default class ServicesManager { key: SERVICES_KEY.RU, title: i18n.t('screens.menu.title'), subtitle: i18n.t('screens.services.descriptions.self'), - image: RU_IMAGE, + image: Urls.images.menu, onPress: (): void => nav.navigate('self-menu'), badgeFunction: (dashboard: FullDashboardType): number => dashboard.today_menu.length, @@ -223,10 +186,10 @@ export default class ServicesManager { key: SERVICES_KEY.AVAILABLE_ROOMS, title: i18n.t('screens.websites.rooms'), subtitle: i18n.t('screens.services.descriptions.availableRooms'), - image: ROOM_IMAGE, + image: Urls.images.availableRooms, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.AVAILABLE_ROOMS, + host: Urls.websites.availableRooms, title: i18n.t('screens.websites.rooms'), }), }, @@ -234,10 +197,10 @@ export default class ServicesManager { key: SERVICES_KEY.BIB, title: i18n.t('screens.websites.bib'), subtitle: i18n.t('screens.services.descriptions.bib'), - image: BIB_IMAGE, + image: Urls.images.bib, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.BIB, + host: Urls.websites.bib, title: i18n.t('screens.websites.bib'), }), }, @@ -245,10 +208,10 @@ export default class ServicesManager { key: SERVICES_KEY.EMAIL, title: i18n.t('screens.websites.mails'), subtitle: i18n.t('screens.services.descriptions.mails'), - image: EMAIL_IMAGE, + image: Urls.images.bluemind, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.BLUEMIND, + host: Urls.websites.bluemind, title: i18n.t('screens.websites.mails'), }), }, @@ -256,10 +219,10 @@ export default class ServicesManager { key: SERVICES_KEY.ENT, title: i18n.t('screens.websites.ent'), subtitle: i18n.t('screens.services.descriptions.ent'), - image: ENT_IMAGE, + image: Urls.images.ent, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.ENT, + host: Urls.websites.ent, title: i18n.t('screens.websites.ent'), }), }, @@ -267,10 +230,10 @@ export default class ServicesManager { key: SERVICES_KEY.INSA_ACCOUNT, title: i18n.t('screens.insaAccount.title'), subtitle: i18n.t('screens.services.descriptions.insaAccount'), - image: ACCOUNT_IMAGE, + image: Urls.images.insaAccount, onPress: (): void => nav.navigate('website', { - host: AvailableWebsites.websites.INSA_ACCOUNT, + host: Urls.websites.insaAccount, title: i18n.t('screens.insaAccount.title'), }), }, @@ -280,7 +243,7 @@ export default class ServicesManager { key: SERVICES_KEY.WASHERS, title: i18n.t('screens.proxiwash.washers'), subtitle: i18n.t('screens.services.descriptions.washers'), - image: WASHER_IMAGE, + image: Urls.images.washer, onPress: (): void => nav.navigate('proxiwash'), badgeFunction: (dashboard: FullDashboardType): number => dashboard.available_washers, @@ -289,7 +252,7 @@ export default class ServicesManager { key: SERVICES_KEY.DRYERS, title: i18n.t('screens.proxiwash.dryers'), subtitle: i18n.t('screens.services.descriptions.washers'), - image: DRYER_IMAGE, + image: Urls.images.dryer, onPress: (): void => nav.navigate('proxiwash'), badgeFunction: (dashboard: FullDashboardType): number => dashboard.available_dryers, diff --git a/src/screens/About/AboutScreen.tsx b/src/screens/About/AboutScreen.tsx index f1fc384..be9efbd 100644 --- a/src/screens/About/AboutScreen.tsx +++ b/src/screens/About/AboutScreen.tsx @@ -34,6 +34,7 @@ import CollapsibleFlatList from '../../components/Collapsible/CollapsibleFlatLis import OptionsDialog from '../../components/Dialogs/OptionsDialog'; import type { OptionsDialogButtonType } from '../../components/Dialogs/OptionsDialog'; import GENERAL_STYLES from '../../constants/Styles'; +import Urls from '../../constants/Urls'; const APP_LOGO = require('../../../assets/android.icon.round.png'); @@ -53,19 +54,6 @@ type MemberItemType = { mail?: string; }; -const links = { - appstore: 'https://apps.apple.com/us/app/campus-amicale-insat/id1477722148', - playstore: - 'https://play.google.com/store/apps/details?id=fr.amicaleinsat.application', - git: - 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/README.md', - changelog: - 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/Changelog.md', - license: - 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/src/branch/master/LICENSE', - react: 'https://facebook.github.io/react-native/', -}; - type PropsType = { navigation: StackNavigationProp; }; @@ -177,7 +165,9 @@ class AboutScreen extends React.Component { appData: Array = [ { onPressCallback: () => { - openWebLink(Platform.OS === 'ios' ? links.appstore : links.playstore); + openWebLink( + Platform.OS === 'ios' ? Urls.about.appstore : Urls.about.playstore + ); }, icon: Platform.OS === 'ios' ? 'apple' : 'google-play', text: @@ -197,7 +187,7 @@ class AboutScreen extends React.Component { }, { onPressCallback: () => { - openWebLink(links.git); + openWebLink(Urls.about.git); }, icon: 'git', text: 'Git', @@ -205,7 +195,7 @@ class AboutScreen extends React.Component { }, { onPressCallback: () => { - openWebLink(links.changelog); + openWebLink(Urls.about.changelog); }, icon: 'refresh', text: i18n.t('screens.about.changelog'), @@ -213,7 +203,7 @@ class AboutScreen extends React.Component { }, { onPressCallback: () => { - openWebLink(links.license); + openWebLink(Urls.about.license); }, icon: 'file-document', text: i18n.t('screens.about.license'), @@ -237,7 +227,7 @@ class AboutScreen extends React.Component { technoData = [ { onPressCallback: () => { - openWebLink(links.react); + openWebLink(Urls.about.react); }, icon: 'react', text: i18n.t('screens.about.reactNative'), diff --git a/src/screens/Amicale/LoginScreen.tsx b/src/screens/Amicale/LoginScreen.tsx index 5bbb0b0..b1485c2 100644 --- a/src/screens/Amicale/LoginScreen.tsx +++ b/src/screens/Amicale/LoginScreen.tsx @@ -32,12 +32,12 @@ import LinearGradient from 'react-native-linear-gradient'; import ConnectionManager from '../../managers/ConnectionManager'; import ErrorDialog from '../../components/Dialogs/ErrorDialog'; import AsyncStorageManager from '../../managers/AsyncStorageManager'; -import AvailableWebsites from '../../constants/AvailableWebsites'; import { MASCOT_STYLE } from '../../components/Mascot/Mascot'; import MascotPopup from '../../components/Mascot/MascotPopup'; import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView'; import { MainStackParamsList } from '../../navigation/MainNavigator'; import GENERAL_STYLES from '../../constants/Styles'; +import Urls from '../../constants/Urls'; type LoginScreenNavigationProp = StackScreenProps; @@ -59,8 +59,6 @@ type StateType = { const ICON_AMICALE = require('../../../assets/amicale.png'); -const RESET_PASSWORD_PATH = 'https://www.amicale-insat.fr/password/reset'; - const emailRegex = /^.+@.+\..+$/; const styles = StyleSheet.create({ @@ -134,8 +132,8 @@ class LoginScreen extends React.Component { onResetPasswordClick = () => { const { navigation } = this.props; navigation.navigate('website', { - host: AvailableWebsites.websites.AMICALE, - path: RESET_PASSWORD_PATH, + host: Urls.websites.amicale, + path: Urls.amicale.resetPassword, title: i18n.t('screens.websites.amicale'), }); }; diff --git a/src/screens/Amicale/ProfileScreen.tsx b/src/screens/Amicale/ProfileScreen.tsx index 27bdf0d..4d533e5 100644 --- a/src/screens/Amicale/ProfileScreen.tsx +++ b/src/screens/Amicale/ProfileScreen.tsx @@ -36,12 +36,12 @@ import MaterialHeaderButtons, { Item, } from '../../components/Overrides/CustomHeaderButton'; import CardList from '../../components/Lists/CardList/CardList'; -import AvailableWebsites from '../../constants/AvailableWebsites'; import Mascot, { MASCOT_STYLE } from '../../components/Mascot/Mascot'; import ServicesManager, { SERVICES_KEY } from '../../managers/ServicesManager'; import CollapsibleFlatList from '../../components/Collapsible/CollapsibleFlatList'; import type { ServiceItemType } from '../../managers/ServicesManager'; import GENERAL_STYLES from '../../constants/Styles'; +import Urls from '../../constants/Urls'; type PropsType = { navigation: StackNavigationProp; @@ -298,7 +298,7 @@ class ProfileScreen extends React.Component { mode="contained" onPress={() => { navigation.navigate('website', { - host: AvailableWebsites.websites.AMICALE, + host: Urls.websites.amicale, path: this.data?.link, title: i18n.t('screens.websites.amicale'), }); diff --git a/src/screens/Home/HomeScreen.tsx b/src/screens/Home/HomeScreen.tsx index cf0b19d..9375b8f 100644 --- a/src/screens/Home/HomeScreen.tsx +++ b/src/screens/Home/HomeScreen.tsx @@ -51,10 +51,8 @@ import type { ServiceItemType } from '../../managers/ServicesManager'; import { getDisplayEvent, getFutureEvents } from '../../utils/Home'; import type { PlanningEventType } from '../../utils/Planning'; import GENERAL_STYLES from '../../constants/Styles'; -// import DATA from "../dashboard_data.json"; +import Urls from '../../constants/Urls'; -const DATA_URL = - 'https://etud.insa-toulouse.fr/~amicale_app/v2/dashboard/dashboard_data.json'; const FEED_ITEM_HEIGHT = 500; const SECTIONS_ID = ['dashboard', 'news_feed']; @@ -476,7 +474,7 @@ class HomeScreen extends React.Component { createDataset={this.createDataset} autoRefreshTime={REFRESH_TIME} refreshOnFocus - fetchUrl={DATA_URL} + fetchUrl={Urls.app.dashboard} renderItem={this.getRenderItem} itemHeight={FEED_ITEM_HEIGHT} onScroll={this.onScroll} diff --git a/src/screens/Other/FeedbackScreen.tsx b/src/screens/Other/FeedbackScreen.tsx index c6e7f49..fdaa567 100644 --- a/src/screens/Other/FeedbackScreen.tsx +++ b/src/screens/Other/FeedbackScreen.tsx @@ -22,15 +22,7 @@ import { Avatar, Button, Card, Paragraph, withTheme } from 'react-native-paper'; import i18n from 'i18n-js'; import { Linking, StyleSheet, View } from 'react-native'; import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView'; - -const links = { - bugsGit: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/', - trello: 'https://trello.com/b/RMej49Uq/application-campus-insa', - facebook: 'https://www.facebook.com/campus.insat', - feedbackMail: `mailto:app@amicale-insat.fr?subject=[FEEDBACK] Application CAMPUS -&body=Coucou Arnaud j'ai du feedback\n\n\n\nBien cordialement.`, - feedbackDiscord: 'https://discord.gg/W8MeTec', -}; +import Urls from '../../constants/Urls'; const styles = StyleSheet.create({ container: { @@ -63,7 +55,7 @@ function getButtons(isFeedback: boolean) { mode="contained" style={styles.button} onPress={() => { - Linking.openURL(links.feedbackMail); + Linking.openURL(Urls.feedback.mail); }} > MAIL @@ -74,7 +66,7 @@ function getButtons(isFeedback: boolean) { color="#2e88fe" style={styles.button} onPress={() => { - Linking.openURL(links.facebook); + Linking.openURL(Urls.feedback.facebook); }} > Facebook @@ -85,7 +77,7 @@ function getButtons(isFeedback: boolean) { color="#7289da" style={styles.button} onPress={() => { - Linking.openURL(links.feedbackDiscord); + Linking.openURL(Urls.feedback.discord); }} > Discord @@ -99,7 +91,7 @@ function getButtons(isFeedback: boolean) { color="#609927" style={styles.button} onPress={() => { - Linking.openURL(links.bugsGit); + Linking.openURL(Urls.feedback.git); }} > GITETUD @@ -110,7 +102,7 @@ function getButtons(isFeedback: boolean) { color="#026AA7" style={styles.button} onPress={() => { - Linking.openURL(links.trello); + Linking.openURL(Urls.feedback.trello); }} > TRELLO diff --git a/src/screens/Planning/PlanningScreen.tsx b/src/screens/Planning/PlanningScreen.tsx index aa03479..b2dd409 100644 --- a/src/screens/Planning/PlanningScreen.tsx +++ b/src/screens/Planning/PlanningScreen.tsx @@ -36,6 +36,7 @@ import { MASCOT_STYLE } from '../../components/Mascot/Mascot'; import MascotPopup from '../../components/Mascot/MascotPopup'; import AsyncStorageManager from '../../managers/AsyncStorageManager'; import GENERAL_STYLES from '../../constants/Styles'; +import Urls from '../../constants/Urls'; LocaleConfig.locales.fr = { monthNames: [ @@ -88,7 +89,6 @@ type StateType = { calendarShowing: boolean; }; -const FETCH_URL = 'https://www.amicale-insat.fr/api/event/list'; const AGENDA_MONTH_SPAN = 3; const styles = StyleSheet.create({ @@ -174,7 +174,7 @@ class PlanningScreen extends React.Component { if (canRefresh) { this.setState({ refreshing: true }); - readData(FETCH_URL) + readData(Urls.amicale.events) .then((fetchedData: Array) => { this.setState({ refreshing: false, diff --git a/src/screens/Proxiwash/ProxiwashAboutScreen.tsx b/src/screens/Proxiwash/ProxiwashAboutScreen.tsx index 1a38ade..994ce54 100644 --- a/src/screens/Proxiwash/ProxiwashAboutScreen.tsx +++ b/src/screens/Proxiwash/ProxiwashAboutScreen.tsx @@ -23,8 +23,7 @@ import i18n from 'i18n-js'; import { Card, Avatar, Paragraph, Title } from 'react-native-paper'; import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView'; import ProxiwashConstants from '../../constants/ProxiwashConstants'; - -const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png'; +import Urls from '../../constants/Urls'; export type LaundromatType = { id: string; @@ -85,9 +84,9 @@ function getCardItem(item: LaundromatType) { */ export default function ProxiwashAboutScreen() { return ( - + - + {getCardItem(ProxiwashConstants.washinsa)} diff --git a/src/screens/Services/Proximo/ProximoAboutScreen.tsx b/src/screens/Services/Proximo/ProximoAboutScreen.tsx index 030ea29..63ef7f0 100644 --- a/src/screens/Services/Proximo/ProximoAboutScreen.tsx +++ b/src/screens/Services/Proximo/ProximoAboutScreen.tsx @@ -21,12 +21,9 @@ import * as React from 'react'; import { Image, StyleSheet, View } from 'react-native'; import i18n from 'i18n-js'; import { Card, Avatar, Paragraph, Text } from 'react-native-paper'; -import CustomTabBar, { - TAB_BAR_HEIGHT, -} from '../../../components/Tabbar/CustomTabBar'; +import { TAB_BAR_HEIGHT } from '../../../components/Tabbar/CustomTabBar'; import CollapsibleScrollView from '../../../components/Collapsible/CollapsibleScrollView'; - -const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proximo.png'; +import Urls from '../../../constants/Urls'; const styles = StyleSheet.create({ container: { @@ -57,7 +54,7 @@ export default function ProximoAboutScreen() { return ( - + {i18n.t('screens.proximo.description')} diff --git a/src/screens/Services/Proximo/ProximoMainScreen.tsx b/src/screens/Services/Proximo/ProximoMainScreen.tsx index 6956501..a1bd6a7 100644 --- a/src/screens/Services/Proximo/ProximoMainScreen.tsx +++ b/src/screens/Services/Proximo/ProximoMainScreen.tsx @@ -27,8 +27,8 @@ import MaterialHeaderButtons, { } from '../../../components/Overrides/CustomHeaderButton'; import type { SectionListDataType } from '../../../components/Screens/WebSectionList'; import { StyleSheet } from 'react-native'; +import Urls from '../../../constants/Urls'; -const DATA_URL = 'https://etud.insa-toulouse.fr/~proximo/data/stock-v2.json'; const LIST_ITEM_HEIGHT = 84; export type ProximoCategoryType = { @@ -320,7 +320,7 @@ class ProximoMainScreen extends React.Component { navigation={navigation} autoRefreshTime={0} refreshOnFocus={false} - fetchUrl={DATA_URL} + fetchUrl={Urls.proximo} renderItem={this.getRenderItem} /> ); diff --git a/src/screens/Services/SelfMenuScreen.tsx b/src/screens/Services/SelfMenuScreen.tsx index 21ab2df..e0e5b78 100644 --- a/src/screens/Services/SelfMenuScreen.tsx +++ b/src/screens/Services/SelfMenuScreen.tsx @@ -25,9 +25,7 @@ import i18n from 'i18n-js'; import DateManager from '../../managers/DateManager'; import WebSectionList from '../../components/Screens/WebSectionList'; import type { SectionListDataType } from '../../components/Screens/WebSectionList'; - -const DATA_URL = - 'https://etud.insa-toulouse.fr/~amicale_app/menu/menu_data.json'; +import Urls from '../../constants/Urls'; type PropsType = { navigation: StackNavigationProp; @@ -198,7 +196,7 @@ class SelfMenuScreen extends React.Component { navigation={navigation} autoRefreshTime={0} refreshOnFocus={false} - fetchUrl={DATA_URL} + fetchUrl={Urls.app.menu} renderItem={this.getRenderItem} renderSectionHeader={this.getRenderSectionHeader} stickyHeader diff --git a/src/screens/Services/WebsiteScreen.tsx b/src/screens/Services/WebsiteScreen.tsx index 49d7192..ec0430d 100644 --- a/src/screens/Services/WebsiteScreen.tsx +++ b/src/screens/Services/WebsiteScreen.tsx @@ -20,8 +20,8 @@ import * as React from 'react'; import { StackNavigationProp } from '@react-navigation/stack'; import WebViewScreen from '../../components/Screens/WebViewScreen'; -import AvailableWebsites from '../../constants/AvailableWebsites'; import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen'; +import Urls from '../../constants/Urls'; type Props = { navigation: StackNavigationProp; @@ -42,7 +42,7 @@ const BIB_STYLE = const BIB_BACK_BUTTON = "'; @@ -63,17 +63,17 @@ class WebsiteScreen extends React.Component { props.navigation.addListener('focus', this.onScreenFocus); this.injectedJS = {}; this.customPaddingFunctions = {}; - this.injectedJS[AvailableWebsites.websites.AVAILABLE_ROOMS] = + this.injectedJS[Urls.websites.availableRooms] = `document.querySelector('head').innerHTML += '${ENABLE_MOBILE_STRING}';` + `document.querySelector('head').innerHTML += '${AVAILABLE_ROOMS_STYLE}'; true;`; - this.injectedJS[AvailableWebsites.websites.BIB] = + this.injectedJS[Urls.websites.bib] = `document.querySelector('head').innerHTML += '${ENABLE_MOBILE_STRING}';` + `document.querySelector('head').innerHTML += '${BIB_STYLE}';` + 'if ($(".hero-unit-form").length > 0 && $("#customBackButton").length === 0)' + `$(".hero-unit-form").append("${BIB_BACK_BUTTON}");true;`; - this.customPaddingFunctions[AvailableWebsites.websites.BLUEMIND] = ( + this.customPaddingFunctions[Urls.websites.bluemind] = ( padding: number ): string => { return ( @@ -82,7 +82,7 @@ class WebsiteScreen extends React.Component { "$('#mailview-bottom').css('min-height', 500);" ); }; - this.customPaddingFunctions[AvailableWebsites.websites.WIKETUD] = ( + this.customPaddingFunctions[Urls.websites.wiketud] = ( padding: number ): string => { return ( diff --git a/src/utils/WebData.ts b/src/utils/WebData.ts index ea7cb93..7e4ad76 100644 --- a/src/utils/WebData.ts +++ b/src/utils/WebData.ts @@ -17,6 +17,8 @@ * along with Campus INSAT. If not, see . */ +import Urls from '../constants/Urls'; + export const ERROR_TYPE = { SUCCESS: 0, BAD_CREDENTIALS: 1, @@ -40,8 +42,6 @@ type ApiResponseType = { data: T; }; -const API_ENDPOINT = 'https://www.amicale-insat.fr/api/'; - /** * Checks if the given API response is valid. * @@ -81,7 +81,7 @@ export async function apiRequest( if (params != null) { requestParams = { ...params }; } - fetch(API_ENDPOINT + path, { + fetch(Urls.amicale.api + path, { method, headers: new Headers({ 'Accept': 'application/json',