diff --git a/src/routes/auth/connect.tsx b/src/routes/auth/connect.tsx index 803fb84a..49fef2d6 100644 --- a/src/routes/auth/connect.tsx +++ b/src/routes/auth/connect.tsx @@ -26,7 +26,6 @@ import WalletSwitcher from "~components/popup/WalletSwitcher"; import Wrapper from "~components/auth/Wrapper"; import browser from "webextension-polyfill"; import Label from "~components/auth/Label"; -import Head from "~components/popup/Head"; import App from "~components/auth/App"; import styled from "styled-components"; import { EventType, trackEvent } from "~utils/analytics"; @@ -37,6 +36,7 @@ import { CheckIcon, CloseIcon } from "@iconicicons/react"; import { ToggleSwitch } from "~routes/popup/subscriptions/subscriptionDetails"; import { defaultAllowance } from "~applications/allowance"; import Arweave from "arweave"; +// import Permissions from "../../components/auth/Permissions"; export default function Connect() { // active address @@ -85,6 +85,9 @@ export default function Connect() { // allowance for permissions const [allowanceEnabled, setAllowanceEnabled] = useState(true); + // state management for edit + const [edit, setEdit] = useState(false); + useEffect(() => { (async () => { if (!params) return; @@ -105,9 +108,16 @@ export default function Connect() { setRequestedPermissions( requested.filter((p) => Object.keys(permissionData).includes(p)) ); + setRequetedPermCopy( + requested.filter((p) => Object.keys(permissionData).includes(p)) + ); })(); }, [params]); + const [requestedPermCopy, setRequetedPermCopy] = useState( + [] + ); + // permissions to add const [permissions, setPermissions] = useState([]); @@ -197,9 +207,9 @@ export default function Connect() {
setEdit(false) : cancel} /> )} {page === "permissions" && ( - -
- - {/* {browser.i18n.getMessage("allow_these_permissions")} */} - Bazar wants to connect to your wallet with the following - permissions - - {params.url} - - - App Permissions - Edit Permissions - - - {requestedPermissions.map((permission, i) => ( - - - - {browser.i18n.getMessage( - permissionData[permission.toUpperCase()] - )} - - - ))} - -
Allowance
- -
- {allowanceEnabled && ( - - AR} - type="number" - {...allowanceInput.bindings} - /> - - )} -
-
+ <> + {!edit ? ( + +
+ + {/* {browser.i18n.getMessage("allow_these_permissions")} */} + Bazar wants to connect to your wallet with the following + permissions + + {params.url} + + + App Permissions + { + setEdit(!edit); + }} + > + Edit Permissions + + + + {requestedPermissions.map((permission, i) => ( + + + + {browser.i18n.getMessage( + permissionData[permission.toUpperCase()] + )} + + + ))} + {requestedPermCopy + .filter( + (permission) => + !requestedPermissions.includes(permission) + ) + .map((permission, i) => ( + + + + {browser.i18n.getMessage( + permissionData[permission.toUpperCase()] + )} + + + ))} + + +
Allowance
+ +
+ {allowanceEnabled && ( + + AR} + type="number" + {...allowanceInput.bindings} + /> + + )} +
+
+ ) : ( + <> + {/* */} + + )} + )}
- { - if (page === "unlock") { - await unlock(); - } else { - await connect(); - } - }} - > - {browser.i18n.getMessage(page === "unlock" ? "sign_in" : "connect")} - - - - {browser.i18n.getMessage("cancel")} - + {edit ? ( + setEdit(false)}> + {browser.i18n.getMessage("save")} + + ) : ( + <> + { + if (page === "unlock") { + await unlock(); + } else { + await connect(); + } + }} + > + {browser.i18n.getMessage( + page === "unlock" ? "sign_in" : "connect" + )} + + + + {browser.i18n.getMessage("cancel")} + + + )}
); @@ -335,7 +389,7 @@ const WalletSelectWrapper = styled.div` position: relative; `; -const Permissions = styled.div` +const StyledPermissions = styled.div` padding-bottom: 1rem; `; @@ -384,6 +438,15 @@ const StyledCheckIcon = styled(CheckIcon)` color: rgba(20, 209, 16, 1); `; +const StyledCloseIcon = styled(CloseIcon)` + width: 17px; + height: 17px; + min-width: 17px; + min-height: 17px; + flex-shrink: 0; + color: ${(props) => props.theme.fail}; +`; + const AllowanceInput = styled(InputV2)` &::-webkit-outer-spin-button, &::-webkit-inner-spin-button {