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.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // @flow
  2. import * as React from 'react';
  3. import {Button, Caption, Card, Headline, Paragraph, withTheme} from 'react-native-paper';
  4. import {StackNavigationProp} from "@react-navigation/stack";
  5. import type {CustomTheme} from "../../../managers/ThemeManager";
  6. import type {Device} from "./EquipmentListScreen";
  7. import {View} from "react-native";
  8. import i18n from "i18n-js";
  9. import {getRelativeDateString} from "../../../utils/EquipmentBooking";
  10. import CollapsibleScrollView from "../../../components/Collapsible/CollapsibleScrollView";
  11. type Props = {
  12. navigation: StackNavigationProp,
  13. route: {
  14. params?: {
  15. item?: Device,
  16. dates: [string, string]
  17. },
  18. },
  19. theme: CustomTheme,
  20. }
  21. class EquipmentConfirmScreen extends React.Component<Props> {
  22. item: Device | null;
  23. dates: [string, string] | null;
  24. constructor(props: Props) {
  25. super(props);
  26. if (this.props.route.params != null) {
  27. if (this.props.route.params.item != null)
  28. this.item = this.props.route.params.item;
  29. else
  30. this.item = null;
  31. if (this.props.route.params.dates != null)
  32. this.dates = this.props.route.params.dates;
  33. else
  34. this.dates = null;
  35. }
  36. }
  37. render() {
  38. const item = this.item;
  39. const dates = this.dates;
  40. if (item != null && dates != null) {
  41. const start = new Date(dates[0]);
  42. const end = new Date(dates[1]);
  43. return (
  44. <CollapsibleScrollView>
  45. <Card style={{margin: 5}}>
  46. <Card.Content>
  47. <View style={{flex: 1}}>
  48. <View style={{
  49. marginLeft: "auto",
  50. marginRight: "auto",
  51. flexDirection: "row",
  52. flexWrap: "wrap",
  53. }}>
  54. <Headline style={{textAlign: "center"}}>
  55. {item.name}
  56. </Headline>
  57. <Caption style={{
  58. textAlign: "center",
  59. lineHeight: 35,
  60. marginLeft: 10,
  61. }}>
  62. ({i18n.t('screens.equipment.bail', {cost: item.caution})})
  63. </Caption>
  64. </View>
  65. </View>
  66. <Button
  67. icon={"check-circle-outline"}
  68. color={this.props.theme.colors.success}
  69. mode="text"
  70. >
  71. {
  72. start == null
  73. ? i18n.t('screens.equipment.booking')
  74. : end != null && start.getTime() !== end.getTime()
  75. ? i18n.t('screens.equipment.bookingPeriod', {
  76. begin: getRelativeDateString(start),
  77. end: getRelativeDateString(end)
  78. })
  79. : i18n.t('screens.equipment.bookingDay', {
  80. date: getRelativeDateString(start)
  81. })
  82. }
  83. </Button>
  84. <Paragraph style={{textAlign: "center"}}>
  85. {i18n.t("screens.equipment.bookingConfirmedMessage")}
  86. </Paragraph>
  87. </Card.Content>
  88. </Card>
  89. </CollapsibleScrollView>
  90. );
  91. } else
  92. return null;
  93. }
  94. }
  95. export default withTheme(EquipmentConfirmScreen);