aboutsummaryrefslogtreecommitdiff
path: root/islands/ListPackageDetails.tsx
diff options
context:
space:
mode:
authorIndrajith K L2023-05-13 11:17:27 +0530
committerIndrajith K L2023-05-13 11:17:27 +0530
commitfc0064f6a0ed4c66a726a93786f7e1bb39bcfe80 (patch)
treec5b65cd636abe4f367cc0c36ca20ca21a8ad080a /islands/ListPackageDetails.tsx
downloadpackage-analyzer-fc0064f6a0ed4c66a726a93786f7e1bb39bcfe80.tar.gz
package-analyzer-fc0064f6a0ed4c66a726a93786f7e1bb39bcfe80.tar.bz2
package-analyzer-fc0064f6a0ed4c66a726a93786f7e1bb39bcfe80.zip
Initial Commit
* Implements Basic Routing and API * Implements Package.json file select and json parse * Displays Project Name, Version & Desc from the package.json * Fetch all package details using npm registry API and map it based on package name
Diffstat (limited to 'islands/ListPackageDetails.tsx')
-rw-r--r--islands/ListPackageDetails.tsx31
1 files changed, 31 insertions, 0 deletions
diff --git a/islands/ListPackageDetails.tsx b/islands/ListPackageDetails.tsx
new file mode 100644
index 0000000..3b7c36f
--- /dev/null
+++ b/islands/ListPackageDetails.tsx
@@ -0,0 +1,31 @@
+import { useEffect, useState } from "preact/hooks";
+
+export default function ListPackageDetails(props: any) {
+ const [packages, setPacakges] = useState(props.packages);
+ const [projectName, setProjectName] = useState(props.projectname);
+ const [projectVersion, setProjectVersion] = useState(props.projectversion);
+ const [projectDesc, setProjectDesc] = useState(props.projectdesc);
+ const [isLoading, setIsLoading] = useState(false);
+ useEffect(() => {
+ fetchRegistry();
+ }, [packages])
+
+ const fetchRegistry = async () => {
+ setIsLoading(true);
+ const response = await fetch("/api/npm", {
+ method: 'POST',
+ body: JSON.stringify(packages)
+ });
+ const data = await response.json();
+ setIsLoading(false);
+ }
+
+ return (
+ <div>
+ <h3>{projectName}</h3>
+ <h4>{projectVersion}</h4>
+ <h5>{projectDesc}</h5>
+ {isLoading ? <>Loading</> : <>Data</>}
+ </div>
+ )
+} \ No newline at end of file