lots of stuff
This commit is contained in:
parent
f946fbf7b8
commit
4be45f8f7c
9 changed files with 513 additions and 236 deletions
|
|
@ -24,7 +24,7 @@ type ExchangeResponse = components["schemas"]["ExchangeResponse"];
|
|||
export default function TradeDetailPage() {
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
const tradeId = params?.id ? parseInt(params.id as string, 10) : null;
|
||||
const publicId = params?.id as string | undefined;
|
||||
|
||||
const { user, isLoading, isAuthorized } = useRequireAuth({
|
||||
requiredPermission: Permission.VIEW_OWN_EXCHANGES,
|
||||
|
|
@ -36,13 +36,13 @@ export default function TradeDetailPage() {
|
|||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!user || !isAuthorized || !tradeId) return;
|
||||
if (!user || !isAuthorized || !publicId) return;
|
||||
|
||||
const fetchTrade = async () => {
|
||||
try {
|
||||
setIsLoadingTrade(true);
|
||||
setError(null);
|
||||
const data = await api.get<ExchangeResponse>(`/api/trades/${tradeId}`);
|
||||
const data = await api.get<ExchangeResponse>(`/api/trades/${publicId}`);
|
||||
setTrade(data);
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch trade:", err);
|
||||
|
|
@ -55,7 +55,7 @@ export default function TradeDetailPage() {
|
|||
};
|
||||
|
||||
fetchTrade();
|
||||
}, [user, isAuthorized, tradeId]);
|
||||
}, [user, isAuthorized, publicId]);
|
||||
|
||||
if (isLoading || isLoadingTrade) {
|
||||
return (
|
||||
|
|
@ -221,7 +221,7 @@ export default function TradeDetailPage() {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
await api.post(`/api/trades/${trade.id}/cancel`, {});
|
||||
await api.post(`/api/trades/${trade.public_id}/cancel`, {});
|
||||
router.push("/trades");
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Failed to cancel trade");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue