Skip to content

Commit

Permalink
Merge pull request #173 from bavix/microref
Browse files Browse the repository at this point in the history
uuidType
  • Loading branch information
rez1dent3 committed Jul 29, 2024
2 parents 5132c6b + a6da7b1 commit dc51b0e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@

gtag('config', 'G-0E805HG8JN');
</script>
<script src="assets/bundle-Dc_XYQh-.js"></script>
<script src="assets/bundle-B1Zvy3n2.js"></script>
</body>
</html>
38 changes: 9 additions & 29 deletions src/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,6 @@ export default class NavComponent extends React.Component {
setUuid(uuid);
}

/**
* Saves the UUID type to localStorage.
*
* @param {string} type - The UUID type to save.
* @return {void}
*/
saveSelectedUuidType = (type) => {
// Save the UUID type to localStorage
localStorage.setItem('uuidType', type);
}

/**
* Retrieves the UUID type from localStorage.
*
* @return {string} The UUID type from localStorage or 'v4' if it is not found.
*/
getStoredUuidType = () => {
// Retrieve the UUID type from localStorage
let type = localStorage.getItem('uuidType');

// Return the UUID type or 'v4' if it is not found
return type ? type : 'v4';
}

/**
* Render method for the NavComponent.
*
Expand All @@ -101,7 +77,14 @@ export default class NavComponent extends React.Component {
*/
render() {
// State to store the selected UUID type
const [selectedUuidType, setSelectedUuidType] = React.useState(this.getStoredUuidType());
const [selectedUuidType, setSelectedUuidType] = React.useState(
localStorage.getItem('uuidType') || 'v4'
);

// Effect to store the selected UUID type in localStorage
React.useEffect(() => {
localStorage.setItem('uuidType', selectedUuidType);
}, [selectedUuidType]);

// State to store the generated UUID
const [generatedUuid, setGeneratedUuid] = React.useState('');
Expand Down Expand Up @@ -151,10 +134,7 @@ export default class NavComponent extends React.Component {
<p className="control">
<span className="select is-link is-small">
{/* Dropdown menu for UUID types */}
<select onChange={(e) => {
setSelectedUuidType(e.target.value);
this.saveSelectedUuidType(e.target.value);
}}>
<select onChange={(e) => setSelectedUuidType(e.target.value)}>
{uuidTypes.map(type => (
<option key={type} value={type} selected={selectedUuidType === type}>
{type}
Expand Down

0 comments on commit dc51b0e

Please sign in to comment.