import React from 'react';
import { View, Text } from 'react-native';
import { useAppTheme } from '@theme';
import { PrimaryButton } from '@components';
import { useAppDispatch, useAppSelector } from '@store';
import { advanceJobStatus } from '@store/slices/jobSlice';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { AppStackParamList } from '@navigation/navigationTypes';
import { RouteNames, JobStatus } from '@utils/constants';
import { getStyles } from './orderAcceptedScreen.styles';

export const OrderAcceptedScreen: React.FC = () => {
  const { colors } = useAppTheme();
  const styles = getStyles(colors);
  const dispatch = useAppDispatch();
  const navigation = useNavigation<NativeStackNavigationProp<AppStackParamList>>();

  const activeJob = useAppSelector((state) => state.job.activeJob);

  const handleNavigate = () => {
    dispatch(advanceJobStatus(JobStatus.ArrivedAtStore));
    navigation.navigate(RouteNames.ArrivedAtStore);
  };

  if (!activeJob) return null;

  return (
    <View style={styles.container}>
      {/* Top Banner Alert */}
      <View style={styles.headerBanner}>
        <Text style={styles.headerText}>Order Accepted • Go to pickup location</Text>
      </View>

      {/* Blank Map Placeholder Background */}
      <View style={styles.mapPlaceholder}>
        <Text style={styles.placeholderText}>[ Map Placeholder ]</Text>
      </View>

      {/* Merchant Bottom Card */}
      <View style={styles.bottomCard}>
        <Text style={styles.cardTitle}>Pickup Merchant</Text>
        <Text style={styles.storeName}>{activeJob.pickupName}</Text>
        <Text style={styles.storeAddress}>{activeJob.pickupAddress}</Text>

        <PrimaryButton
          title="Navigate"
          onPress={handleNavigate}
          style={styles.navigateButton}
        />
      </View>
    </View>
  );
};

export default OrderAcceptedScreen;
