Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add parcel list modal #398

Merged
merged 9 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import * as turf from "@turf/turf";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import type { InvocationConfig } from "@web3-storage/upload-client";
import ParcelList from "./parcels/ParcelList";

export const ZOOM_GRID_LEVEL = 17;
const GRID_DIM_LAT = 140;
Expand Down Expand Up @@ -170,14 +171,14 @@ export type MapProps = {
paymentToken: NativeAssetSuperToken;
sfFramework: Framework;
setPortfolioNeedActionCount: React.Dispatch<React.SetStateAction<number>>;
portfolioParcelCenter: Point | null;
setPortfolioParcelCenter: React.Dispatch<React.SetStateAction<Point | null>>;
isPortfolioToUpdate: boolean;
parcelNavigationCenter: Point | null;
setParcelNavigationCenter: React.Dispatch<React.SetStateAction<Point | null>>;
shouldRefetchParcelsData: boolean;
auctionStart: BigNumber;
auctionEnd: BigNumber;
startingBid: BigNumber;
endingBid: BigNumber;
setIsPortfolioToUpdate: React.Dispatch<React.SetStateAction<boolean>>;
setShouldRefetchParcelsData: React.Dispatch<React.SetStateAction<boolean>>;
};

const MAP_STYLE_KEY = "storedMapStyleName";
Expand All @@ -199,7 +200,7 @@ function Map(props: MapProps) {
setSelectedParcelId,
interactionState,
setInteractionState,
portfolioParcelCenter,
parcelNavigationCenter,
} = props;
const { data, fetchMore, refetch } = useQuery<PolygonQuery>(query, {
variables: {
Expand Down Expand Up @@ -260,11 +261,12 @@ function Map(props: MapProps) {
const [interactiveLayerIds, setInteractiveLayerIds] = React.useState<
string[]
>([]);
const [invalidLicenseId, setInvalidLicenseId] = useState("");
const [invalidLicenseId, setInvalidLicenseId] = React.useState("");
const [newParcel, setNewParcel] = React.useState<{
id: string;
timerId: number | null;
}>({ id: "", timerId: null });
const [showParcelList, setShowParcelList] = React.useState<boolean>(false);

const router = useRouter();

Expand Down Expand Up @@ -751,10 +753,10 @@ function Map(props: MapProps) {
}, [data]);

useEffect(() => {
if (portfolioParcelCenter) {
if (parcelNavigationCenter) {
flyToLocation({
longitude: portfolioParcelCenter.coordinates[0],
latitude: portfolioParcelCenter.coordinates[1],
longitude: parcelNavigationCenter.coordinates[0],
latitude: parcelNavigationCenter.coordinates[1],
zoom: ZOOM_GRID_LEVEL,
duration: 500,
padding: {
Expand All @@ -764,11 +766,11 @@ function Map(props: MapProps) {
});

setSelectedParcelCoords({
x: portfolioParcelCenter.coordinates[0],
y: portfolioParcelCenter.coordinates[1],
x: parcelNavigationCenter.coordinates[0],
y: parcelNavigationCenter.coordinates[1],
});
}
}, [portfolioParcelCenter]);
}, [parcelNavigationCenter]);

return (
<>
Expand Down Expand Up @@ -915,6 +917,18 @@ function Map(props: MapProps) {
<Image src={"satellite_ic.png"} width={30} />
</Button>
</ButtonGroup>
<Button
variant="primary"
className="p-0 border-0 parcel-list-btn"
onClick={() => setShowParcelList(true)}
>
<Image src="list.svg" alt="parcel list" width={38} />
</Button>
<ParcelList
showParcelList={showParcelList}
handleCloseModal={() => setShowParcelList(false)}
{...props}
/>
</>
);
}
Expand Down
4 changes: 2 additions & 2 deletions components/cards/ActionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function ActionForm(props: ActionFormProps) {
requiredPayment,
spender,
hasOutstandingBid = false,
setIsPortfolioToUpdate,
setShouldRefetchParcelsData,
minForSalePrice,
paymentToken,
setShouldParcelContentUpdate,
Expand Down Expand Up @@ -277,7 +277,7 @@ export function ActionForm(props: ActionFormProps) {
}

setInteractionState(STATE.PARCEL_SELECTED);
setIsPortfolioToUpdate(true);
setShouldRefetchParcelsData(true);
}

const isInvalid = isForSalePriceInvalid || !displayNewForSalePrice;
Expand Down
6 changes: 3 additions & 3 deletions components/cards/OutstandingBidView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function OutstandingBidView(props: OutstandingBidViewProps) {
perSecondFeeDenominator,
setInteractionState,
setSelectedParcelId,
setIsPortfolioToUpdate,
setShouldRefetchParcelsData,
setParcelFieldsToUpdate,
sfFramework,
paymentToken,
Expand Down Expand Up @@ -179,7 +179,7 @@ function OutstandingBidView(props: OutstandingBidViewProps) {
}

setIsActing(false);
setIsPortfolioToUpdate(true);
setShouldRefetchParcelsData(true);
setParcelFieldsToUpdate({
forSalePrice: newForSalePriceDisplay !== existingForSalePriceDisplay,
licenseOwner: true,
Expand Down Expand Up @@ -220,7 +220,7 @@ function OutstandingBidView(props: OutstandingBidViewProps) {
setInteractionState(STATE.PARCEL_SELECTED);

setSelectedParcelId("");
setIsPortfolioToUpdate(true);
setShouldRefetchParcelsData(true);
setSelectedParcelId(selectedParcelId);
}

Expand Down
4 changes: 2 additions & 2 deletions components/cards/ParcelInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ function ParcelInfo(props: ParcelInfoProps) {
</Col>
<Col className="d-flex justify-content-end gap-2 text-end pt-2 mx-2">
<OverlayTrigger
key="top"
key="chat"
placement="top"
overlay={<Tooltip id={`tooltip-key`}>Open Parcel Chat</Tooltip>}
>
Expand All @@ -421,7 +421,7 @@ function ParcelInfo(props: ParcelInfoProps) {
</Button>
</OverlayTrigger>
<OverlayTrigger
key="top"
key="browser"
placement="top"
overlay={
<Tooltip id={`tooltip-key`}>Open in Spatial Browser</Tooltip>
Expand Down
4 changes: 2 additions & 2 deletions components/cards/PlaceBidAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function PlaceBidAction(props: PlaceBidActionProps) {
perSecondFeeDenominator,
licenseDiamondContract,
setInteractionState,
setIsPortfolioToUpdate,
setShouldRefetchParcelsData,
setParcelFieldsToUpdate,
sfFramework,
paymentToken,
Expand Down Expand Up @@ -203,7 +203,7 @@ function PlaceBidAction(props: PlaceBidActionProps) {
}

setIsActing(false);
setIsPortfolioToUpdate(true);
setShouldRefetchParcelsData(true);
setInteractionState(STATE.PARCEL_SELECTED);
setParcelFieldsToUpdate({
forSalePrice: displayNewForSalePrice !== displayCurrentForSalePrice,
Expand Down
4 changes: 2 additions & 2 deletions components/cards/RejectBidAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function RejectBidAction(props: RejectBidActionProps) {
bidTimestamp,
bidForSalePrice,
setInteractionState,
setIsPortfolioToUpdate,
setShouldRefetchParcelsData,
setParcelFieldsToUpdate,
sfFramework,
paymentToken,
Expand Down Expand Up @@ -293,7 +293,7 @@ function RejectBidAction(props: RejectBidActionProps) {
}

setIsActing(false);
setIsPortfolioToUpdate(true);
setShouldRefetchParcelsData(true);
setInteractionState(STATE.PARCEL_SELECTED);
setParcelFieldsToUpdate({
forSalePrice: displayNewForSalePrice !== displayCurrentForSalePrice,
Expand Down
6 changes: 3 additions & 3 deletions components/cards/StreamingInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type StreamingInfoProps = {
setSelectedParcelId: React.Dispatch<React.SetStateAction<string>>;
setInteractionState: React.Dispatch<React.SetStateAction<STATE>>;
setPortfolioNeedActionCount: React.Dispatch<React.SetStateAction<number>>;
setPortfolioParcelCenter: React.Dispatch<React.SetStateAction<Point | null>>;
isPortfolioToUpdate: boolean;
setIsPortfolioToUpdate: React.Dispatch<React.SetStateAction<boolean>>;
setParcelNavigationCenter: React.Dispatch<React.SetStateAction<Point | null>>;
shouldRefetchParcelsData: boolean;
setShouldRefetchParcelsData: React.Dispatch<React.SetStateAction<boolean>>;
};

function StreamingInfo(props: StreamingInfoProps) {
Expand Down
Loading