import ImageLoader from "@/components/ui/ImageLoader";
import { isImage } from "@/utils/helper";
import React from "react";
import { Pressable, Text } from "react-native";

const FilePreview = ({ item, index }: { item: string; index: number }) => {
  return isImage(item) ? (
    <Pressable
      key={index}
      onPress={() => {}}
      className="border border-slate-200"
    >
      <ImageLoader
        src={item}
        alt={`attachment-${index}`}
        width={80}
        height={80}
      />
    </Pressable>
  ) : (
    <Pressable
      key={index}
      onPress={() => {}}
      className=" gap-3 rounded-md border bg-slate-50 p-3 transition  border-slate-200"
    >
      <Text className="truncate text-sm text-slate-700">
        {item.split("/").pop()}
      </Text>
    </Pressable>
  );
};

export default FilePreview;
