Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EquipmentConfirmScreen.tsx 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import * as React from 'react';
  20. import {
  21. Caption,
  22. Card,
  23. Headline,
  24. Paragraph,
  25. Title,
  26. useTheme,
  27. } from 'react-native-paper';
  28. import {View} from 'react-native';
  29. import i18n from 'i18n-js';
  30. import {getRelativeDateString} from '../../../utils/EquipmentBooking';
  31. import CollapsibleScrollView from '../../../components/Collapsible/CollapsibleScrollView';
  32. import {StackScreenProps} from '@react-navigation/stack';
  33. import {MainStackParamsList} from '../../../navigation/MainNavigator';
  34. type EquipmentConfirmScreenNavigationProp = StackScreenProps<
  35. MainStackParamsList,
  36. 'equipment-confirm'
  37. >;
  38. type Props = EquipmentConfirmScreenNavigationProp;
  39. function EquipmentConfirmScreen(props: Props) {
  40. const theme = useTheme();
  41. const item = props.route.params?.item;
  42. const dates = props.route.params?.dates;
  43. if (item != null && dates != null) {
  44. const start = new Date(dates[0]);
  45. const end = new Date(dates[1]);
  46. let buttonText;
  47. if (start == null) {
  48. buttonText = i18n.t('screens.equipment.booking');
  49. } else if (end != null && start.getTime() !== end.getTime()) {
  50. buttonText = i18n.t('screens.equipment.bookingPeriod', {
  51. begin: getRelativeDateString(start),
  52. end: getRelativeDateString(end),
  53. });
  54. } else {
  55. buttonText = i18n.t('screens.equipment.bookingDay', {
  56. date: getRelativeDateString(start),
  57. });
  58. }
  59. console.log(buttonText);
  60. return (
  61. <CollapsibleScrollView>
  62. <Card style={{margin: 5}}>
  63. <Card.Content>
  64. <View style={{flex: 1}}>
  65. <View
  66. style={{
  67. marginLeft: 'auto',
  68. marginRight: 'auto',
  69. flexDirection: 'row',
  70. flexWrap: 'wrap',
  71. }}>
  72. <Headline style={{textAlign: 'center'}}>{item.name}</Headline>
  73. <Caption
  74. style={{
  75. textAlign: 'center',
  76. lineHeight: 35,
  77. marginLeft: 10,
  78. }}>
  79. ({i18n.t('screens.equipment.bail', {cost: item.caution})})
  80. </Caption>
  81. </View>
  82. </View>
  83. <Title style={{color: theme.colors.success, textAlign: 'center'}}>
  84. {buttonText}
  85. </Title>
  86. <Paragraph style={{textAlign: 'center'}}>
  87. {i18n.t('screens.equipment.bookingConfirmedMessage')}
  88. </Paragraph>
  89. </Card.Content>
  90. </Card>
  91. </CollapsibleScrollView>
  92. );
  93. }
  94. return null;
  95. }
  96. export default EquipmentConfirmScreen;