Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { useState, useCallback, useEffect } from 'react';
- import { ScrollView, Text, Alert } from 'react-native';
- import PropTypes from 'prop-types';
- import HTML from 'react-native-render-html';
- import api from '~/services/api';
- import CheckBox from './CheckBox';
- import Header from '~/components/Header';
- import {
- Container,
- PaymentStatus,
- Title,
- StyledButton,
- SubmitButton,
- PaymentText,
- Library,
- Option,
- OptionTitle,
- LibraryTitle,
- Document,
- CloseButton,
- ButtonText,
- } from './styles';
- import DocLibrary from '~/components/DocLibrary';
- export default function SendOrder({ navigation }) {
- const [agreeTerms, setAgreeTerms] = useState(false);
- const [recomendationData, setRecomendationData] = useState([]);
- const [userInvestmentThesis, setUserInvestmentThesis] = useState('');
- const [fileToken, setFileToken] = useState('');
- const [showModal, setShowModal] = useState(false);
- const [showDoc, setShowDoc] = useState(false);
- const [document, setDocument] = useState([]);
- const [requestDone, setRequestDone] = useState(0);
- const [loading, setLoading] = useState(false);
- const htmlContent = document;
- const getRecomendationRequest = useCallback(async () => {
- const {
- data: { data },
- } = await api.get('robotadvisory/recomendation/get', {});
- setRecomendationData(data);
- setUserInvestmentThesis(data.file_token);
- }, []);
- const setRecomendantionRequest = useCallback(async () => {
- // navigation.navigate('LaunchpadConfig');
- // await api.post('robotadvisory/informedconsent', {
- // recomendation_token: recomendationData.token,
- // });
- // console.log('tk', recomendationData.token);
- navigation.navigate('LaunchpadConfig');
- }, [navigation, recomendationData]);
- const getDocument = useCallback(async () => {
- try {
- setLoading(true);
- const { data } = await api.post('accounts/files/documents', {
- token: fileToken,
- });
- setDocument(data);
- setLoading(false);
- } catch (error) {
- setLoading(false);
- if (error != null && error.response != null) {
- Alert.alert('Token expirado', 'É necessário fazer login novamente');
- setShowDoc(false);
- // navigation.navigate('Login');
- } else {
- Alert.alert('Ocorreu um erro, por favor tente novamente mais tarde!');
- }
- }
- }, [fileToken]);
- useEffect(() => {
- if (requestDone < 1) {
- getRecomendationRequest();
- setRequestDone(requestDone + 1);
- }
- }, [getRecomendationRequest, recomendationData, requestDone]);
- return (
- <>
- <Header navigation={navigation} />
- <PaymentStatus>
- <PaymentText>PAGAMENTO EFETUADO COM SUCESSO</PaymentText>
- </PaymentStatus>
- <Container>
- <Title>Tese de Investimento</Title>
- <StyledButton
- doc
- onPress={() => {
- setFileToken(userInvestmentThesis);
- setShowModal(true);
- }}
- >
- Abrir Documentos
- </StyledButton>
- <DocLibrary />
- {/* <Library isVisible={showModal} animationOutTiming={400}>
- <CloseButton lib onPress={() => setShowModal(false)}>
- <ButtonText lib>X</ButtonText>
- </CloseButton>
- <LibraryTitle>Biblioteca de Documentos</LibraryTitle>
- <Option
- onPress={() => {
- setShowDoc(true);
- setShowModal(false);
- getDocument();
- }}
- >
- <OptionTitle
- onPress={() => {
- setShowDoc(true);
- setShowModal(false);
- getDocument();
- }}
- >
- Teses de investimento
- </OptionTitle>
- </Option>
- </Library>
- <Document
- isVisible={showDoc}
- backdropTransitionInTiming={500}
- animationInTiming={200}
- >
- <CloseButton onPress={() => setShowDoc(false)}>
- <ButtonText>X</ButtonText>
- </CloseButton>
- <ScrollView>
- <HTML html={htmlContent} />
- </ScrollView>
- </Document> */}
- <CheckBox
- checked={agreeTerms}
- onPress={() => setAgreeTerms(!agreeTerms)}
- text="Concordo com a Tese de Investimento proposta"
- />
- <SubmitButton
- disable={!agreeTerms}
- onPress={() => setRecomendantionRequest()}
- >
- Submeter
- </SubmitButton>
- </Container>
- </>
- );
- }
- SendOrder.propTypes = {
- navigation: PropTypes.oneOfType([PropTypes.object]).isRequired,
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement