refactor: reorganize hooks and add safety checks
fix(api): add validation for listing and seller in bid route feat(telemetry): add userId to MarketTelemetry style(globe): add null check for canvas element chore: add lint:fix script to package.json
This commit is contained in:
1 parent
47c04de6fe
commit
6adc8d96e8
12 files changed
+119
-89
No files matched your search
@@ -40,18 +40,6 @@ export function AnalyticsDashboard() {
|
||||
const [analytics, setAnalytics] = useState<AdAnalytics | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.userId) {
|
||||
loadUserListings();
|
||||
}
|
||||
}, [user?.userId, loadUserListings]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedAd) {
|
||||
loadAnalytics(selectedAd);
|
||||
}
|
||||
}, [selectedAd, loadAnalytics]);
|
||||
|
||||
const loadUserListings = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -82,6 +70,18 @@ export function AnalyticsDashboard() {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.userId) {
|
||||
loadUserListings();
|
||||
}
|
||||
}, [user?.userId, loadUserListings]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedAd) {
|
||||
loadAnalytics(selectedAd);
|
||||
}
|
||||
}, [selectedAd, loadAnalytics]);
|
||||
|
||||
if (!user) {
|
||||
return (
|
||||
<div className="text-center py-12">
|
||||
|
||||
@@ -103,13 +103,6 @@ export function BidModal({
|
||||
}
|
||||
}, [minBid, bidAmount]);
|
||||
|
||||
// Buscar histórico de lances quando abrir modal
|
||||
useEffect(() => {
|
||||
if (open && listing) {
|
||||
fetchBidHistory();
|
||||
}
|
||||
}, [open, listing?.listing_id, fetchBidHistory, listing]);
|
||||
|
||||
const fetchBidHistory = async () => {
|
||||
if (!listing) return;
|
||||
|
||||
@@ -131,6 +124,13 @@ export function BidModal({
|
||||
}
|
||||
};
|
||||
|
||||
// Buscar histórico de lances quando abrir modal
|
||||
useEffect(() => {
|
||||
if (open && listing) {
|
||||
fetchBidHistory();
|
||||
}
|
||||
}, [open, listing?.listing_id, fetchBidHistory, listing]);
|
||||
|
||||
const handleBid = async () => {
|
||||
const amount = parseFloat(bidAmount);
|
||||
|
||||
|
||||
@@ -204,12 +204,6 @@ export function CreateAdModal({
|
||||
};
|
||||
|
||||
// Carregar servidores ao abrir o modal
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
loadServers();
|
||||
}
|
||||
}, [open, loadServers]);
|
||||
|
||||
const loadServers = async () => {
|
||||
setLoadingServers(true);
|
||||
try {
|
||||
@@ -225,6 +219,12 @@ export function CreateAdModal({
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
loadServers();
|
||||
}
|
||||
}, [open, loadServers]);
|
||||
|
||||
const handleClose = () => {
|
||||
if (!loading) {
|
||||
setSelectedItem(null);
|
||||
|
||||
@@ -135,10 +135,6 @@ export function MyAdsIntentionList({
|
||||
"all" | "pending" | "accepted" | "rejected"
|
||||
>("all");
|
||||
|
||||
useEffect(() => {
|
||||
loadIntentions();
|
||||
}, [loadIntentions]);
|
||||
|
||||
const loadIntentions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -162,6 +158,10 @@ export function MyAdsIntentionList({
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadIntentions();
|
||||
}, [loadIntentions]);
|
||||
|
||||
const pendingCount = intentions.filter((i) => i.status === "pending").length;
|
||||
|
||||
if (loading) {
|
||||
|
||||
Reference in new issue
Block a user