import React from "react";
import { View, Text, StyleSheet, Pressable } from "react-native";
import ChevronRight from "../../assets/icons/chevron_rightside.svg";

type Props = {
  title: string;
  firstText: string;
  secondText?: string;
  percentage: number;
  onPress?: () => void;
};

const ProgressCard: React.FC<Props> = ({
  title,
  firstText,
  secondText = "",
  percentage,
  onPress,
}) => {
  return (
    <View style={styles.card}>
      <View style={styles.topRow}>
        <View style={styles.textColumn}>
          <Text style={styles.title}>{title}</Text>
          <Text style={styles.time}>
            {firstText}
            {secondText ? ` / ${secondText}` : ""}
          </Text>
        </View>
        {onPress && (
          <Pressable style={styles.iconButton} onPress={onPress}>
            <ChevronRight />
          </Pressable>
        )}
      </View>
      <View style={styles.progressContainer}>
        <View style={styles.progressBar}>
          <View style={[styles.progressFill, { width: `${percentage}%` }]} />
        </View>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  card: {
    backgroundColor: "#FCFCFC",
    borderRadius: 10,
    padding: 16,
    width: "100%",
    height: 96,
    justifyContent: "space-between",
  },
  topRow: {
    flexDirection: "row",
    justifyContent: "space-between",
    alignItems: "flex-start",
  },
  textColumn: {
    flexDirection: "column",
    gap: 4,
  },
  title: {
    fontSize: 12,
    fontFamily: "Inter-Medium",
    color: "#565E70",
    lineHeight: 16,
  },
  time: {
    fontSize: 14,
    fontFamily: "Inter-SemiBold",
    color: "#252A34",
    lineHeight: 20,
  },
  iconButton: {
    width: 40,
    height: 40,
    padding: 10,
    justifyContent: "center",
    alignItems: "center",
  },
  progressContainer: {
    marginTop: 8,
    width: "100%",
    height: 8,
  },
  progressBar: {
    width: "100%",
    height: 8,
    backgroundColor: "#E5E9F0",
    borderRadius: 10,
    overflow: "hidden",
  },
  progressFill: {
    height: "100%",
    backgroundColor: "#027A48",
    borderRadius: 10,
  },
});

export default ProgressCard;
