import { Ionicons } from "@expo/vector-icons";
import * as Clipboard from "expo-clipboard";
import { router, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import {
Alert,
Image,
Linking,
Pressable,
ScrollView,
Share,
View,
} from "react-native";
import { Button } from "@/components/ui/Button";
import { AppHeader } from "@/components/ui/Header";
import { Screen } from "@/components/ui/Screen";
import { Text } from "@/components/ui/Text";
import { buildPharmacistOrderShareText } from "@/lib/commerce";
import { routes } from "@/lib/routes";
import { useOrdersStore } from "@/lib/stores/ordersStore";
import { colors, fonts, gutter, radii, shadows } from "@/lib/theme";
import { formatETB, WHATSAPP_NUMBER } from "@/lib/utils";
/**
* Screenshot-friendly pharmacist order code card.
* Guests copy / share / screenshot this so staff can create the order in admin.
*/
export default function PharmacistOrderCodeScreen() {
const { id } = useLocalSearchParams<{ id: string }>();
const order = useOrdersStore((s) => s.getById(id));
const [copied, setCopied] = useState(false);
if (!order?.pickupCode) {
return (
No pharmacist order code found for this order.
);
}
const shareText = buildPharmacistOrderShareText(order);
const due = order.selfPay ?? order.total;
const copyCode = async () => {
await Clipboard.setStringAsync(order.pickupCode!);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
const copyFull = async () => {
await Clipboard.setStringAsync(shareText);
Alert.alert("Copied", "Order details copied — paste into chat or admin notes.");
};
const share = async () => {
try {
await Share.share({ message: shareText, title: `Gishen code ${order.pickupCode}` });
} catch {
// user dismissed
}
};
const whatsapp = () => {
Linking.openURL(
`https://wa.me/${WHATSAPP_NUMBER}?text=${encodeURIComponent(shareText)}`
);
};
return (
Share this code with a Gishen pharmacist. They enter it on the admin page
to create your order. Pay when you collect.
{/* Clean card — ideal for device screenshots */}
Gishen Pharmacy
Pharmacist order code
SHOW OR SHARE THIS CODE
{order.pickupCode}
Enter on admin → create order
{order.items.slice(0, 6).map((item) => (
· {item.name} ×{item.quantity}
))}
{order.items.length > 6 ? (
· +{order.items.length - 6} more
) : null}
Total due
{formatETB(due)}
Pay at branch when collecting
Tip: screenshot the card above to show in person or send as an image.
Copy full order details
);
}
function Row({ label, value }: { label: string; value: string }) {
return (
{label}
{value}
);
}