tetrons 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/app/page.jsx +11 -4
  2. package/package.json +1 -1
package/dist/app/page.jsx CHANGED
@@ -1,13 +1,22 @@
1
1
  "use client";
2
2
  import { useEffect, useState } from "react";
3
+ import { useSearchParams } from "next/navigation";
3
4
  import EditorContent from "../components/tetrons/EditorContent";
4
5
  import "../styles/tetrons.css";
5
6
  export default function Home() {
7
+ const searchParams = useSearchParams();
8
+ const urlKey = searchParams.get("apiKey");
6
9
  const [apiKey, setApiKey] = useState(null);
7
10
  const [loading, setLoading] = useState(true);
8
11
  useEffect(() => {
9
12
  const fetchApiKey = async () => {
10
13
  try {
14
+ if (urlKey) {
15
+ setApiKey(urlKey);
16
+ localStorage.setItem("my-api-key", urlKey);
17
+ setLoading(false);
18
+ return;
19
+ }
11
20
  const cachedKey = localStorage.getItem("my-api-key");
12
21
  if (cachedKey) {
13
22
  setApiKey(cachedKey);
@@ -16,9 +25,7 @@ export default function Home() {
16
25
  }
17
26
  const res = await fetch("/api/register", {
18
27
  method: "POST",
19
- headers: {
20
- "Content-Type": "application/json",
21
- },
28
+ headers: { "Content-Type": "application/json" },
22
29
  body: JSON.stringify({
23
30
  email: "mr.swastikjha@gmail.com",
24
31
  organization: "FCSPL",
@@ -40,7 +47,7 @@ export default function Home() {
40
47
  }
41
48
  };
42
49
  fetchApiKey();
43
- }, []);
50
+ }, [urlKey]);
44
51
  if (loading) {
45
52
  return <div className="text-center p-4">⏳ Loading Editor...</div>;
46
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tetrons",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "A Next.js project written in TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",