From bf6cc85d55ce54588d8f20a39c9e96e243de13b3 Mon Sep 17 00:00:00 2001 From: Shaun Orssaud Date: Mon, 29 Jan 2024 11:37:53 +0900 Subject: [PATCH] ROSC design update --- docker-compose.yml | 2 +- .../pages/marketplace/tabs/Rosc/CreateTab.tsx | 367 ++++++++++-------- 2 files changed, 216 insertions(+), 153 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1834a4a..e12c35d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,4 +8,4 @@ services: ports: - "3000:80" environment: - - codex_url=${codex_url:-http://kubernetes.docker.internal:30001} + - codex_url=${codex_url:-http://kubernetes.docker.internal:30003} diff --git a/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx b/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx index c025acc..ed9ce9e 100644 --- a/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx +++ b/frontend/src/pages/marketplace/tabs/Rosc/CreateTab.tsx @@ -17,25 +17,36 @@ function CreateTab() { const [expiry, setExpiry] = useState("") const [nodes, setNodes] = useState("") const [tolerance, setTolerance] = useState("") - const [collateral, setCollateral,] = useState(""); + const [collateral, setCollateral] = useState(""); const [error, setError] = useState(""); - const [isBoxOpen, setBoxOpen] = useState(false); + const [isBoxOpenDuration, setBoxOpenDuration] = useState(false); + const [isBoxOpenExpiry, setBoxOpenExpiry] = useState(false); - const toggleBox = () => { - setBoxOpen(!isBoxOpen); + const toggleBoxDuration = () => { + setBoxOpenDuration(!isBoxOpenDuration); }; - const handleDateChange = (selectedDate: any) => { - const timestamp = moment(selectedDate).unix(); - setExpiry(timestamp.toString()); // Format the date as needed - + const toggleBoxExpiry = () => { + setBoxOpenExpiry(!isBoxOpenExpiry); + }; + + const handleExpiryChange = (newDuration: { days: number; hours: number; minutes: number; seconds: number }) => { + const { days, hours, minutes, seconds } = newDuration; + const totalSeconds = days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds; + const timestamp = moment().unix() + totalSeconds; + setExpiry(timestamp.toString()); + }; const handleDurationChange = (newDuration: { days: number; hours: number; minutes: number; seconds: number }) => { const { days, hours, minutes, seconds } = newDuration; const totalSeconds = days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds; - setDuration(totalSeconds.toString()); + + if (totalSeconds >= 60 && totalSeconds <= 86400) { + setDuration(totalSeconds.toString()); + } + }; function upload(cid: string) { @@ -80,88 +91,121 @@ function CreateTab() { }); } + const handleProofProbabilityChange = (e: any) => { + const value = e.target.value; + if (value === "" || (value >= 0 && value <= 99)) { + setProofProbability(value); + } + }; + return ( <> + + - { - setFtdCid(e.target.value); - }} - value={ftdCid} - /> -
- - - -
- { - setProofProbability(e.target.value); - }} - value={proofProbability} - /> -
- setReward(e.target.value)} - value={reward} - /> -
- {/* */} - -
- { - setNodes(e.target.value); - }} - value={nodes} - /> -
- { - setTolerance(e.target.value); - }} - value={tolerance} - /> -
- setCollateral(e.target.value)} - /> - +
+
+ + { + setFtdCid(e.target.value); + }} + value={ftdCid} + /> +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + setReward(e.target.value)} + value={reward} + /> +
+
+ + { + setNodes(e.target.value); + }} + value={nodes} + /> +
+
+ + { + setTolerance(e.target.value); + }} + value={tolerance} + /> +
+
+ + setCollateral(e.target.value)} + /> +
+
+
+
+ +
+ +
+ +
+ +
+
{error && ( -

+

{error}

)} @@ -172,86 +216,105 @@ function CreateTab() { export default CreateTab; const CreateTabWrapper = styled.div` +flex: 1; +display: flex; +flex-direction: column; + +main { display: flex; - flex-direction: row; align-items: center; justify-content: center; - width: 75%; + height: 100%; + width: 100%; + padding: 16px 0px; +} - input { - flex: 3; - height: 60px; - padding: 10px 20px; - border: none; - background-color: ${constants.surfaceColor}; - color: ${constants.onSurfaceColor}; - width: 100%; - } +h1 { + color: ${constants.onSurfaceColor}; + font-size: 24px; + margin: 16px; +} - input:focus { - outline: none; - border: 2px solid ${constants.primaryColor}; - } +.inputs { + padding: 16px; + display: flex; + align-items: center; + justify-content: center; + background-color: #141414; + border-radius: 8px; + width: 50%; +} +.row { + display: flex; + align-items: center; + justify-content: center; +} - input:nth-child(1) { - border-top-left-radius: 8px; - border-bottom-left-radius: 8px; - } +.field { + display: flex; + align-items: left; + flex-direction: column; + height: 100%; + width: 100%; + padding: 0px 4px; +} - #divider { - width: 2.5px; - height: 60px; - background-color: #555555; - } +h4 { + color: ${constants.onSurfaceColor}; + font-size: 20px; + margin: 16px; +} - button { - flex: 2; - height: 60px; - border: none; - background-color: ${constants.primaryColor}; - color: ${constants.onPrimaryColor}; - font-size: 1rem; - cursor: pointer; - border-top-right-radius: 8px; - border-bottom-right-radius: 8px; - width: 100%; - } +input { + height: 60px; + padding: 10px 20px; + border: none; + background-color: ${constants.surfaceColor}; + color: ${constants.onSurfaceColor}; + width: 100%; + border-radius: 8px; + margin: 16px 0px; + border: 2px dashed #9e9e9e; + border-radius: 8px; + text-align: center; +} - @media (max-width: 1180px) { +input:focus { + outline: none; + border: 2px solid ${constants.primaryColor}; +} + +button { + height: 50%; + width: 50%; + margin-top: 40px; + border: none; + background-color: ${constants.primaryColor}; + color: ${constants.onPrimaryColor}; + font-size: 1rem; + cursor: pointer; + border-radius: 8px; +} + +button span { + font-weight: bold; +} + +@media (max-width: 1180px) { + .inputs { width: 80%; } +} - @media (max-width: 768px) { +@media (max-width: 768px) { + .inputs { width: 85%; } +} - @media (max-width: 450px) { +@media (max-width: 450px) { + .inputs { width: 90%; } -`; - -const CustomDropdown = styled.div` - position: relative; - display: inline-block; - width: 150px; - `; - -const DropdownContent = styled.div` - display: block; - position: absolute; - background-color: #555555; - min-width: 120px; - box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); - z-index: 4; - right: 0; - `; - -const DropdownOption = styled.div` - padding: 12px 16px; - text-decoration: none; - display: block; - cursor: pointer; - &:hover { - background-color: #f1f1f1; - } - `; \ No newline at end of file +} +`; \ No newline at end of file