import { resetGuideStates } from '@/utils/devTools';
import React from 'react';
import { Alert, StyleSheet, Text, TouchableOpacity } from 'react-native';

interface GuideTestButtonProps {
  visible?: boolean;
}

export const GuideTestButton: React.FC<GuideTestButtonProps> = ({ visible = false }) => {
  if (!visible) return null;

  const handleResetGuides = async () => {
    Alert.alert(
      '重置用户引导',
      '确定要重置所有用户引导状态吗？这将清除用户已完成的引导记录。',
      [
        { text: '取消', style: 'cancel' },
        {
          text: '确定',
          style: 'destructive',
          onPress: async () => {
            await resetGuideStates();
            Alert.alert('成功', '用户引导状态已重置，下次进入页面时将重新显示引导。');
          },
        },
      ]
    );
  };

  return (
    <TouchableOpacity style={styles.button} onPress={handleResetGuides}>
      <Text style={styles.buttonText}>重置引导</Text>
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  button: {
    position: 'absolute',
    top: 50,
    right: 20,
    backgroundColor: '#FF6B6B',
    paddingHorizontal: 12,
    paddingVertical: 8,
    borderRadius: 8,
    zIndex: 1000,
  },
  buttonText: {
    color: '#FFFFFF',
    fontSize: 12,
    fontWeight: '600',
  },
});
