Skip to content

Commit

Permalink
Merge pull request #1092 from Shelf-nu/1079-bug-i-am-update-locationq…
Browse files Browse the repository at this point in the history
…t-code-scan-but-assets-not-update-via-crisp

fix: make sure qr scan redirects to correct url to be able to update position using usePosition hook
  • Loading branch information
DonKoko authored Jun 24, 2024
2 parents a8c2729 + ecb20b1 commit 4ee9e3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
29 changes: 7 additions & 22 deletions app/components/location/scan-details.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
import type { ReactNode } from "react";
import type { SerializeFrom } from "@remix-run/node";
import { Button } from "~/components/shared/button";
import type { parseScanData } from "~/modules/scan/utils.server";
import { ShelfMap } from "./map";
import { MapPlaceholder } from "./map-placeholder";
import { HelpIcon } from "../icons/library";
import { InfoTooltip } from "../shared/info-tooltip";

export interface lastScanType {
lastScan?: {
coordinates: string;
dateTime: ReactNode;
ua: {
device: {
model: string;
vendor: string;
};
browser: {
name: string;
};
os: {
name: string;
};
};
manuallyGenerated: boolean;
};
}

export function ScanDetails({ lastScan }: lastScanType) {
export function ScanDetails({
lastScan,
}: {
lastScan?: SerializeFrom<ReturnType<typeof parseScanData>> | null;
}) {
let latitude, longitude;

const hasLocation = lastScan?.coordinates !== "Unknown location";
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_layout+/assets.$assetId.overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export async function action({ context, request, params }: ActionFunctionArgs) {
}

export default function AssetOverview() {
const { asset, locale, timeZone, qrObj } = useLoaderData<typeof loader>();
const { asset, locale, timeZone, qrObj, lastScan } =
useLoaderData<typeof loader>();
const booking = asset?.bookings?.length ? asset?.bookings[0] : undefined;

const customFieldsValues =
Expand Down Expand Up @@ -464,8 +465,7 @@ export default function AssetOverview() {
/>

{asset && <AssetQR qrObj={qrObj} asset={asset} />}
{/* @TODO: Figure our the issue with type definition of `lastScan` */}
{!isSelfService ? <ScanDetails /> : null}
{!isSelfService ? <ScanDetails lastScan={lastScan} /> : null}
</div>
</div>
<ContextualSidebar />
Expand Down
2 changes: 1 addition & 1 deletion app/routes/qr+/$qrId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export async function loader({ context, request, params }: LoaderFunctionArgs) {
}

return redirect(
`/assets/${qr.assetId}?ref=qr&scanId=${scan.id}&qrId=${qr.id}`,
`/assets/${qr.assetId}/overview?ref=qr&scanId=${scan.id}&qrId=${qr.id}`,
{
headers,
}
Expand Down

0 comments on commit 4ee9e3a

Please sign in to comment.