aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/AnotherComponent.tsx28
-rw-r--r--src/components/FFXIVWorldSelector.tsx59
2 files changed, 87 insertions, 0 deletions
diff --git a/src/components/AnotherComponent.tsx b/src/components/AnotherComponent.tsx
new file mode 100644
index 0000000..f74e924
--- /dev/null
+++ b/src/components/AnotherComponent.tsx
@@ -0,0 +1,28 @@
+import React, { useState, useEffect } from 'react';
+
+const AnotherComponent: React.FC = () => {
+ const [selectedWorld, setSelectedWorld] = useState<string | null>(null);
+
+ useEffect(() => {
+ // Load selected world from localStorage
+ const savedWorld = localStorage.getItem('selectedWorld');
+ if (savedWorld) {
+ setSelectedWorld(savedWorld);
+ }
+ }, []);
+
+ return (
+ <div>
+ <p>Selected World: {selectedWorld}</p>
+ <button onClick={() => {
+ const newWorld = 'New World';
+ setSelectedWorld(newWorld);
+ localStorage.setItem('selectedWorld', newWorld); // Save to localStorage
+ }}>
+ Change World
+ </button>
+ </div>
+ );
+};
+
+export default AnotherComponent; \ No newline at end of file
diff --git a/src/components/FFXIVWorldSelector.tsx b/src/components/FFXIVWorldSelector.tsx
new file mode 100644
index 0000000..f2dc4cc
--- /dev/null
+++ b/src/components/FFXIVWorldSelector.tsx
@@ -0,0 +1,59 @@
+import React, { useState, useEffect } from 'react';
+
+interface World {
+ id: number;
+ name: string;
+}
+
+const FFXIVWorldSelector: React.FC = () => {
+ const [worlds, setWorlds] = useState<World[]>([]);
+ const [selectedWorld, setSelectedWorld] = useState<string | null>(null);
+
+ useEffect(() => {
+ const fetchWorlds = async () => {
+ try {
+ const response = await fetch('https://universalis.app/api/v2/worlds');
+ const data = await response.json();
+ setWorlds(data);
+ } catch (error) {
+ console.error('Error fetching worlds:', error);
+ }
+ };
+
+ fetchWorlds();
+
+ // Load selected world from localStorage
+ const savedWorld = localStorage.getItem('selectedWorld');
+ if (savedWorld) {
+ setSelectedWorld(savedWorld);
+ }
+ }, []);
+
+ const handleWorldChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
+ const selectedWorld = event.target.value;
+ setSelectedWorld(selectedWorld);
+ localStorage.setItem('selectedWorld', selectedWorld); // Save to localStorage
+ };
+
+ const handleApplyClick = () => {
+ window.location.reload(); // Refresh the page
+ };
+
+ return (
+ <div>
+ <label htmlFor="world-select">Select a world: </label>
+ <select id="world-select" onChange={handleWorldChange} value={selectedWorld || ''}>
+ <option value="">--Please choose an option--</option>
+ {worlds.map((world) => (
+ <option key={world.id} value={world.name}>
+ {world.name}
+ </option>
+ ))}
+ </select>
+ {selectedWorld && <p>Selected World: {selectedWorld}</p>}
+ <button onClick={handleApplyClick}>Apply</button>
+ </div>
+ );
+};
+
+export default FFXIVWorldSelector; \ No newline at end of file
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage