diff options
| author | Pinapelz <yukais@pinapelz.com> | 2024-08-27 01:12:32 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2024-08-27 01:12:32 -0700 |
| commit | 1cc5a2be9e7c3408b8b59aabd6d6e9afeb574c84 (patch) | |
| tree | 7b340eb97d41edc91c5c4993233cb01ba140919c | |
| parent | e3f0281c25d6ead23264a94b0a7b18f10019c185 (diff) | |
move ffxiv post components to submodule
- declutter blog code
| -rw-r--r-- | .gitmodules | 3 | ||||
| m--------- | src/components/FFXIV-MDX-React-Components | 0 | ||||
| -rw-r--r-- | src/components/FFXIVItemPrice.tsx | 119 | ||||
| -rw-r--r-- | src/components/FFXIVWorldSelector.tsx | 62 | ||||
| -rw-r--r-- | src/content/blog/ffxiv-gil-making.mdx | 6 | ||||
| -rw-r--r-- | src/styles/ffxiv-gil-making.css | 18 | ||||
| -rw-r--r-- | src/styles/ffxiv-selector.css | 72 |
7 files changed, 6 insertions, 274 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..284fc45 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/components/FFXIV-MDX-React-Components"] + path = src/components/FFXIV-MDX-React-Components + url = https://github.com/pinapelz/FFXIV-MDX-React-Components diff --git a/src/components/FFXIV-MDX-React-Components b/src/components/FFXIV-MDX-React-Components new file mode 160000 +Subproject 53c7ce959b5c72002c5444b7d6e5b458331a427 diff --git a/src/components/FFXIVItemPrice.tsx b/src/components/FFXIVItemPrice.tsx deleted file mode 100644 index d65b3ca..0000000 --- a/src/components/FFXIVItemPrice.tsx +++ /dev/null @@ -1,119 +0,0 @@ -import React, { useState, useEffect } from 'react'; - -interface FFXIVItemPriceProps { - itemId: number; - itemName: string; - itemImageUrl: string; -} - -const FFXIVItemPrice: React.FC<FFXIVItemPriceProps> = ({ itemId = 5530, itemName="Coke", itemImageUrl="https://xivapi.com/i/021000/021462_hr1.png"}) => { - const [selectedWorld, setSelectedWorld] = useState<string | null>(null); - const [dailySaleVelocity, setDailySaleVelocity] = useState<number | null>(null); - const [averageSalePrice, setAverageSalePrice] = useState<number | null>(null); - const [inputQuantity, setInputQuantity] = useState<number>(0); - const [potentialGil, setPotentialGil] = useState<number>(0); - const [dataSource, setDataSource] = useState<string>('world'); - - const fetchData = (attempt: number = 1) => { - fetch(`https://universalis.app/api/v2/aggregated/${selectedWorld}/${itemId}`) - .then(response => response.json()) - .then(data => { - let result = data.results[0]; - try { - setDailySaleVelocity(Math.round(result.nq.dailySaleVelocity.world.quantity)); - setAverageSalePrice(Math.round(result.nq.averageSalePrice.world.price)); - setDataSource('world'); - } catch (error) { - try { - setDailySaleVelocity(Math.round(result.nq.dailySaleVelocity.dc.quantity)); - setAverageSalePrice(Math.round(result.nq.averageSalePrice.dc.price)); - setDataSource('dc'); - } catch (error) { - try { - setDailySaleVelocity(Math.round(result.nq.dailySaleVelocity.region.quantity)); - setAverageSalePrice(Math.round(result.nq.averageSalePrice.region.price)); - setDataSource('region'); - } catch (error) { - console.error('Error fetching data:', error); - if (attempt < 3) { - setTimeout(() => fetchData(attempt + 1), 5000); - } - } - } - } - }) - .catch(error => { - console.error(`Error fetching data (attempt ${attempt}):`, error); - if (attempt < 3) { - setTimeout(() => fetchData(attempt + 1), 5000); - } - }); - }; - - useEffect(() => { - const savedWorld = localStorage.getItem('selectedWorld'); - if (savedWorld) { - setSelectedWorld(savedWorld); - } else { - setSelectedWorld('Midgardsormr'); - } - - fetchData(); - }, [itemId, selectedWorld]); - - const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { - const quantity = parseInt(e.target.value, 10); - setInputQuantity(quantity); - setPotentialGil(quantity * (averageSalePrice || 0)); - }; - - const formatNumber = (number: number | null) => { - return number !== null ? new Intl.NumberFormat().format(number) : 'N/A'; - }; - - return ( - <div className="ffxiv-container"> - <div className="ffxiv-header"> - <a href={"https://universalis.app/market/" + itemId} className="no-underline"> - <h1 className="ffxiv-h1">{itemName}</h1> - </a> - <img src={itemImageUrl} alt={itemName} className="ffxiv-item-icon" /> - </div> - <table className="ffxiv-table"> - <tbody> - <tr> - <td className="ffxiv-label">Average Price/Item:</td> - <td className="ffxiv-value">{formatNumber(averageSalePrice)} gil</td> - </tr> - <tr> - <td className="ffxiv-label">Daily Sale Velocity:</td> - <td className="ffxiv-value">{formatNumber(dailySaleVelocity)} items</td> - </tr> - <tr> - <td className="ffxiv-label">Enter Quantity:</td> - <td> - <input - type="number" - value={inputQuantity} - onChange={handleInputChange} - placeholder="Enter quantity" - className="ffxiv-input" - /> - </td> - </tr> - <tr> - <td className="ffxiv-label">Potential Gil Earnings:</td> - <td className="ffxiv-value">{formatNumber(potentialGil)} gil</td> - </tr> - </tbody> - </table> - <footer> - {dataSource === 'dc' ? 'Datacenter Fallback ' : dataSource === 'region' ? 'Regional Fallback ' : ''} - {selectedWorld} Marketboard Data provided by Universalis API. <a className="eorzeadb_link" href="#" onClick={(e) => { e.preventDefault(); fetchData(); }}>Click here to reload data</a> - <br /> - </footer> - </div> - ); -}; - -export default FFXIVItemPrice;
\ No newline at end of file diff --git a/src/components/FFXIVWorldSelector.tsx b/src/components/FFXIVWorldSelector.tsx deleted file mode 100644 index 63eff07..0000000 --- a/src/components/FFXIVWorldSelector.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import '../styles/ffxiv-selector.css'; -interface World { - id: number; - name: string; -} - -interface FFXIVWorldSelectorProps { - message: string; -} - -const FFXIVWorldSelector: React.FC<FFXIVWorldSelectorProps> = ({ message = "Select a World" }) => { - 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 className="ffxiv-container"> - <label htmlFor="world-select" className="ffxiv-label">{message}</label> - <select id="world-select" onChange={handleWorldChange} value={selectedWorld || ''} className="ffxiv-select"> - <option value="">--Please choose an option--</option> - {worlds.map((world) => ( - <option key={world.id} value={world.name}> - {world.name} - </option> - ))} - </select> - <button onClick={handleApplyClick} className="ffxiv-button">Apply</button> - </div> - ); -}; - -export default FFXIVWorldSelector;
\ No newline at end of file diff --git a/src/content/blog/ffxiv-gil-making.mdx b/src/content/blog/ffxiv-gil-making.mdx index 39dbe68..fcbdec3 100644 --- a/src/content/blog/ffxiv-gil-making.mdx +++ b/src/content/blog/ffxiv-gil-making.mdx @@ -3,9 +3,9 @@ title: "FFXIV - Actually Making Gil Without Crafting" description: "An actually OK guide at how to become a gillionaire without crafting (not just running roulettes and maps)" pubDate: "2024-08-23" --- -import '../../styles/ffxiv-gil-making.css' -import FFXIVWorldSelector from '../../components/FFXIVWorldSelector'; -import FFXIVItemPrice from '../../components/FFXIVItemPrice'; +import '../../components/FFXIV-MDX-React-Components/style.css' +import FFXIVWorldSelector from '../../components/FFXIV-MDX-React-Components/src/components/FFXIVWorldSelector'; +import FFXIVItemPrice from '../../components/FFXIV-MDX-React-Components/src/components/FFXIVItemPrice'; <FFXIVWorldSelector client:load message="Set your home world to get crowdsourced marketboard information!" /> <script src="https://lds-img.finalfantasyxiv.com/pc/global/js/eorzeadb/loader.js?v3"></script> diff --git a/src/styles/ffxiv-gil-making.css b/src/styles/ffxiv-gil-making.css deleted file mode 100644 index 711b873..0000000 --- a/src/styles/ffxiv-gil-making.css +++ /dev/null @@ -1,18 +0,0 @@ -.eorzeadb_link { - color: goldenrod; - text-decoration: none; - position: relative; -} - -.eorzeadb_link:hover { - color: darkgoldenrod; -} - -.no-underline { - color: inherit; - text-decoration: none; -} - -.no-underline:hover { - text-decoration: underline; -}
\ No newline at end of file diff --git a/src/styles/ffxiv-selector.css b/src/styles/ffxiv-selector.css deleted file mode 100644 index efad540..0000000 --- a/src/styles/ffxiv-selector.css +++ /dev/null @@ -1,72 +0,0 @@ -.ffxiv-container { - background-color: #1a1a1a; - color: #e2c08d; - padding: 10px; - border: 2px solid #e2c08d; - border-radius: 10px; - font-family: 'Arial', serif; - max-width: 500px; - margin: auto; -} - -.ffxiv-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 10px; -} - -.ffxiv-item-icon { - width: 50px; - height: 50px; -} - -.ffxiv-h1 { - font-size: 1.5em; - color: #e2c08d; - margin: 0; -} - -.ffxiv-table { - width: 100%; - border-collapse: collapse; -} - -.ffxiv-button { - background-color: #333; - color: #e2c08d; - border: 1px solid #e2c08d; - padding: 5px; - padding-left: 10px; - padding-right: 10px; - margin-left: 10px; - border-radius: 5px; - cursor: pointer; -} - -.ffxiv-table td { - padding: 5px; - border: 1px solid #e2c08d; -} - -.ffxiv-label { - font-size: 1em; -} - -.ffxiv-value { - font-size: 1em; -} - -.ffxiv-input { - background-color: #333; - color: #e2c08d; - border: 1px solid #e2c08d; - padding: 5px; - border-radius: 5px; - width: 100%; - box-sizing: border-box; -} - -.ffxiv-input::placeholder { - color: #e2c08d; -}
\ No newline at end of file |
