Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bacalj committed Aug 19, 2024
1 parent b8fefac commit a2159f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
11 changes: 3 additions & 8 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useRef, useCallback } from "react";
import { clsx } from "clsx";
import { ILocation } from "../types";
import { ICurrentDayLocation, ILocation } from "../types";
import { debounce } from "../grasp-seasons/utils/utils";
import { kInitialDimensions, kVersion, kPluginName, kDefaultOnAttributes, kSimulationTabDimensions, kDataContextName, kChildCollectionName } from "../constants";
import { initializePlugin, codapInterface, selectSelf, addDataContextChangeListener, ClientNotification, getCaseByID } from "@concord-consortium/codap-plugin-api";
Expand All @@ -11,12 +11,6 @@ import { Header } from "./header";

import "../assets/scss/App.scss";

interface CurrentDayLocation {
_latitude: string;
_longitude: string;
_dayOfYear: number;
}

const debouncedUpdateRowSelectionInCodap = debounce((
latitude: string,
longitude: string,
Expand Down Expand Up @@ -55,7 +49,7 @@ export const App: React.FC = () => {
const [selectedAttrs, setSelectedAttributes] = useState<string[]>(kDefaultOnAttributes);
const [dataContext, setDataContext] = useState<any>(null);

const currentDayLocationRef = useRef<CurrentDayLocation>({
const currentDayLocationRef = useRef<ICurrentDayLocation>({
_latitude: "",
_longitude: "",
_dayOfYear: 171
Expand Down Expand Up @@ -154,6 +148,7 @@ export const App: React.FC = () => {
dimensions: tab === "location" ? kInitialDimensions : kSimulationTabDimensions
}
}).then(() => {
// This brings the plugin window to the front within CODAP
selectSelf();
}).catch((error) => {
console.error("Error updating dimensions or selecting self:", error);
Expand Down
9 changes: 6 additions & 3 deletions src/components/location-tab.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from "react";
import { useCodapData } from "../hooks/useCodapData";
import { kChildCollectionAttributes } from "../constants";
import { ILocation } from "../types";
import { ICodapDataContextInfo, ILocation } from "../types";
import { LocationPicker } from "./location-picker";
import { locationsEqual } from "../utils/daylight-utils";

Expand All @@ -13,12 +13,12 @@ interface LocationTabProps {
locations: ILocation[];
locationSearch: string;
selectedAttrs: string[];
dataContext: any; // TODO this is not being used, maybe we'll need it for querying?
dataContext: ICodapDataContextInfo | null;
setLatitude: (latitude: string) => void;
setLongitude: (longitude: string) => void;
setLocationSearch: (search: string) => void;
setSelectedAttributes: (attrs: string[]) => void;
setDataContext: (context: any) => void; // TODO this is not being used
setDataContext: (context: any) => void;
setLocations: (locations: ILocation[]) => void;
}

Expand All @@ -35,6 +35,7 @@ export const LocationTab: React.FC<LocationTabProps> = ({
setLocations
}) => {


const {
dataContext,
handleClearData,
Expand All @@ -43,6 +44,8 @@ export const LocationTab: React.FC<LocationTabProps> = ({
getUniqueLocationsInCodapData
} = useCodapData();

console.log("| what is dataContext anyway?", typeof dataContext, {dataContext});

Check warning on line 47 in src/components/location-tab.tsx

View workflow job for this annotation

GitHub Actions / Build and Run Jest Tests

Unexpected console statement

Check warning on line 47 in src/components/location-tab.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

Unexpected console statement

useEffect(() => {
const updateEachAttrVisibility = () => {
for (const attr of kChildCollectionAttributes) {
Expand Down
11 changes: 11 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export interface ICodapDataContextInfo {
id: number;
name: string;
title: string;
}

export interface ICurrentDayLocation {
_latitude: string;
_longitude: string;
_dayOfYear: number;
}

export interface ILocation {
name: string;
Expand Down

0 comments on commit a2159f6

Please sign in to comment.