Skip to content

Commit

Permalink
fix: removed console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cephaschapa committed Mar 18, 2024
1 parent ae9187c commit 7ab8981
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
15 changes: 3 additions & 12 deletions app/src/app/[lng]/data/[step]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,6 @@ export default function AddDataSteps({
});
}
// Add file data to rudux state object
const hasUserAddedRequiredData = (
scopes: string,
subsectors: string,
): boolean => {
const hasValues = scopes.length && subsectors.length ? true : false;
return hasValues;
};

const {
isOpen: isfileDataModalOpen,
onOpen: onfileDataModalOpen,
Expand All @@ -477,7 +469,7 @@ export default function AddDataSteps({
const base64FileString = await fileToBase64(file);
const filename = file.name;
onfileDataModalOpen();
console.log(formData);

dispatch(
addFile({
sectorName: currentStep.title!,
Expand All @@ -496,14 +488,13 @@ export default function AddDataSteps({
},
}),
);
dispatch(clear());
};

const sectorData = getInventoryData.sectors.filter(
(sector) => sector.sectorName === currentStep.title,
);

console.log(sectorData);

function removeSectorFile(fileId: string, sectorName: string) {
dispatch(
removeFile({
Expand Down Expand Up @@ -835,7 +826,7 @@ export default function AddDataSteps({
return (
<Card
shadow="none"
h="124px"
h="84px"
w="full"
borderWidth="1px"
borderColor="border.overlay"
Expand Down
7 changes: 4 additions & 3 deletions app/src/components/Modals/add-file-data-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from "react";
import React, { FC, useEffect, useState } from "react";
import {
Box,
Button,
Expand Down Expand Up @@ -35,7 +35,7 @@ interface AddFileDataModalProps {

export interface FileData {
subsectors: string;
scope: string;
scopes: string;
}

const AddFileDataModal: FC<AddFileDataModalProps> = ({
Expand Down Expand Up @@ -154,6 +154,7 @@ const AddFileDataModal: FC<AddFileDataModalProps> = ({
<DropdownSelectInput
subsectors={subsectors}
setValue={setValue}
watch={watch}
t={t}
/>
</FormControl>
Expand All @@ -172,7 +173,7 @@ const AddFileDataModal: FC<AddFileDataModalProps> = ({
<Checkbox
value={scope.value}
borderColor="interactive.secondary"
{...register("scope")}
{...register("scopes")}
onChange={(e) =>
handleSelectedScopes(scope.value, e.target.checked)
}
Expand Down
13 changes: 10 additions & 3 deletions app/src/components/dropdown-select-input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import {
Box,
Tag,
Expand All @@ -12,20 +12,27 @@ import {
} from "@chakra-ui/react";
import { MdArrowDropDown, MdArrowDropUp } from "react-icons/md";
import { SubSectorWithRelations } from "@/app/[lng]/data/[step]/types";
import { UseFormRegister, UseFormSetValue, useForm } from "react-hook-form";
import {
UseFormRegister,
UseFormSetValue,
UseFormWatch,
useForm,
} from "react-hook-form";
import { FileData } from "./Modals/add-file-data-modal";
import { TFunction } from "i18next";

interface DropdownSelectProps {
subsectors: SubSectorWithRelations[] | null;
setValue: UseFormSetValue<FileData>;
t: TFunction;
watch: UseFormWatch<FileData>;
}

const DropdownSelectInput: React.FC<DropdownSelectProps> = ({
subsectors,
setValue,
t,
watch,
}) => {
const [selectedItems, setSelectedItems] = useState<string[]>([]);

Expand All @@ -35,6 +42,7 @@ const DropdownSelectInput: React.FC<DropdownSelectProps> = ({
) => {
if (event.target.checked) {
setSelectedItems([...selectedItems, value]);
setValue("subsectors", subsectorValues.length ? subsectorValues : "");
} else {
setSelectedItems(selectedItems.filter((item) => item !== value));
}
Expand All @@ -52,7 +60,6 @@ const DropdownSelectInput: React.FC<DropdownSelectProps> = ({
};

const subsectorValues = selectedItems.slice().join(",");
setValue("subsectors", subsectorValues.length ? subsectorValues : "");

return (
<Box className="w-full">
Expand Down

0 comments on commit 7ab8981

Please sign in to comment.