//@ts-nocheck
import React, { useEffect } from 'react';
import { observer, Observer } from 'mobx-react-lite';
import {
  Platform,
  SafeAreaView,
  ScrollView,
  TouchableOpacity,
  View,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { commonStyles } from '../CommonStyles';
import { MText } from '../../components/MText';
import {
  Back2Icon,
  IconBackWhite,
  NextIcon,
  StepIcon,
} from '../../assets/icons';
import MButton from '../../components/MButton';
import LinearGradient from 'react-native-linear-gradient';
import digitalLendingStore from './store';
import { Step1 } from './Step1';
import { Step2 } from './Step2';
import { Step3 } from './Step3';
import { Step4 } from './Step4';
import { Step5 } from './Step5';
import { Step6 } from './Step6';
import Loading from '../../components/Loading';
import MHeader from '../../components/MHeader';

export const DigitalLending = observer(function DigitalLending(props: any) {
  const navigation = useNavigation();
  const loan = props?.route?.params;

  useEffect(() => {
    digitalLendingStore.getDetailLoan(loan?.id);
    digitalLendingStore.getProvinces();
    digitalLendingStore.getJob();
    digitalLendingStore.getBrandProduct();
    digitalLendingStore.getBank();
  }, []);

  const renderView = (step: number) => {
    switch (step) {
      case 1:
        return <Step1 />;
      case 2:
        return <Step2 />;
      case 3:
        return <Step3 />;
      case 4:
        return <Step4 />;
      case 5:
        return <Step5 />;
      case 6:
        return <Step6 />;
      default:
        null;
    }
  };

  return (
    <View style={[commonStyles.fill, { zIndex: 1, backgroundColor: 'white' }]}>
      <MHeader
        title="Thông tin cá nhân"
        onBack={() => {
          navigation.pop();
          digitalLendingStore.clear();
          digitalLendingStore.data = {};
        }}
      />
      <SafeAreaView
        style={{
          flex: 1,
        }}
      >
        <Observer>{() => renderView(digitalLendingStore.step)}</Observer>
      </SafeAreaView>
    </View>
  );
});
