forked from ozalboher/IntegratorPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
232 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Styles for the LabSelect component are in the StationSelect.css file | ||
import React, { useState } from "react"; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import LabLogo from "../../Assets/labs-icon.png"; | ||
import { Msg } from "../Msg/Msg"; | ||
import { BackIconSmall } from "../../Assets/BackIconSmall"; | ||
|
||
|
||
export const LabSelect = (props) => { | ||
const { items, setItems, setName } = props; // Make the items and setItems props available | ||
const [editMode, setEditMode] = useState(null); | ||
const [stationName, setStationName] = useState("Your Station Name"); | ||
const [newItem, setNewItem] = useState({ | ||
name: "New Lab", | ||
}); | ||
const [msg, setMsg] = useState(""); | ||
const [isError, setIsError] = useState(false); | ||
|
||
const handleNameClick = (id) => { | ||
setEditMode(id); | ||
// Find the item with the clicked ID and set its name as the current stationName | ||
const selectedItem = items.find((item) => item.id === id); | ||
if (selectedItem) { | ||
setStationName(selectedItem.name); | ||
} | ||
}; | ||
|
||
const handleNameChange = (event) => { | ||
if (event.target.value.length > 15) { | ||
setIsError(true); | ||
setMsg("Name is too long"); | ||
setTimeout(() => { | ||
setMsg(""); | ||
}, 3000); | ||
return; | ||
} | ||
if (event.target.value.length < 1) { | ||
setIsError(true); | ||
setMsg("Name is too short"); | ||
setTimeout(() => { | ||
setMsg(""); | ||
}, 3000); | ||
} | ||
setStationName(event.target.value); | ||
}; | ||
|
||
const handleNameBlur = () => { | ||
setEditMode(null); | ||
console.log("Save the new name: ", stationName); | ||
// Update the item's name in the state | ||
setItems((prevItems) => | ||
prevItems.map((item) => | ||
item.id === editMode ? { ...item, name: stationName } : item | ||
) | ||
); | ||
}; | ||
|
||
const handleSaveNewItem = () => { | ||
setItems((prevItems) => [ | ||
...prevItems, | ||
{ | ||
id: uuidv4(), | ||
name: newItem.name, | ||
} | ||
]); | ||
console.log(items); | ||
setNewItem({ name: "New Lab" }); // Clear the newItem after saving | ||
}; | ||
|
||
const handleDeleteItem = (id) => { | ||
const isConfirmed = window.confirm("Are you sure you want to delete?"); | ||
if (!isConfirmed) return; | ||
setItems((prevItems) => prevItems.filter((item) => item.id !== id)); | ||
}; | ||
|
||
const handleSelectedItem = (item) => { | ||
setName(item); | ||
}; | ||
return ( | ||
<> | ||
<div className="station-select-container"> | ||
<div className="popup-msg-labs"> | ||
{msg&&<Msg msg={msg} isError={isError}/>} | ||
</div> | ||
<button className="add-new-button" onClick={handleSaveNewItem}> | ||
Add New | ||
</button> | ||
<div className="station-box"> | ||
{items.map((item) => ( | ||
<li key={item.id} className=""> | ||
<span | ||
className="delete-icon" | ||
onClick={() => handleDeleteItem(item.id)} | ||
> | ||
✖ {/* "X" character */} | ||
</span> | ||
{/* <Link to={{ pathname: `${item.name}` }}> */} | ||
<img | ||
className="ws-logo" | ||
src={LabLogo} | ||
alt="StationLogo" | ||
onClick={() => handleSelectedItem(item.name)} | ||
title="" | ||
onContextMenu={(e) => e.preventDefault()} | ||
/> | ||
{/* </Link> */} | ||
|
||
{editMode === item.id ? ( | ||
<input | ||
className="station-name-input" | ||
type="text" | ||
value={stationName} | ||
onChange={handleNameChange} | ||
onBlur={handleNameBlur} | ||
/> | ||
) : ( | ||
<div | ||
className="station-name" | ||
onClick={() => handleNameClick(item.id)} | ||
> | ||
{item.name} | ||
</div> | ||
)} | ||
</li> | ||
))} | ||
</div> | ||
|
||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { React } from 'react'; | ||
import { useState } from 'react'; | ||
|
||
|
||
export const XrDocs= () => { | ||
|
||
return ( | ||
<> | ||
<div> | ||
<button className='general-btn'>DOCS</button> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { React } from 'react'; | ||
import { useState } from 'react'; | ||
import { StationSelect } from '../../../Components/StationSelect/StationSelect'; | ||
import {StationInfo } from '../../../Components/StationInfo/StationInfo'; | ||
import { LabSelect } from '../../../Components/LabSelect/LabSelect'; | ||
|
||
export const XrLabs= () => { | ||
const [labItems, setLabItems] = useState([{ id: 1, name: 'Lab-102' }]);// Send the information to the LabSelect component | ||
const [items, setItems] = useState([{ id: 1, name: 'New Station' }]);// Send the information to the StationSelect component | ||
const [items2, setItems2] = useState([{ id: 1, name: 'New PC' }]);// Send the information to the StationInfo component | ||
|
||
const [labName, setLabName] = useState(''); | ||
const [stationTitleName, setStationTitleName] = useState(''); | ||
|
||
|
||
return ( | ||
<> | ||
<div className='page-content'> | ||
<h1 style={{ textAlign: "center" }}>XR LABS</h1> | ||
{labName && <h2 style={{ textAlign: 'center' }}>Lab Selected: {labName}</h2>} | ||
{stationTitleName && <h2 style={{ textAlign: 'center' }}>Station Selected: {stationTitleName}</h2>} | ||
{/* pages content based on states of labName and stationTitleName */ } | ||
{!labName && <LabSelect items={labItems} setItems={setLabItems} setName={setLabName}/>} | ||
{ labName && !stationTitleName && <StationSelect items = {items} setItems = {setItems} setName={setStationTitleName} labNameRemove = {setLabName}/>} | ||
{ stationTitleName && <StationInfo items={items2} setItems={setItems2} setName = {setStationTitleName}/>} | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { React } from "react"; | ||
import { CircleMenu } from "../../../Components/CircleMenu/CircleMenu"; | ||
|
||
export const XrMain = () => { | ||
const backBtn = true; | ||
const menuItems = [ | ||
{ label: "LABS", link: "/xr-labs" }, | ||
{ label: "DOCS", link: "/xr-docs" }, | ||
]; | ||
|
||
return ( | ||
<> | ||
<CircleMenu items={menuItems} backBtn={backBtn} /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.