mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 06:51:13 -05:00
Remove real-time updates
This commit is contained in:
@@ -40,57 +40,6 @@ export default function OperatorDetail() {
|
|||||||
}
|
}
|
||||||
}, [slug]);
|
}, [slug]);
|
||||||
|
|
||||||
// Real-time subscription for parks, rides, and photos changes
|
|
||||||
useEffect(() => {
|
|
||||||
if (!operator?.id) return;
|
|
||||||
|
|
||||||
const channel = supabase
|
|
||||||
.channel('operator-stats-changes')
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: '*',
|
|
||||||
schema: 'public',
|
|
||||||
table: 'parks',
|
|
||||||
filter: `operator_id=eq.${operator.id}`
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
console.log('Park change detected for operator:', payload);
|
|
||||||
fetchStatistics(operator.id);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: 'UPDATE',
|
|
||||||
schema: 'public',
|
|
||||||
table: 'rides'
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
console.log('Ride status change detected:', payload);
|
|
||||||
fetchStatistics(operator.id);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: '*',
|
|
||||||
schema: 'public',
|
|
||||||
table: 'photos',
|
|
||||||
filter: `entity_type=eq.operator,entity_id=eq.${operator.id}`
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
console.log('Photo change detected for operator:', payload);
|
|
||||||
fetchPhotoCount(operator.id);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
supabase.removeChannel(channel);
|
|
||||||
};
|
|
||||||
}, [operator?.id]);
|
|
||||||
|
|
||||||
const fetchOperatorData = async () => {
|
const fetchOperatorData = async () => {
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
|
|||||||
@@ -40,57 +40,6 @@ export default function PropertyOwnerDetail() {
|
|||||||
}
|
}
|
||||||
}, [slug]);
|
}, [slug]);
|
||||||
|
|
||||||
// Real-time subscription for parks and photos changes
|
|
||||||
useEffect(() => {
|
|
||||||
if (!owner?.id) return;
|
|
||||||
|
|
||||||
const channel = supabase
|
|
||||||
.channel('owner-stats-changes')
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: '*',
|
|
||||||
schema: 'public',
|
|
||||||
table: 'parks',
|
|
||||||
filter: `property_owner_id=eq.${owner.id}`
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
console.log('Park change detected for owner:', payload);
|
|
||||||
fetchStatistics(owner.id);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: 'UPDATE',
|
|
||||||
schema: 'public',
|
|
||||||
table: 'rides'
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
console.log('Ride status change detected:', payload);
|
|
||||||
fetchStatistics(owner.id);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.on(
|
|
||||||
'postgres_changes',
|
|
||||||
{
|
|
||||||
event: '*',
|
|
||||||
schema: 'public',
|
|
||||||
table: 'photos',
|
|
||||||
filter: `entity_type=eq.property_owner,entity_id=eq.${owner.id}`
|
|
||||||
},
|
|
||||||
(payload) => {
|
|
||||||
console.log('Photo change detected for owner:', payload);
|
|
||||||
fetchPhotoCount(owner.id);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
supabase.removeChannel(channel);
|
|
||||||
};
|
|
||||||
}, [owner?.id]);
|
|
||||||
|
|
||||||
const fetchOwnerData = async () => {
|
const fetchOwnerData = async () => {
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
|
|||||||
Reference in New Issue
Block a user