Centralized urls

This commit is contained in:
Arnaud Vergnet 2021-05-09 15:00:39 +02:00
parent 8f06843ba6
commit 128af0b813
18 changed files with 166 additions and 173 deletions

View file

@ -34,7 +34,7 @@ export type CollapsibleComponentPropsType = {
hasTab?: boolean;
onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
paddedProps?: (paddingTop: number) => Record<string, any>;
headerColors: string;
headerColors?: string;
};
type Props = CollapsibleComponentPropsType & {

View file

@ -54,9 +54,8 @@ type PropsType<ItemT, RawData> = {
data: RawData | null,
isLoading?: boolean
) => SectionListDataType<ItemT>;
onScroll: (event: NativeSyntheticEvent<EventTarget>) => void;
collapsibleStack: Collapsible;
onScroll?: (event: NativeSyntheticEvent<EventTarget>) => void;
showError?: boolean;
itemHeight?: number | null;
updateData?: number;

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
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/',
},
};

View file

@ -17,6 +17,8 @@
* along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
*/
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',
},
};

91
src/constants/Urls.tsx Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
*/
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',
},
};

View file

@ -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,

View file

@ -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<any>;
};
@ -177,7 +165,9 @@ class AboutScreen extends React.Component<PropsType, StateType> {
appData: Array<ListItemType> = [
{
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<PropsType, StateType> {
},
{
onPressCallback: () => {
openWebLink(links.git);
openWebLink(Urls.about.git);
},
icon: 'git',
text: 'Git',
@ -205,7 +195,7 @@ class AboutScreen extends React.Component<PropsType, StateType> {
},
{
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<PropsType, StateType> {
},
{
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<PropsType, StateType> {
technoData = [
{
onPressCallback: () => {
openWebLink(links.react);
openWebLink(Urls.about.react);
},
icon: 'react',
text: i18n.t('screens.about.reactNative'),

View file

@ -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<MainStackParamsList, 'login'>;
@ -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<Props, StateType> {
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'),
});
};

View file

@ -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<any>;
@ -298,7 +298,7 @@ class ProfileScreen extends React.Component<PropsType, StateType> {
mode="contained"
onPress={() => {
navigation.navigate('website', {
host: AvailableWebsites.websites.AMICALE,
host: Urls.websites.amicale,
path: this.data?.link,
title: i18n.t('screens.websites.amicale'),
});

View file

@ -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<PropsType, StateType> {
createDataset={this.createDataset}
autoRefreshTime={REFRESH_TIME}
refreshOnFocus
fetchUrl={DATA_URL}
fetchUrl={Urls.app.dashboard}
renderItem={this.getRenderItem}
itemHeight={FEED_ITEM_HEIGHT}
onScroll={this.onScroll}

View file

@ -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

View file

@ -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<PropsType, StateType> {
if (canRefresh) {
this.setState({ refreshing: true });
readData(FETCH_URL)
readData(Urls.amicale.events)
.then((fetchedData: Array<PlanningEventType>) => {
this.setState({
refreshing: false,

View file

@ -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 (
<CollapsibleScrollView style={styles.container} hasTab>
<CollapsibleScrollView style={styles.container} hasTab={true}>
<View style={styles.imageContainer}>
<Image source={{ uri: LOGO }} style={styles.image} />
<Image source={{ uri: Urls.images.proxiwash }} style={styles.image} />
</View>
{getCardItem(ProxiwashConstants.washinsa)}

View file

@ -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 (
<CollapsibleScrollView style={styles.container}>
<View style={styles.imageContainer}>
<Image source={{ uri: LOGO }} style={styles.image} />
<Image source={{ uri: Urls.images.proximo }} style={styles.image} />
</View>
<Text>{i18n.t('screens.proximo.description')}</Text>
<Card style={styles.card}>

View file

@ -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<PropsType> {
navigation={navigation}
autoRefreshTime={0}
refreshOnFocus={false}
fetchUrl={DATA_URL}
fetchUrl={Urls.proximo}
renderItem={this.getRenderItem}
/>
);

View file

@ -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<any>;
@ -198,7 +196,7 @@ class SelfMenuScreen extends React.Component<PropsType> {
navigation={navigation}
autoRefreshTime={0}
refreshOnFocus={false}
fetchUrl={DATA_URL}
fetchUrl={Urls.app.menu}
renderItem={this.getRenderItem}
renderSectionHeader={this.getRenderSectionHeader}
stickyHeader

View file

@ -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<any>;
@ -42,7 +42,7 @@ const BIB_STYLE =
const BIB_BACK_BUTTON =
"<div style='width: 100%; display: flex'>" +
`<a style='margin: auto' href='${AvailableWebsites.websites.BIB}'>` +
`<a style='margin: auto' href='${Urls.websites.bib}'>` +
"<button id='customBackButton' class='btn btn-primary'>Retour</button>" +
'</a>' +
'</div>';
@ -63,17 +63,17 @@ class WebsiteScreen extends React.Component<Props, State> {
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<Props, State> {
"$('#mailview-bottom').css('min-height', 500);"
);
};
this.customPaddingFunctions[AvailableWebsites.websites.WIKETUD] = (
this.customPaddingFunctions[Urls.websites.wiketud] = (
padding: number
): string => {
return (

View file

@ -17,6 +17,8 @@
* along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
*/
import Urls from '../constants/Urls';
export const ERROR_TYPE = {
SUCCESS: 0,
BAD_CREDENTIALS: 1,
@ -40,8 +42,6 @@ type ApiResponseType<T> = {
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<T>(
if (params != null) {
requestParams = { ...params };
}
fetch(API_ENDPOINT + path, {
fetch(Urls.amicale.api + path, {
method,
headers: new Headers({
'Accept': 'application/json',