mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 14:51:13 -05:00
Fix all compliance violations
This commit is contained in:
@@ -201,17 +201,36 @@ export function ImageDiff({ change, compact = false }: ImageDiffProps) {
|
||||
);
|
||||
}
|
||||
|
||||
interface LocationData {
|
||||
location_id?: string;
|
||||
city?: string;
|
||||
state_province?: string;
|
||||
country?: string;
|
||||
postal_code?: string;
|
||||
latitude?: number | string;
|
||||
longitude?: number | string;
|
||||
}
|
||||
|
||||
interface LocationDiffProps {
|
||||
oldLocation: any;
|
||||
newLocation: any;
|
||||
oldLocation: LocationData | string | null | undefined;
|
||||
newLocation: LocationData | string | null | undefined;
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export function LocationDiff({ oldLocation, newLocation, compact = false }: LocationDiffProps) {
|
||||
// Type guards for LocationData
|
||||
const isLocationData = (loc: unknown): loc is LocationData => {
|
||||
return typeof loc === 'object' && loc !== null && !Array.isArray(loc);
|
||||
};
|
||||
|
||||
// Check if we're creating a new location entity
|
||||
const isCreatingNewLocation = oldLocation?.location_id && !oldLocation?.city && newLocation?.city;
|
||||
const isCreatingNewLocation = isLocationData(oldLocation) &&
|
||||
oldLocation.location_id &&
|
||||
!oldLocation.city &&
|
||||
isLocationData(newLocation) &&
|
||||
newLocation.city;
|
||||
|
||||
const formatLocation = (loc: any) => {
|
||||
const formatLocation = (loc: LocationData | string | null | undefined) => {
|
||||
if (!loc) return 'None';
|
||||
if (typeof loc === 'string') return loc;
|
||||
|
||||
@@ -242,12 +261,14 @@ export function LocationDiff({ oldLocation, newLocation, compact = false }: Loca
|
||||
};
|
||||
|
||||
// Check if only coordinates changed
|
||||
const onlyCoordinatesChanged = oldLocation?.city === newLocation?.city &&
|
||||
oldLocation?.state_province === newLocation?.state_province &&
|
||||
oldLocation?.country === newLocation?.country &&
|
||||
oldLocation?.postal_code === newLocation?.postal_code &&
|
||||
(Number(oldLocation?.latitude) !== Number(newLocation?.latitude) ||
|
||||
Number(oldLocation?.longitude) !== Number(newLocation?.longitude));
|
||||
const onlyCoordinatesChanged = isLocationData(oldLocation) &&
|
||||
isLocationData(newLocation) &&
|
||||
oldLocation.city === newLocation.city &&
|
||||
oldLocation.state_province === newLocation.state_province &&
|
||||
oldLocation.country === newLocation.country &&
|
||||
oldLocation.postal_code === newLocation.postal_code &&
|
||||
(Number(oldLocation.latitude) !== Number(newLocation.latitude) ||
|
||||
Number(oldLocation.longitude) !== Number(newLocation.longitude));
|
||||
|
||||
if (compact) {
|
||||
const oldLoc = formatLocation(oldLocation);
|
||||
|
||||
Reference in New Issue
Block a user