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

fix(ui): empty dashboard, add data finish button not linking to dashboard, signup callback URL issue #417

Merged
merged 6 commits into from
Apr 4, 2024
16 changes: 11 additions & 5 deletions app/src/app/[lng]/[inventory]/data/review/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { RootState } from "@/lib/store";

import { ArrowBackIcon } from "@chakra-ui/icons";
import { Box, Button, Card, Heading, Icon, Text } from "@chakra-ui/react";
import { useRouter } from "next/navigation";
import { useParams, useRouter } from "next/navigation";

import { FaRegTrashAlt, FaTrash } from "react-icons/fa";
import { FiTrash, FiTrash2 } from "react-icons/fi";
import { FaRegTrashAlt } from "react-icons/fa";
import { FiTrash2 } from "react-icons/fi";
import { MdOutlineEdit } from "react-icons/md";
import { useSelector, useDispatch } from "react-redux";
import { clear, removeSectorData } from "@/features/city/inventoryDataSlice";
Expand All @@ -21,11 +21,17 @@ import { appendFileToFormData } from "@/util/helpers";
import { useState } from "react";

export default function ReviewPage({
params: { lng, inventoryId },
params: { lng },
}: {
params: { lng: string; inventoryId: string };
params: { lng: string };
}) {
const { t } = useTranslation(lng, "data");
const { inventory: inventoryParam } = useParams();
let inventoryId = inventoryParam as string | null;
if (inventoryId === "null" || inventoryId === "undefined") {
inventoryId = null;
}

const router = useRouter();
const dispatch = useDispatch();
const getAllSectorData = useSelector(
Expand Down
7 changes: 5 additions & 2 deletions app/src/app/[lng]/[inventory]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ export default function Home({ params: { lng } }: { params: { lng: string } }) {
const { t } = useTranslation(lng, "dashboard");
const toast = useToast();
const router = useRouter();
const { inventory: cityParam } = useParams();
const inventoryId = cityParam as string;
const { inventory: inventoryParam } = useParams();
let inventoryId = inventoryParam as string | null;
if (inventoryId === "null" || inventoryId === "undefined") {
inventoryId = null;
}

// query API data
// TODO maybe rework this logic into one RTK query:
Expand Down
8 changes: 5 additions & 3 deletions app/src/app/[lng]/auth/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ export default function Signup({
const fullUrl = window.location.href;
const urlParams = new URL(fullUrl);
const callbackUrl = urlParams.searchParams.get("callbackUrl");
if (callbackUrl) {
if (callbackUrl && callbackUrl != "null" && callbackUrl != "undefined") {
try {
const url = new URL(callbackUrl);
const callbackUrlSegments = url.pathname.split("/");
const path = callbackUrl.startsWith("/")
? callbackUrl
: new URL(callbackUrl).pathname;
const callbackUrlSegments = path.split("/");
if (callbackUrlSegments.length > 2) {
inventoryId = callbackUrlSegments.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/Cards/SectorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function SectorCard({
sectorProgress: SectorProgress;
stepNumber: number;
t: TFunction;
inventory: string;
inventory: string | null;
}) {
const [isAccordionOpen, setAccordionOpen] = useState(false);
const toggleAccordion = () => setAccordionOpen(!isAccordionOpen);
Expand Down