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.

VoteWait.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. // @flow
  20. import * as React from 'react';
  21. import {Avatar, Card, Paragraph, withTheme} from 'react-native-paper';
  22. import {StyleSheet} from 'react-native';
  23. import i18n from 'i18n-js';
  24. import type {CustomThemeType} from '../../../managers/ThemeManager';
  25. import type {CardTitleIconPropsType} from '../../../constants/PaperStyles';
  26. type PropsType = {
  27. startDate: string | null,
  28. justVoted: boolean,
  29. hasVoted: boolean,
  30. isVoteRunning: boolean,
  31. theme: CustomThemeType,
  32. };
  33. const styles = StyleSheet.create({
  34. card: {
  35. margin: 10,
  36. },
  37. icon: {
  38. backgroundColor: 'transparent',
  39. },
  40. });
  41. class VoteWait extends React.Component<PropsType> {
  42. shouldComponentUpdate(): boolean {
  43. return false;
  44. }
  45. render(): React.Node {
  46. const {props} = this;
  47. const {startDate} = props;
  48. return (
  49. <Card style={styles.card}>
  50. <Card.Title
  51. title={
  52. props.isVoteRunning
  53. ? i18n.t('screens.vote.wait.titleSubmitted')
  54. : i18n.t('screens.vote.wait.titleEnded')
  55. }
  56. subtitle={i18n.t('screens.vote.wait.subtitle')}
  57. left={(iconProps: CardTitleIconPropsType): React.Node => (
  58. <Avatar.Icon size={iconProps.size} icon="progress-check" />
  59. )}
  60. />
  61. <Card.Content>
  62. {props.justVoted ? (
  63. <Paragraph style={{color: props.theme.colors.success}}>
  64. {i18n.t('screens.vote.wait.messageSubmitted')}
  65. </Paragraph>
  66. ) : null}
  67. {props.hasVoted ? (
  68. <Paragraph style={{color: props.theme.colors.success}}>
  69. {i18n.t('screens.vote.wait.messageVoted')}
  70. </Paragraph>
  71. ) : null}
  72. {startDate != null ? (
  73. <Paragraph>
  74. {`${i18n.t('screens.vote.wait.messageDate')} ${startDate}`}
  75. </Paragraph>
  76. ) : (
  77. <Paragraph>
  78. {i18n.t('screens.vote.wait.messageDateUndefined')}
  79. </Paragraph>
  80. )}
  81. </Card.Content>
  82. </Card>
  83. );
  84. }
  85. }
  86. export default withTheme(VoteWait);