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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. Button,
  22. Caption,
  23. Card,
  24. Headline,
  25. Paragraph,
  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. return (
  60. <CollapsibleScrollView>
  61. <Card style={{margin: 5}}>
  62. <Card.Content>
  63. <View style={{flex: 1}}>
  64. <View
  65. style={{
  66. marginLeft: 'auto',
  67. marginRight: 'auto',
  68. flexDirection: 'row',
  69. flexWrap: 'wrap',
  70. }}>
  71. <Headline style={{textAlign: 'center'}}>{item.name}</Headline>
  72. <Caption
  73. style={{
  74. textAlign: 'center',
  75. lineHeight: 35,
  76. marginLeft: 10,
  77. }}>
  78. ({i18n.t('screens.equipment.bail', {cost: item.caution})})
  79. </Caption>
  80. </View>
  81. </View>
  82. <Button
  83. icon="check-circle-outline"
  84. color={theme.colors.success}
  85. mode="text">
  86. {buttonText}
  87. </Button>
  88. <Paragraph style={{textAlign: 'center'}}>
  89. {i18n.t('screens.equipment.bookingConfirmedMessage')}
  90. </Paragraph>
  91. </Card.Content>
  92. </Card>
  93. </CollapsibleScrollView>
  94. );
  95. }
  96. return null;
  97. }
  98. export default EquipmentConfirmScreen;