import React from 'react';
import { View, ScrollView } from 'react-native';
import { AppContainer, MyText, tw, MyTouchableOpacity } from 'common-ui';
import { trpc } from '@/src/trpc-client';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
import dayjs from "dayjs";
import { useRouter, useLocalSearchParams } from 'expo-router';
import { LinearGradient } from 'expo-linear-gradient';
export default function SlotDetails() {
const router = useRouter();
const { slotId } = useLocalSearchParams();
const { data: slotData, isLoading, error } = trpc.admin.slots.getSlotById.useQuery({
id: parseInt(slotId as string),
});
const slot = slotData?.slot;
const products = slot?.products || [];
if (isLoading) {
return (
Loading slot details...
);
}
if (error || !slot) {
return (
Error loading slot details
);
}
return (
{/* Header */}
Slot #{slot.id}
Delivery: {dayjs(slot.deliveryTime).format('MMM DD, YYYY hh:mm A')}
Freeze: {dayjs(slot.freezeTime).format('MMM DD, YYYY hh:mm A')}
{slot.isActive ? 'Active' : 'Inactive'}
{/* Products Section */}
Products
{products.length} items
{products.length === 0 ? (
No products in this slot
) : (
{products.map((product) => (
{product.name}
))}
)}
{/* FAB for Edit Slot */}
router.push(`/(drawer)/dashboard/slots/edit/${slot.id}` as any)}
activeOpacity={0.95}
style={{ position: 'absolute', bottom: 32, right: 24, zIndex: 100 }}
>
);
}