diff --git a/package.json b/package.json index c6d4e222a..bedb24bd3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "react-router-dom": "6.3.0", "regenerator-runtime": "0.13.7", "socket.io-client": "^4.5.2", - "styled-components": "^5.3.5", + "styled-components": "^6.0.8", "tiny-invariant": "^1.2.0", "ts-mocha": "^10.0.0", "tslib": "^2.3.0", diff --git a/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx b/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx index a87a6126f..a589565a6 100644 --- a/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx +++ b/packages/examples/sdk-frontend-react/src/app/ChatSupportTest.tsx @@ -1,6 +1,6 @@ import React, { useContext } from 'react'; import { Web3Provider } from '@ethersproject/providers'; -import { Chat, ITheme } from '@pushprotocol/uiweb'; +import { SupportChat, ITheme } from '@pushprotocol/uiweb'; import { lightTheme } from '@pushprotocol/uiweb'; import { EnvContext, Web3Context } from './context'; @@ -31,10 +31,11 @@ export const ChatSupportTest = () => { }; return ( - { const chatFilterList = [ @@ -15,7 +15,17 @@ const ChatViewComponentTest = () => {

Chat UI Test page

{console.log('in close')}} /> - console.log("BOIIII RETURNNNSSSSS")} chatId='4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68' limit={10} isConnected={true} /> + {console.log('in close')}} modalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} modalPositionType={MODAL_POSITION_TYPE.RELATIVE}/> + + console.log("BOIIII RETURNNNSSSSS")} + chatId='4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68' + limit={10} + isConnected={true} + groupInfoModalBackground={MODAL_BACKGROUND_TYPE.OVERLAY} + groupInfoModalPositionType={MODAL_POSITION_TYPE.RELATIVE} + verificationFailModalPosition={MODAL_POSITION_TYPE.RELATIVE} + /> ); @@ -24,7 +34,8 @@ const ChatViewComponentTest = () => { export default ChatViewComponentTest; const ChatViewComponentCard = styled(Section)` - height: 60vh; + height: 80vh; + position:relative; `; //c2d544ad9d1efd5c5a593b143bf8232875c926cf28015564e70ad078b95f807e //4ac5ab85c9c3d57adbdf2dba79357e56b2f9ef0256befe750d9f93af78d2ca68 diff --git a/packages/examples/sdk-frontend-react/src/app/app.tsx b/packages/examples/sdk-frontend-react/src/app/app.tsx index 98a5bd2c7..e118af2ca 100644 --- a/packages/examples/sdk-frontend-react/src/app/app.tsx +++ b/packages/examples/sdk-frontend-react/src/app/app.tsx @@ -88,6 +88,7 @@ import SearchSpaceTest from './SpaceTest/SearchSpaceTest'; import SearchGroupTest from './ChatTest/SearchGroupTest'; import RejectRequestTest from './ChatTest/RejectRequestTest'; import GetGroupMemberStatusTest from './ChatTest/GetGroupMemberStatusTest'; +import { ChatSupportTest } from './ChatSupportTest'; window.Buffer = window.Buffer || Buffer; @@ -313,7 +314,7 @@ export function App() { - + } - /> + /> } + /> {/* */} {/* */} diff --git a/packages/restapi/CHANGELOG.md b/packages/restapi/CHANGELOG.md index 393b1c1be..ec6aa8d74 100644 --- a/packages/restapi/CHANGELOG.md +++ b/packages/restapi/CHANGELOG.md @@ -2,6 +2,559 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [0.0.1-alpha.50](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.49...restapi-0.0.1-alpha.50) (2023-10-16) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a996249](https://github.com/ethereum-push-notification-service/push-sdk/commit/a996249be88209d5ff7a2fb228ca56bbe294e9c3)) +* Merge branch 'alpha' into alpha-deployment ([119e13a](https://github.com/ethereum-push-notification-service/push-sdk/commit/119e13ac1699a96e977ce84443617f8fdb59f98f)) +* Merge branch 'alpha' into alpha-deployment ([eff31e3](https://github.com/ethereum-push-notification-service/push-sdk/commit/eff31e3dfbbc1f2835366ad5093109d7a5e58b34)) + + + +## [0.0.1-alpha.49](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.48...restapi-0.0.1-alpha.49) (2023-10-10) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([6d965a9](https://github.com/ethereum-push-notification-service/push-sdk/commit/6d965a97a2486e8f4d32f7ae0c4391e4d788935f)) + + + +## [0.0.1-alpha.48](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.47...restapi-0.0.1-alpha.48) (2023-10-10) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([1c9ab5e](https://github.com/ethereum-push-notification-service/push-sdk/commit/1c9ab5e5ce999308dcd2150b3f591eca0293958f)) +* minor fix ([9750680](https://github.com/ethereum-push-notification-service/push-sdk/commit/9750680b7975216297ddf17b5c0bf8075b6ff8d4)) + + + +## [0.0.1-alpha.47](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.46...restapi-0.0.1-alpha.47) (2023-10-09) + + +### Bug Fixes + +* added settings ([8f34995](https://github.com/ethereum-push-notification-service/push-sdk/commit/8f34995d9720bb47be798f2eb54738447d956567)) +* latest pull ([a1caeaf](https://github.com/ethereum-push-notification-service/push-sdk/commit/a1caeaffbc48bbb183d50595e6110bba7baa1fe1)) +* Merge branch 'alpha' into alpha-deployment ([d7251e9](https://github.com/ethereum-push-notification-service/push-sdk/commit/d7251e9b0637d3df59198673e22c42194719d7c1)) +* minor fix ([15d5856](https://github.com/ethereum-push-notification-service/push-sdk/commit/15d58568dd0f71bcf06199ae304d489d96244c34)) + + + +## [0.0.1-alpha.46](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.22...restapi-0.0.1-alpha.46) (2023-10-08) + + +### Bug Fixes + +* added settings ([#762](https://github.com/ethereum-push-notification-service/push-sdk/issues/762)) ([75604d7](https://github.com/ethereum-push-notification-service/push-sdk/commit/75604d7ae3a4dff944cd1dab54cb98ee4d4e07a7)) +* build fix ([299a3be](https://github.com/ethereum-push-notification-service/push-sdk/commit/299a3be9990d58572be1ad111af1b6a0fee17098)) +* merge alpha ([e476962](https://github.com/ethereum-push-notification-service/push-sdk/commit/e476962f26070e0dfd20e5334514eee930eeeaad)) +* merge main ([16dd007](https://github.com/ethereum-push-notification-service/push-sdk/commit/16dd007772a4c5104e336eef318f0056de7a5cfb)) + + + +## [0.0.1-alpha.45](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.44...restapi-0.0.1-alpha.45) (2023-10-05) + + +### Bug Fixes + +* alpha to main ([76a8d84](https://github.com/ethereum-push-notification-service/push-sdk/commit/76a8d849e689793590cf096c794016267503df3d)) +* Merge branch 'alpha' into alpha-deployment ([522814d](https://github.com/ethereum-push-notification-service/push-sdk/commit/522814d67af116576c753ee4c1a2681967a4c11c)) +* Merge branch 'alpha' into alpha-deployment ([fdb3925](https://github.com/ethereum-push-notification-service/push-sdk/commit/fdb3925a9ee63dc747ba227dfb719d784c21592d)) +* Notification event mutation ([ec2aedb](https://github.com/ethereum-push-notification-service/push-sdk/commit/ec2aedbc2e09bc4ded91a9f119464e3a61983606)) +* restored config ([098beac](https://github.com/ethereum-push-notification-service/push-sdk/commit/098beacaebdd19678878c9e50d5b3f103cb39803)) + + + +## [0.0.1-alpha.44](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.43...restapi-0.0.1-alpha.44) (2023-10-03) + + +### Bug Fixes + +* log removed ([68b38e9](https://github.com/ethereum-push-notification-service/push-sdk/commit/68b38e91a1afacb21baa0ee29f8967d86ce4b7f7)) +* minor fix ([c73b6cc](https://github.com/ethereum-push-notification-service/push-sdk/commit/c73b6ccfb510dfc38150a4207f806ccee7b44efb)) + + + +## [0.0.1-alpha.43](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.42...restapi-0.0.1-alpha.43) (2023-09-29) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([0bf9a2d](https://github.com/ethereum-push-notification-service/push-sdk/commit/0bf9a2d6e0e8ff19af34e5e53ee6e05f35bc0479)) + + + +## [0.0.1-alpha.42](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.41...restapi-0.0.1-alpha.42) (2023-09-29) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([6c3b91d](https://github.com/ethereum-push-notification-service/push-sdk/commit/6c3b91d79622e695808e38afb1e5dbdccab2f3eb)) + + + +## [0.0.1-alpha.41](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.40...restapi-0.0.1-alpha.41) (2023-09-29) + + +### Bug Fixes + +* minor fixes ([4338d18](https://github.com/ethereum-push-notification-service/push-sdk/commit/4338d18e07dbb51245331547442014eff2b54707)) + + + +## [0.0.1-alpha.40](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.39...restapi-0.0.1-alpha.40) (2023-09-29) + + +### Bug Fixes + +* minor fixes ([be3e90a](https://github.com/ethereum-push-notification-service/push-sdk/commit/be3e90ae43625eac56cc82548e150a6296a09777)) +* socket enabled ([fa4fc0a](https://github.com/ethereum-push-notification-service/push-sdk/commit/fa4fc0ae78898432232031df85a1ec04cc9027c8)) + + + +## [0.0.1-alpha.39](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.38...restapi-0.0.1-alpha.39) (2023-09-29) + + +### Bug Fixes + +* more fixes ([fe0ad48](https://github.com/ethereum-push-notification-service/push-sdk/commit/fe0ad486338d1cc57508e5ccc1c3b2aeece9624a)) + + + +## [0.0.1-alpha.38](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.37...restapi-0.0.1-alpha.38) (2023-09-29) + + +### Bug Fixes + +* error handling in socket events ([399d1fe](https://github.com/ethereum-push-notification-service/push-sdk/commit/399d1fe396ce19f764c9fc80dea3a3852216837a)) + + + +## [0.0.1-alpha.37](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.36...restapi-0.0.1-alpha.37) (2023-09-29) + + +### Bug Fixes + +* minor fixes ([12e3ca5](https://github.com/ethereum-push-notification-service/push-sdk/commit/12e3ca542aa11f7640ba5b84492707eb6e8bc3fc)) + + + +## [0.0.1-alpha.36](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.21...restapi-0.0.1-alpha.36) (2023-09-29) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([c4d2cff](https://github.com/ethereum-push-notification-service/push-sdk/commit/c4d2cff0d7ecf909ab9dd993f54ffa9f4ce9d7b4)) +* some changes on stream ([92a2202](https://github.com/ethereum-push-notification-service/push-sdk/commit/92a220264e15dad6636b1e7a34ca6f0871849b14)) +* stream cases ([3ca0496](https://github.com/ethereum-push-notification-service/push-sdk/commit/3ca0496396a9796568973376ee99e26b65f1abed)) + + + +## [0.0.1-alpha.35](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.34...restapi-0.0.1-alpha.35) (2023-09-29) + + +### Bug Fixes + +* error fixed ([99163b3](https://github.com/ethereum-push-notification-service/push-sdk/commit/99163b3338940dd9904630007868ca01faf4190c)) +* Merge branch 'alpha' into alpha-deployment ([be03539](https://github.com/ethereum-push-notification-service/push-sdk/commit/be035393a90a50ac2b9115b8f0a817a988f395f9)) +* Merge branch 'alpha' into alpha-deployment ([8d56ee8](https://github.com/ethereum-push-notification-service/push-sdk/commit/8d56ee882719a65391e7e51abfb0b7f86c2ae5ad)) +* Merge branch 'main' into alpha ([b6887db](https://github.com/ethereum-push-notification-service/push-sdk/commit/b6887db0aa76126a47efa6ec88fc9841d7c3ae06)) +* remove only from test ([09524c7](https://github.com/ethereum-push-notification-service/push-sdk/commit/09524c793ecdef095f90c54bc5895ca1c6adba01)) + + + +## [0.0.1-alpha.34](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.33...restapi-0.0.1-alpha.34) (2023-09-27) + + +### Bug Fixes + +* added class based implementation for notification ([#699](https://github.com/ethereum-push-notification-service/push-sdk/issues/699)) ([44f0b7b](https://github.com/ethereum-push-notification-service/push-sdk/commit/44f0b7be1fb568c90c4dfebb7dc61ab82efaddc2)) +* changed typescript 5.0.2 and configured eslint ([8ca7e42](https://github.com/ethereum-push-notification-service/push-sdk/commit/8ca7e4203bcc06886dfe293f8aec5597aec60e5b)) + + + +## [0.0.1-alpha.33](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.19...restapi-0.0.1-alpha.33) (2023-09-07) + + +### Bug Fixes + +* merge alpha ([1783d45](https://github.com/ethereum-push-notification-service/push-sdk/commit/1783d45bb3ceab1cce3c6bb19dfbda38c3662a3e)) +* Merge branch 'alpha' into alpha-deployment ([84aaadf](https://github.com/ethereum-push-notification-service/push-sdk/commit/84aaadfb19e335e5806086fba2ad5e94c1bf3b7e)) +* merge main ([5f37942](https://github.com/ethereum-push-notification-service/push-sdk/commit/5f379427e8a517089758de776eab9f2409aa61f8)) +* merge main ([44e0d32](https://github.com/ethereum-push-notification-service/push-sdk/commit/44e0d324af1d4605129a5e129d3ab6481313c00c)) +* merge main ([9efdbe8](https://github.com/ethereum-push-notification-service/push-sdk/commit/9efdbe8c6f86eeb859075af493797575728cf902)) +* merge main ([93e3106](https://github.com/ethereum-push-notification-service/push-sdk/commit/93e31068bc48e9a271c376d2610e503f69499f8b)) + + + +## [0.0.1-alpha.32](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.31...restapi-0.0.1-alpha.32) (2023-08-17) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([8dd925c](https://github.com/ethereum-push-notification-service/push-sdk/commit/8dd925cd5e0a134e07735b5a3ef7382f4b1909de)) +* Read me fixes ([7c02c3a](https://github.com/ethereum-push-notification-service/push-sdk/commit/7c02c3adef593b59bde6c8dd4d23b760e99a5416)) +* Space rules ([2181074](https://github.com/ethereum-push-notification-service/push-sdk/commit/2181074811549a0c70aea189bc82a1acf1944ba1)) + + + +## [0.0.1-alpha.31](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.30...restapi-0.0.1-alpha.31) (2023-08-16) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a4c170e](https://github.com/ethereum-push-notification-service/push-sdk/commit/a4c170edd7766c843412bd83f6ef7e5a9ab70247)) + + + +## [0.0.1-alpha.30](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.9...restapi-0.0.1-alpha.30) (2023-08-15) + + +### Bug Fixes + +* fixed subscribe and unsubscribe ([3f908a0](https://github.com/ethereum-push-notification-service/push-sdk/commit/3f908a02ce7faee703340e17f6441f3ebe88fd58)) +* Merge branch 'alpha' into alpha-deployment ([984a80f](https://github.com/ethereum-push-notification-service/push-sdk/commit/984a80f178abc220a0243a5fce00413d4dd0aadb)) +* merge main ([f338fd4](https://github.com/ethereum-push-notification-service/push-sdk/commit/f338fd49707933c65bdcc7736cdd08d6784625ba)) +* **merged:** merged ([bb71789](https://github.com/ethereum-push-notification-service/push-sdk/commit/bb717897cec1e7d46d86be05b1d29ca9103272c5)) + + + +## [0.0.1-alpha.29](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.28...restapi-0.0.1-alpha.29) (2023-08-02) + + +### Bug Fixes + +* url correction ([26b6b73](https://github.com/ethereum-push-notification-service/push-sdk/commit/26b6b739d8b6b8a38ae10ae87270ca4d8782db51)) + + + +## [0.0.1-alpha.28](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.4...restapi-0.0.1-alpha.28) (2023-08-02) + + +### Bug Fixes + +* add: scw sig verification ([#593](https://github.com/ethereum-push-notification-service/push-sdk/issues/593)) ([6768065](https://github.com/ethereum-push-notification-service/push-sdk/commit/67680657981a847e23a4dbad6d2fd6a7bc127743)) +* Merge branch 'alpha' into alpha-deployment ([6c19940](https://github.com/ethereum-push-notification-service/push-sdk/commit/6c19940b4d72d9443b8afd06ddc2a6f9e29582a7)) +* merged main ([c5533f8](https://github.com/ethereum-push-notification-service/push-sdk/commit/c5533f8dce7b88cb1f14aa72f83579a8e01dcf36)) + + + +## [0.0.1-alpha.27](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.3...restapi-0.0.1-alpha.27) (2023-07-24) + + +### Bug Fixes + +* merge alpha ([16a55af](https://github.com/ethereum-push-notification-service/push-sdk/commit/16a55af713da0394ab9d82e13fed6d64190b247d)) +* Merge branch 'alpha' into alpha-deployment ([6ea669a](https://github.com/ethereum-push-notification-service/push-sdk/commit/6ea669a5aa3cebe693de259c1ea28787c0407d2a)) +* signer compatibility with viem ([3df201c](https://github.com/ethereum-push-notification-service/push-sdk/commit/3df201c7474b88d270d6e868bc516f223539e74c)) + + + +## [0.0.1-alpha.26](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.2...restapi-0.0.1-alpha.26) (2023-07-21) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([3f3369a](https://github.com/ethereum-push-notification-service/push-sdk/commit/3f3369a1bda71a82cde8ef386901265a62a91a2c)) +* merge main ([c07ce16](https://github.com/ethereum-push-notification-service/push-sdk/commit/c07ce1628321dd3bae46d08e08bfc7986795bb64)) +* signer compatibility with viem and ethers ([1edea43](https://github.com/ethereum-push-notification-service/push-sdk/commit/1edea431ccf7f19cc0430deb2ce7a5c61390d99f)) +* signer compatibility with viem and ethers ([#567](https://github.com/ethereum-push-notification-service/push-sdk/issues/567)) ([c07c3fa](https://github.com/ethereum-push-notification-service/push-sdk/commit/c07c3fab76a095998b1eac830c941116ad1e9b4f)) +* space feed API path fix ([00d91b1](https://github.com/ethereum-push-notification-service/push-sdk/commit/00d91b1860525c15618f130970c9173100424a23)) +* use SpaceIFeeds ([5b7f2fc](https://github.com/ethereum-push-notification-service/push-sdk/commit/5b7f2fc2398a2203925059aa2721e855ea9f98d4)) + + + +## [0.0.1-alpha.25](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.4.1...restapi-0.0.1-alpha.25) (2023-07-19) + + +### Bug Fixes + +* fixed merge conflicts ([dfab492](https://github.com/ethereum-push-notification-service/push-sdk/commit/dfab492127e821219c5fd5dc08ed08a172bee31b)) +* Merge branch 'alpha' into alpha-deployment ([a71302b](https://github.com/ethereum-push-notification-service/push-sdk/commit/a71302b4a5066cb9d00ca5d14e55228c558eda85)) +* Merge branch 'main' into alpha-deployment ([fe93d43](https://github.com/ethereum-push-notification-service/push-sdk/commit/fe93d43a103d5067b16d8f7a5d01835be1d1f40a)) +* renamed spaces variables and removed some unused variables ([3519d39](https://github.com/ethereum-push-notification-service/push-sdk/commit/3519d3982be389711f48891896478b7a35a71b73)) +* space api ([064e10d](https://github.com/ethereum-push-notification-service/push-sdk/commit/064e10d9c66ab1d39f799fd64a39652862b2f074)) + + + +## [0.0.1-alpha.24](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.23...restapi-0.0.1-alpha.24) (2023-07-14) + + +### Bug Fixes + +* rename chats to spaces ([899eb21](https://github.com/ethereum-push-notification-service/push-sdk/commit/899eb212af29e3a65541686d98927e37b97927c5)) + + + +## [0.0.1-alpha.23](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.22...restapi-0.0.1-alpha.23) (2023-07-12) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([b120e30](https://github.com/ethereum-push-notification-service/push-sdk/commit/b120e302f6b9f8e360b43f80dcdd3248c1e4304b)) +* Merge branch 'alpha' into alpha-deployment ([54c5721](https://github.com/ethereum-push-notification-service/push-sdk/commit/54c57219c7f3f198a3f7578a0720895aff2d27f4)) +* Merge branch 'main' into alpha ([7b316ec](https://github.com/ethereum-push-notification-service/push-sdk/commit/7b316ec8e6f3178c02e7fce6d27884ba8ef1b4f4)) +* Merge branch 'main' into alpha ([d66202d](https://github.com/ethereum-push-notification-service/push-sdk/commit/d66202d0798b9ec731d7f5d30031b89ae29d72b4)) + + + +## [0.0.1-alpha.22](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.21...restapi-0.0.1-alpha.22) (2023-07-07) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([5c84e2f](https://github.com/ethereum-push-notification-service/push-sdk/commit/5c84e2f07667fe4e9d94561544807b11c103ac49)) +* merged maain ([942cc65](https://github.com/ethereum-push-notification-service/push-sdk/commit/942cc65a60aa043054cebb143990711fb6e2efdb)) + + + +## [0.0.1-alpha.21](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.20...restapi-0.0.1-alpha.21) (2023-07-07) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([c05d024](https://github.com/ethereum-push-notification-service/push-sdk/commit/c05d024415bb1cb9e1fe59714d7db5516d161c06)) +* merged main ([46cf04e](https://github.com/ethereum-push-notification-service/push-sdk/commit/46cf04e75c314065c77a5a77d9351d9ccc7e0a58)) +* spaces naming ([6db7fc0](https://github.com/ethereum-push-notification-service/push-sdk/commit/6db7fc09b680060f022040feb2a22aeed9c652d0)) + + + +## [0.0.1-alpha.20](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.19...restapi-0.0.1-alpha.20) (2023-07-03) + + +### Bug Fixes + +* new commit ([25f2725](https://github.com/ethereum-push-notification-service/push-sdk/commit/25f2725efb0e1017ee2a0460259b27f252471014)) + + + +## [0.0.1-alpha.19](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.3.9...restapi-0.0.1-alpha.19) (2023-07-03) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a15e368](https://github.com/ethereum-push-notification-service/push-sdk/commit/a15e368241215e2e2219792afd718567d621bf2a)) +* merge main ([6998d35](https://github.com/ethereum-push-notification-service/push-sdk/commit/6998d35aa181f17a5ad8d9501943a6a867814650)) +* rename based on new convention ([0e34479](https://github.com/ethereum-push-notification-service/push-sdk/commit/0e34479b1581abd59e0f853d6547e23a0afb5e28)) + + + +## [0.0.1-alpha.18](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.3.8...restapi-0.0.1-alpha.18) (2023-06-20) + + +### Bug Fixes + +* add name to SpaceIFeeds ([9c22271](https://github.com/ethereum-push-notification-service/push-sdk/commit/9c222715d0f15ae912b90661f9d18d42bddc4c89)) +* Merge branch 'alpha' into alpha-deployment ([b521522](https://github.com/ethereum-push-notification-service/push-sdk/commit/b521522c3b147b789a03b2683da4b6cefac795fe)) +* Merge branch 'main' into alpha ([64de06f](https://github.com/ethereum-push-notification-service/push-sdk/commit/64de06fc3cfd4359cf0d7fb70212e775ce9e51b9)) +* merge main ([27105a2](https://github.com/ethereum-push-notification-service/push-sdk/commit/27105a247fe4bd4db78a41be06ef6a2d52fb6b21)) +* update path ([10d62b1](https://github.com/ethereum-push-notification-service/push-sdk/commit/10d62b1a017b3d0a5044a4ab33bdce183f795f51)) + + + +## [0.0.1-alpha.17](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.3.5...restapi-0.0.1-alpha.17) (2023-06-08) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a9d8ff1](https://github.com/ethereum-push-notification-service/push-sdk/commit/a9d8ff18bcad950e40b966e5b4020e29b493aa28)) +* merge main ([78c020a](https://github.com/ethereum-push-notification-service/push-sdk/commit/78c020ac61decc2d3b78d3749c8ec5df7478842f)) +* **video:** fix error on repeated acceptRequest calls ([#442](https://github.com/ethereum-push-notification-service/push-sdk/issues/442)) ([f34bfa0](https://github.com/ethereum-push-notification-service/push-sdk/commit/f34bfa09cf88e812e07c0dcf7fabf792726c577f)) + + + +## [0.0.1-alpha.16](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.3.3...restapi-0.0.1-alpha.16) (2023-06-02) + + +### Bug Fixes + +* add spaces for functions ([#307](https://github.com/ethereum-push-notification-service/push-sdk/issues/307)) ([aea015a](https://github.com/ethereum-push-notification-service/push-sdk/commit/aea015ae478da77ebaa41a4e111ac213027b0b6a)) +* Merge branch 'alpha' into alpha-deployment ([ad6a56b](https://github.com/ethereum-push-notification-service/push-sdk/commit/ad6a56be24c326b7fb1f6eddb01b20b489eee27d)) +* merge main ([3959345](https://github.com/ethereum-push-notification-service/push-sdk/commit/39593456140e152e53f4bd7c10a19e0d8f05dfc9)) + + + +## [0.0.1-alpha.15](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.3.2...restapi-0.0.1-alpha.15) (2023-05-29) + + +### Bug Fixes + +* fix nft videocall ([#411](https://github.com/ethereum-push-notification-service/push-sdk/issues/411)) ([8cdb999](https://github.com/ethereum-push-notification-service/push-sdk/commit/8cdb999bc548caf67ec6fbe625253b5795a4e465)) +* Iuser structure changed ([#365](https://github.com/ethereum-push-notification-service/push-sdk/issues/365)) ([2fc6f54](https://github.com/ethereum-push-notification-service/push-sdk/commit/2fc6f549c80a65a5a6009b0c2fa9635d757bdf11)), closes [#390](https://github.com/ethereum-push-notification-service/push-sdk/issues/390) [#295](https://github.com/ethereum-push-notification-service/push-sdk/issues/295) +* Merge branch 'alpha' into alpha-deployment ([a66c9a4](https://github.com/ethereum-push-notification-service/push-sdk/commit/a66c9a4a3628700a450b8e2fb7a5f942d1d84095)) +* Merge branch 'alpha' into alpha-deployment ([f247665](https://github.com/ethereum-push-notification-service/push-sdk/commit/f2476650b650ade59721c30f6e8483e86c013cd4)) +* merged main to alpha ([067bc5d](https://github.com/ethereum-push-notification-service/push-sdk/commit/067bc5d358c5f218628a980ce23ab3b39615805f)) + + + +## [0.0.1-alpha.13](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.12...restapi-0.0.1-alpha.13) (2023-05-19) + + +### Bug Fixes + +* backward compatiblity fix ([fbf2463](https://github.com/ethereum-push-notification-service/push-sdk/commit/fbf246396a44513626fc1dda6e90c12d2f073ead)) +* Merge branch 'alpha' into alpha-deployment ([3b5a0f1](https://github.com/ethereum-push-notification-service/push-sdk/commit/3b5a0f160b72e775cf17031067fa7488171e1bbd)) + + + +## [0.0.1-alpha.12](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.11...restapi-0.0.1-alpha.12) (2023-05-19) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([963cc02](https://github.com/ethereum-push-notification-service/push-sdk/commit/963cc02768862b6a9427519257ff9f9565f613ea)) +* **video:** fix enableAudio ([85ef733](https://github.com/ethereum-push-notification-service/push-sdk/commit/85ef733127bdfbae5c66c671ddc7700785d192c0)) + + + +## [0.0.1-alpha.11](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.10...restapi-0.0.1-alpha.11) (2023-05-19) + + +### Bug Fixes + +* added enums ([f1880d8](https://github.com/ethereum-push-notification-service/push-sdk/commit/f1880d8f037fc640851af4311bd5e514de5cf3db)) +* changed additionalMeta structure ([#406](https://github.com/ethereum-push-notification-service/push-sdk/issues/406)) ([0cf573e](https://github.com/ethereum-push-notification-service/push-sdk/commit/0cf573e56165bf3164a42cbc4b41a3085801e90a)) +* fix versions ([05c8fa9](https://github.com/ethereum-push-notification-service/push-sdk/commit/05c8fa9f9286e78d706c6be53e7b8ae963105766)) +* Merge branch 'alpha' into alpha-deployment ([68f11eb](https://github.com/ethereum-push-notification-service/push-sdk/commit/68f11eb71d44423081000c00c36cb0a936558f2f)) +* Merge branch 'alpha' into alpha-deployment ([3700515](https://github.com/ethereum-push-notification-service/push-sdk/commit/3700515be010fdcab6062db0a039f7df612a7a6b)) +* Merge branch 'alpha' into alpha-deployment ([925b437](https://github.com/ethereum-push-notification-service/push-sdk/commit/925b4379aa7b7d2d061b23d5ccbc42d06829f100)) +* **sendvideonotifications:** modify additional meta acc to new std ([#407](https://github.com/ethereum-push-notification-service/push-sdk/issues/407)) ([9d2124a](https://github.com/ethereum-push-notification-service/push-sdk/commit/9d2124aa61f798a0b137636aac62397e1e52150e)) +* **types:** remove bad import ([5517200](https://github.com/ethereum-push-notification-service/push-sdk/commit/55172002a2cecb33407a3828c2debeca24e0c972)) +* **video:** remove stop audio/video logic from create function ([#404](https://github.com/ethereum-push-notification-service/push-sdk/issues/404)) ([983c896](https://github.com/ethereum-push-notification-service/push-sdk/commit/983c896a2c89463f117f5a4d8153ef95501f2124)) + + +### Reverts + +* **getverificationproof:** add wallet and env params to getVerificationProof ([#403](https://github.com/ethereum-push-notification-service/push-sdk/issues/403)) ([26f6fcb](https://github.com/ethereum-push-notification-service/push-sdk/commit/26f6fcb9b2992850cd33ea613cea13830bd48bc3)) + + + +## [0.0.1-alpha.10](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.9...restapi-0.0.1-alpha.10) (2023-05-17) + + +### Bug Fixes + +* added deprecated info to history ([#399](https://github.com/ethereum-push-notification-service/push-sdk/issues/399)) ([eda1a34](https://github.com/ethereum-push-notification-service/push-sdk/commit/eda1a345975141c5656891dbf919aacd2924d66b)) +* Merge branch 'alpha' into alpha-deployment ([46ebed2](https://github.com/ethereum-push-notification-service/push-sdk/commit/46ebed2b9d4b4ff0518429a091d0a37b1d3f022d)) + + + +## [0.0.1-alpha.9](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.8...restapi-0.0.1-alpha.9) (2023-05-16) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([469398d](https://github.com/ethereum-push-notification-service/push-sdk/commit/469398dc94df805257d6a6bb8e0707cebc5f7d8a)) +* **video:** turn off trickle while creating peer instance ([#398](https://github.com/ethereum-push-notification-service/push-sdk/issues/398)) ([ae5b38e](https://github.com/ethereum-push-notification-service/push-sdk/commit/ae5b38e702539eaf92a516b4e557c5a88de0f4c7)) + + + +## [0.0.1-alpha.8](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.7...restapi-0.0.1-alpha.8) (2023-05-16) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([549fd83](https://github.com/ethereum-push-notification-service/push-sdk/commit/549fd839867d84a98a10206a7f9945aeb1720e49)) +* Merge branch 'main' into alpha ([72464fd](https://github.com/ethereum-push-notification-service/push-sdk/commit/72464fd97260b612649035e3b241f946de8f9e92)) +* **video:** set trickle to true while creating peer instance ([#397](https://github.com/ethereum-push-notification-service/push-sdk/issues/397)) ([0b609be](https://github.com/ethereum-push-notification-service/push-sdk/commit/0b609bec87a6187d1e7cbf8052a2b9a36b9fcd7a)) + + + +## [0.0.1-alpha.7](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.6...restapi-0.0.1-alpha.7) (2023-05-15) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([37c1c8d](https://github.com/ethereum-push-notification-service/push-sdk/commit/37c1c8db579876f5835c2e5bb5e6baf073dc9208)) +* **video:** remove status change upon connect in request ([#394](https://github.com/ethereum-push-notification-service/push-sdk/issues/394)) ([7441ef0](https://github.com/ethereum-push-notification-service/push-sdk/commit/7441ef0fb2c9ed39e12a4f1819ade0ee7e0d6b10)) + + + +## [0.0.1-alpha.6](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.5...restapi-0.0.1-alpha.6) (2023-05-14) + + +### Bug Fixes + +* add video call retry logic upon error & doc: add video call in restapi/readme ([#391](https://github.com/ethereum-push-notification-service/push-sdk/issues/391)) ([9c8c86b](https://github.com/ethereum-push-notification-service/push-sdk/commit/9c8c86b35d1cb0300d0170e87931dd31a15f9342)) + + + +## [0.0.1-alpha.5](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.4...restapi-0.0.1-alpha.5) (2023-05-14) + + + +## [0.0.1-alpha.4](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.2.15...restapi-0.0.1-alpha.4) (2023-05-12) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a1a8666](https://github.com/ethereum-push-notification-service/push-sdk/commit/a1a86661b1823c84328ec90ac9aafc6c57f574f3)) +* Merge branch 'main' into alpha ([5fc51db](https://github.com/ethereum-push-notification-service/push-sdk/commit/5fc51db1a336203048b4b42a5384cb37cf79c509)) +* **video:** separate react state from video class instance variable data ([#389](https://github.com/ethereum-push-notification-service/push-sdk/issues/389)) ([83bf445](https://github.com/ethereum-push-notification-service/push-sdk/commit/83bf4457332b127bf9e41a2f4c93fb851367724d)) + + + +## [0.0.1-alpha.3](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.2...restapi-0.0.1-alpha.3) (2023-05-11) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([e19b9b0](https://github.com/ethereum-push-notification-service/push-sdk/commit/e19b9b05b60174e68dc7bfe0e2349e20d8af2604)) +* Replace arrow functions with normal functions in the Video class ([#380](https://github.com/ethereum-push-notification-service/push-sdk/issues/380)) ([b90435a](https://github.com/ethereum-push-notification-service/push-sdk/commit/b90435a953b908899c92eb5b4d4c3677e47b1552)) + + + +## [0.0.1-alpha.2](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-1.2.13...restapi-0.0.1-alpha.2) (2023-05-10) + + +### Bug Fixes + +* merge alpha ([7f0642c](https://github.com/ethereum-push-notification-service/push-sdk/commit/7f0642c4c417390a5bb52d36d9493bd5b767b634)) +* merge main ([a5fdfe1](https://github.com/ethereum-push-notification-service/push-sdk/commit/a5fdfe10f18c857c32aa5fe5c5dd95db0f268cd1)) +* merge main to alpha ([4866a37](https://github.com/ethereum-push-notification-service/push-sdk/commit/4866a37ed0502c0d16ac91f088d3bb5e597b652a)) + + + +## [0.0.1-alpha.1](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.0...restapi-0.0.1-alpha.1) (2023-05-08) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([1223c60](https://github.com/ethereum-push-notification-service/push-sdk/commit/1223c60b0f179b26537992a776155aefffd7b5ef)) +* sendVideoNotification and end video call logic ([#367](https://github.com/ethereum-push-notification-service/push-sdk/issues/367)) ([d39c703](https://github.com/ethereum-push-notification-service/push-sdk/commit/d39c703bcda6d332717a5e9b1af6ab574be9d991)) + + + +## [0.0.1-alpha.0](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-beta.2...restapi-0.0.1-alpha.0) (2023-05-04) + + +### Bug Fixes + +* added pagination and deprecation tag ([#346](https://github.com/ethereum-push-notification-service/push-sdk/issues/346)) ([69763b8](https://github.com/ethereum-push-notification-service/push-sdk/commit/69763b8da2cf3e92bb85908e4f46a72b650c9dba)) +* changed Definitions for auth.update and upgrade ([#351](https://github.com/ethereum-push-notification-service/push-sdk/issues/351)) ([31daee3](https://github.com/ethereum-push-notification-service/push-sdk/commit/31daee3a5aa913705d1dec8210c0412cd89c94c9)) +* eip191v2 signatures for create and auth.update ([#353](https://github.com/ethereum-push-notification-service/push-sdk/issues/353)) ([008e6d0](https://github.com/ethereum-push-notification-service/push-sdk/commit/008e6d08d75fdacf19f1674cc2b8bd82091fa31f)) +* Merge branch 'main' into alpha ([477bae4](https://github.com/ethereum-push-notification-service/push-sdk/commit/477bae4fdc4e86374615f0f67c41c570a567b9fe)) + + + +## [0.0.1-alpha.45](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.44...restapi-0.0.1-alpha.45) (2023-10-05) + + +### Bug Fixes + +* alpha to main ([76a8d84](https://github.com/ethereum-push-notification-service/push-sdk/commit/76a8d849e689793590cf096c794016267503df3d)) +* local tests ([#744](https://github.com/ethereum-push-notification-service/push-sdk/issues/744)) ([e6ac9dc](https://github.com/ethereum-push-notification-service/push-sdk/commit/e6ac9dc896e710213d74e715da8af971c10b5e29)) +* Merge branch 'alpha' into alpha-deployment ([522814d](https://github.com/ethereum-push-notification-service/push-sdk/commit/522814d67af116576c753ee4c1a2681967a4c11c)) +* Merge branch 'alpha' into alpha-deployment ([fdb3925](https://github.com/ethereum-push-notification-service/push-sdk/commit/fdb3925a9ee63dc747ba227dfb719d784c21592d)) +* Notification event mutation ([ec2aedb](https://github.com/ethereum-push-notification-service/push-sdk/commit/ec2aedbc2e09bc4ded91a9f119464e3a61983606)) +* restored config ([098beac](https://github.com/ethereum-push-notification-service/push-sdk/commit/098beacaebdd19678878c9e50d5b3f103cb39803)) + + + ## [0.0.1-alpha.44](https://github.com/ethereum-push-notification-service/push-sdk/compare/restapi-0.0.1-alpha.43...restapi-0.0.1-alpha.44) (2023-10-03) diff --git a/packages/restapi/package.json b/packages/restapi/package.json index 7d07fba25..ebc92f5d0 100644 --- a/packages/restapi/package.json +++ b/packages/restapi/package.json @@ -1,6 +1,6 @@ { "name": "@pushprotocol/restapi", - "version": "1.4.22", + "version": "0.0.1-alpha.50", "type": "commonjs", "publishConfig": { "registry": "https://registry.npmjs.org/" diff --git a/packages/restapi/src/lib/space/acceptPromotionRequest.ts b/packages/restapi/src/lib/space/acceptPromotionRequest.ts index 6ed125b25..c37c5e3b7 100644 --- a/packages/restapi/src/lib/space/acceptPromotionRequest.ts +++ b/packages/restapi/src/lib/space/acceptPromotionRequest.ts @@ -1,11 +1,15 @@ +import { produce } from 'immer'; + import type Space from './Space'; import { addSpeakers } from './addSpeakers'; +import sendLiveSpaceData from './helpers/sendLiveSpaceData'; import { pCAIP10ToWallet } from '../helpers'; import { SPACE_ACCEPT_REQUEST_TYPE, SPACE_INVITE_ROLES, } from '../payloads/constants'; +import { CHAT } from '../types'; export interface IAcceptPromotionRequestType { signalData: any; @@ -35,6 +39,35 @@ export async function acceptPromotionRequest( env: this.env, }); + const modifiedLiveSpaceData = produce( + this.spaceSpecificData.liveSpaceData, + (draft) => { + const listenerIndex = + this.spaceSpecificData.liveSpaceData.listeners.findIndex( + (listener) => + pCAIP10ToWallet(listener.address) === + pCAIP10ToWallet(promoteeAddress) + ); + + draft.listeners.splice(listenerIndex, 1); + + draft.speakers.push({ + address: pCAIP10ToWallet(promoteeAddress), + emojiReactions: null, + audio: null, + }); + } + ); + + await sendLiveSpaceData({ + spaceId: this.spaceSpecificData.spaceId, + pgpPrivateKey: this.pgpPrivateKey, + env: this.env, + signer: this.signer, + liveSpaceData: modifiedLiveSpaceData, + action: CHAT.META.SPACE.SPEAKER.PRVILEGE, + }); + // accept the promotion request // this.acceptRequest({ // signalData, diff --git a/packages/uiweb/CHANGELOG.md b/packages/uiweb/CHANGELOG.md index fc461f033..90ffe6c03 100644 --- a/packages/uiweb/CHANGELOG.md +++ b/packages/uiweb/CHANGELOG.md @@ -2,6 +2,164 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [0.0.1-alpha.29](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.28...uiweb-0.0.1-alpha.29) (2023-11-07) + + +### Bug Fixes + +* added alias to support chat ([#821](https://github.com/ethereum-push-notification-service/push-sdk/issues/821)) ([cbd0bbd](https://github.com/ethereum-push-notification-service/push-sdk/commit/cbd0bbd15d9269c3dee9b257e6a3c6adafc7e206)) +* Merge branch 'alpha' into alpha-deployment ([247f0f2](https://github.com/ethereum-push-notification-service/push-sdk/commit/247f0f22bd7b814807ba4b98d11351c114e156f6)) + + + +## [0.0.1-alpha.28](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.27...uiweb-0.0.1-alpha.28) (2023-11-03) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([bf0510a](https://github.com/ethereum-push-notification-service/push-sdk/commit/bf0510aa1a299e2d90af01735882fac1e7821f5d)) + + +### Features + +* added some more default patterns for markdown ([#817](https://github.com/ethereum-push-notification-service/push-sdk/issues/817)) ([838b5f2](https://github.com/ethereum-push-notification-service/push-sdk/commit/838b5f242ab92fb958a8da30ead6bed034e5525c)) + + + +## [0.0.1-alpha.27](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.26...uiweb-0.0.1-alpha.27) (2023-11-03) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([eac8df1](https://github.com/ethereum-push-notification-service/push-sdk/commit/eac8df177d358254221666bd0b23d5d982b93167)) + + + +## [0.0.1-alpha.26](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.25...uiweb-0.0.1-alpha.26) (2023-11-02) + + +### Bug Fixes + +* merge alpha ([745c3d6](https://github.com/ethereum-push-notification-service/push-sdk/commit/745c3d6fdffce621c0e14252c1d926384d959246)) +* Merge branch 'alpha' into alpha-deployment ([394010d](https://github.com/ethereum-push-notification-service/push-sdk/commit/394010d5b0d947abea5efa4fab1de332c621d9b7)) +* replaced hardcoded access failed msg with actual conditions ([#812](https://github.com/ethereum-push-notification-service/push-sdk/issues/812)) ([035c784](https://github.com/ethereum-push-notification-service/push-sdk/commit/035c784d649f878f76b4b56ef7f4a908bd33b419)) + + + +## [0.0.1-alpha.25](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.24...uiweb-0.0.1-alpha.25) (2023-10-31) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a4ca4dc](https://github.com/ethereum-push-notification-service/push-sdk/commit/a4ca4dc0ac1424741642f0afa55dc6ac581af3ab)) + + + +## [0.0.1-alpha.25](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.24...uiweb-0.0.1-alpha.25) (2023-10-31) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([a4ca4dc](https://github.com/ethereum-push-notification-service/push-sdk/commit/a4ca4dc0ac1424741642f0afa55dc6ac581af3ab)) + + + +## [0.0.1-alpha.24](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.23...uiweb-0.0.1-alpha.24) (2023-10-25) + + +### Bug Fixes + +* fixed horizontal alignment of group info and fixed icon on connect button modal ([#804](https://github.com/ethereum-push-notification-service/push-sdk/issues/804)) ([982da0d](https://github.com/ethereum-push-notification-service/push-sdk/commit/982da0de8826380ce6c048ce9689c1ecb7c8efbc)) +* Merge branch 'alpha' into alpha-deployment ([11edd78](https://github.com/ethereum-push-notification-service/push-sdk/commit/11edd786f40bd7cfc69d9a859901b03625d410fb)) + + + +## [0.0.1-alpha.23](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.22...uiweb-0.0.1-alpha.23) (2023-10-24) + + + +## [0.0.1-alpha.22](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.21...uiweb-0.0.1-alpha.22) (2023-10-19) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([c46ab7e](https://github.com/ethereum-push-notification-service/push-sdk/commit/c46ab7e07950e72310047a0a16f63fd01fd32a02)) +* Merge branch 'alpha' into alpha-deployment ([5c1a194](https://github.com/ethereum-push-notification-service/push-sdk/commit/5c1a194b3a44b2f486b392e4e02c9fd711351864)) + + + +## [0.0.1-alpha.21](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.20...uiweb-0.0.1-alpha.21) (2023-10-16) + + +### Bug Fixes + +* fixed lint issues in chat ([#784](https://github.com/ethereum-push-notification-service/push-sdk/issues/784)) ([0c71905](https://github.com/ethereum-push-notification-service/push-sdk/commit/0c719052a873c1c2aceefbd801f672542ba9ec69)) +* Merge branch 'alpha' into alpha-deployment ([ff9e92c](https://github.com/ethereum-push-notification-service/push-sdk/commit/ff9e92c5dda229af26be8f858b05579e7f366057)) +* Merge branch 'alpha' into alpha-deployment ([a996249](https://github.com/ethereum-push-notification-service/push-sdk/commit/a996249be88209d5ff7a2fb228ca56bbe294e9c3)) + + + +## [0.0.1-alpha.20](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.19...uiweb-0.0.1-alpha.20) (2023-10-13) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([de2303a](https://github.com/ethereum-push-notification-service/push-sdk/commit/de2303a76da0057f6ad0bd191c7ddd520f40b037)) +* ui fixes for lk ([#782](https://github.com/ethereum-push-notification-service/push-sdk/issues/782)) ([5f49fac](https://github.com/ethereum-push-notification-service/push-sdk/commit/5f49fac6d88f7745609e41df89f05851aa046025)) + + + +## [0.0.1-alpha.19](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.18...uiweb-0.0.1-alpha.19) (2023-10-12) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([eff31e3](https://github.com/ethereum-push-notification-service/push-sdk/commit/eff31e3dfbbc1f2835366ad5093109d7a5e58b34)) + + + +## [0.0.1-alpha.18](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.17...uiweb-0.0.1-alpha.18) (2023-10-10) + + +### Bug Fixes + +* merge alpha ([e476962](https://github.com/ethereum-push-notification-service/push-sdk/commit/e476962f26070e0dfd20e5334514eee930eeeaad)) +* Merge branch 'alpha' into alpha-deployment ([6d965a9](https://github.com/ethereum-push-notification-service/push-sdk/commit/6d965a97a2486e8f4d32f7ae0c4391e4d788935f)) +* merge main ([16dd007](https://github.com/ethereum-push-notification-service/push-sdk/commit/16dd007772a4c5104e336eef318f0056de7a5cfb)) +* merge main ([902194c](https://github.com/ethereum-push-notification-service/push-sdk/commit/902194cd30f9b83891b6e3dde8c39ddddacc876e)) + + + +## [1.1.14](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.15...uiweb-1.1.14) (2023-10-03) + + +### Bug Fixes + +* Merge branch 'main' into deployment ([afdc6f8](https://github.com/ethereum-push-notification-service/push-sdk/commit/afdc6f8669dd0cd9ece859f4c8f6dc4181872e2c)) +* Merge branch 'main' into deployment ([f9bb113](https://github.com/ethereum-push-notification-service/push-sdk/commit/f9bb113702f47132dc512910e5060286e985f4bf)) + + + +## [0.0.1-alpha.17](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.16...uiweb-0.0.1-alpha.17) (2023-10-05) + + +### Bug Fixes + +* Merge branch 'alpha' into alpha-deployment ([95c84a5](https://github.com/ethereum-push-notification-service/push-sdk/commit/95c84a58e2e4f21465ccd21c29d82b3ace594f0d)) + + + +## [0.0.1-alpha.16](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.15...uiweb-0.0.1-alpha.16) (2023-10-05) + + +### Bug Fixes + +* alpha to main ([76a8d84](https://github.com/ethereum-push-notification-service/push-sdk/commit/76a8d849e689793590cf096c794016267503df3d)) +* fixed typo ([3c6b14d](https://github.com/ethereum-push-notification-service/push-sdk/commit/3c6b14d1ae68ce74c91864d898e3d646898655bb)) +* minor fixes ([6737403](https://github.com/ethereum-push-notification-service/push-sdk/commit/6737403738dd70ad4056f9d10b4ab363fc172094)) + + + ## [0.0.1-alpha.15](https://github.com/ethereum-push-notification-service/push-sdk/compare/uiweb-0.0.1-alpha.14...uiweb-0.0.1-alpha.15) (2023-09-25) diff --git a/packages/uiweb/package.json b/packages/uiweb/package.json index 0bfdce8e0..fbd33cd9a 100644 --- a/packages/uiweb/package.json +++ b/packages/uiweb/package.json @@ -1,6 +1,6 @@ { "name": "@pushprotocol/uiweb", - "version": "0.0.1-alpha.15", + "version": "0.0.1-alpha.29", "publishConfig": { "registry": "https://registry.npmjs.org/" }, @@ -25,6 +25,8 @@ "livekit-client": "^1.13.3", "moment": "^2.29.4", "react-icons": "^4.10.1", + "react-easy-crop": "^4.1.4", + "react-image-file-resizer": "^0.4.7", "react-toastify": "^9.1.3", "react-twitter-embed": "^4.0.4", "uuid": "^9.0.1" @@ -33,6 +35,6 @@ "@pushprotocol/restapi": "^1.2.15", "@pushprotocol/socket": "^0.5.0", "react": ">=16.8.0", - "styled-components": "^5.3.5" + "styled-components": "^6.0.8" } } diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/AddWalletContent.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/AddWalletContent.tsx index dd8d4f64d..e99062b39 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/AddWalletContent.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/AddWalletContent.tsx @@ -17,7 +17,7 @@ import useToast from '../reusables/NewToast'; import { getNewChatUser, } from '../../../helpers'; -import { ModalButtonProps, User } from '../exportedTypes'; +import { IChatTheme, ModalButtonProps, User } from '../exportedTypes'; import { addWalletValidation } from '../helpers/helper'; import { device } from '../../../config'; import CloseIcon from '../../../icons/close.svg'; @@ -44,7 +44,6 @@ export const AddWalletContent = ({ handleMemberList, groupMembers, isLoading, - modalHeader, }: AddWalletContentProps) => { const theme = useContext(ThemeContext); @@ -119,6 +118,7 @@ export const AddWalletContent = ({ return (
` +const ModalConfirmButton = styled.button` margin: 60px 0 0 0; width: 197px; background: ${(props) => - props.memberListCount ? props.theme.backgroundColor.buttonBackground : props.theme.backgroundColor.buttonDisableBackground}; + props.memberListCount ? props.theme.backgroundColor!.buttonBackground : props.theme.backgroundColor!.buttonDisableBackground}; color: ${(props) => - props.memberListCount ? props.theme.textColor.buttonText : props.theme.textColor.buttonDisableText}; + props.memberListCount ? props.theme.textColor!.buttonText : props.theme.textColor!.buttonDisableText}; border: ${(props) => - props.memberListCount ? 'none' : props.theme.border.modal}; + props.memberListCount ? 'none' : props.theme.border!.modal}; min-width: 50%; box-sizing: border-box; cursor: pointer; diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx index fa6d4e27b..e47d24135 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx @@ -20,114 +20,27 @@ import 'react-toastify/dist/ReactToastify.min.css'; import { IGroup } from '../../../types'; import { isValidETHAddress } from '../helpers/helper'; -import { IChatProfile, IChatTheme } from '../exportedTypes'; +import { + IChatProfile, + MODAL_BACKGROUND_TYPE, + MODAL_POSITION_TYPE, + +} from '../exportedTypes'; import { InfuraAPIKey, allowedNetworks, device } from '../../../config'; import { resolveNewEns, shortenText } from '../../../helpers'; -import TokenGatedIcon from '../../../icons/TokenGatedIcon.svg'; + import PublicChatIcon from '../../../icons/Public-Chat.svg'; import GreyImage from '../../../icons/greyImage.png'; import InfoIcon from '../../../icons/infodark.svg'; import VerticalEllipsisIcon from '../../../icons/VerticalEllipsis.svg'; +import { TokenGatedSvg } from '../../../icons/TokenGatedSvg'; -type OptionProps = { - options: boolean; - setOptions: React.Dispatch>; - isGroup: boolean; - groupInfo: IGroup | null | undefined; - setGroupInfo: React.Dispatch>; - theme: IChatTheme; -}; - -const Options = ({ - options, - setOptions, - isGroup, - groupInfo, - setGroupInfo, - theme, -}: OptionProps) => { - const DropdownRef = useRef(null); - const [modal, setModal] = useState(false); - - useClickAway(DropdownRef, () => { - setOptions(false); - }); - - const ShowModal = () => { - setModal(true); - }; - - if (groupInfo && isGroup) { - return ( -
- {/* {(groupInfo?.rules?.chat?.conditions || groupInfo.rules?.entry?.conditions) && ( - - )} */} - - - setOptions(true)}> - - - {options && ( - - - - - Group Info - - - )} - - {modal && ( - - )} - -
- ); - } else { - return null; - } -}; - export const ChatProfile: React.FC = ({ chatId, style, -}: { - chatId: string; - style: 'Info' | 'Preview'; + groupInfoModalBackground = MODAL_BACKGROUND_TYPE.OVERLAY, + groupInfoModalPositionType = MODAL_POSITION_TYPE.GLOBAL, }) => { const theme = useContext(ThemeContext); const { account, env } = useChatData(); @@ -142,6 +55,16 @@ export const ChatProfile: React.FC = ({ const isMobile = useMediaQuery(device.tablet); const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5; const provider = new ethers.providers.InfuraProvider(l1ChainId, InfuraAPIKey); + const DropdownRef = useRef(null); + const [modal, setModal] = useState(false); + + useClickAway(DropdownRef, () => { + setOptions(false); + }); + + const ShowModal = () => { + setModal(true); + }; const fetchProfileData = async () => { if (isValidETHAddress(chatId)) { @@ -164,7 +87,7 @@ export const ChatProfile: React.FC = ({ return isGroup ? groupInfo?.groupImage ?? GreyImage : chatInfo?.profile?.picture ?? - createBlockie?.(chatId)?.toDataURL()?.toString(); + createBlockie?.(chatId)?.toDataURL()?.toString(); } else { return createBlockie?.(chatId)?.toDataURL()?.toString(); } @@ -174,13 +97,14 @@ export const ChatProfile: React.FC = ({ return isGroup ? groupInfo?.groupName : ensName - ? `${ensName} (${isMobile - ? shortenText(chatInfo?.did?.split(':')[1] ?? '', 4, true) - : chatId + ? `${ensName} (${ + isMobile + ? shortenText(chatInfo?.did?.split(':')[1] ?? '', 4, true) + : chatId })` - : chatInfo - ? shortenText(chatInfo.did?.split(':')[1] ?? '', 6, true) - : shortenText(chatId, 6, true); + : chatInfo + ? shortenText(chatInfo.did?.split(':')[1] ?? '', 6, true) + : shortenText(chatId, 6, true); }; useEffect(() => { @@ -196,16 +120,64 @@ export const ChatProfile: React.FC = ({ member={{ wallet: getProfileName() as string, image: getImage() }} customStyle={{ fontSize: '17px' }} /> +
+ {(groupInfo?.rules?.chat?.conditions || + groupInfo?.rules?.entry?.conditions) && } + {!!groupInfo?.isPublic && ( + + )} - - + {!!groupInfo && isGroup && ( + setOptions(true)}> + + + {options && ( + + + + + Group Info + + + )} + + )} + + +
+ {modal && ( + + )} {/* {!isGroup && @@ -230,7 +202,6 @@ const Container = styled.div` align-items: center; padding: 6px; box-sizing: border-box; - position: relative; `; const ImageItem = styled.div` @@ -241,6 +212,7 @@ const DropDownBar = styled.div` position: absolute; top: 30px; left: -130px; + cursor: pointer; display: block; min-width: 140px; color: rgb(101, 119, 149); diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/GroupInfoModal.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/GroupInfoModal.tsx index aca69ae8f..855e1e70b 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/GroupInfoModal.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/GroupInfoModal.tsx @@ -16,7 +16,7 @@ import { ProfileContainer } from '../reusables'; import { IGroup } from '../../../types'; import { IChatTheme } from '../theme'; -import { device } from '../../../config'; +import { ENV, device } from '../../../config'; import { convertToWalletAddressList, getAdminList, @@ -31,11 +31,12 @@ import addIcon from '../../../icons/addicon.svg'; import DismissAdmin from '../../../icons/dismissadmin.svg'; import AddAdmin from '../../../icons/addadmin.svg'; import Remove from '../../../icons/remove.svg'; -import { shortenText } from '../../../helpers'; -import TokenGatedIcon from '../../../icons/TokenGatedIcon.svg'; +import { copyToClipboard, shortenText } from '../../../helpers'; import ConditionsComponent from '../CreateGroup/ConditionsComponent'; -import { ConditionArray } from '../exportedTypes'; -import { ACCESS_TYPE_TITLE } from '../constants'; +import { ACCESS_TYPE_TITLE, OPERATOR_OPTIONS_INFO } from '../constants'; +import { getRuleInfo } from '../helpers/getRulesToCondtionArray'; +import { MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE, ModalBackgroundType, ModalPositionType } from '../exportedTypes'; +import { TokenGatedSvg } from '../../../icons/TokenGatedSvg'; const UPDATE_KEYS = { REMOVE_MEMBER: 'REMOVE_MEMBER', @@ -45,6 +46,11 @@ const UPDATE_KEYS = { } as const; type UpdateKeys = typeof UPDATE_KEYS[keyof typeof UPDATE_KEYS]; +type UpdateGroupType = { + adminList: Array; + memberList: Array; +}; + const SUCCESS_MESSAGE = { REMOVE_MEMBER: 'Removed Member successfully', ADD_MEMBER: 'Group Invitation sent', @@ -89,10 +95,10 @@ const PendingMembers = ({ {showPendingRequests && ( -
{groupInfo?.pendingMembers && @@ -114,7 +120,7 @@ const PendingMembers = ({ /> ))} -
+ )} ); @@ -123,91 +129,36 @@ const PendingMembers = ({ } }; -const dummyConditonsData: ConditionArray[] = [ - [{ operator: 'any' }], - [ - { - type: 'PUSH', - category: 'ERC20', - subcategory: 'holder', - data: { - contract: 'eip155:1:0xf418588522d5dd018b425E472991E52EBBeEEEEE', - amount: 1, - decimals: 18, - }, - }, - ], - [ - { operator: 'all' }, - { - type: 'PUSH', - category: 'ERC20', - subcategory: 'holder', - data: { - contract: 'eip155:137:0x58001cC1A9E17A20935079aB40B1B8f4Fc19EFd1', - amount: 1, - decimals: 18, - }, - }, - { - type: 'PUSH', - category: 'ERC721', - subcategory: 'holder', - data: { - contract: 'eip155:137:0x58001cC1A9E17A20935079aB40B1B8f4Fc19EFd1', - amount: 1, - decimals: 18, - }, - }, - { - type: 'GUILD', - category: 'ROLES', - subcategory: 'DEFAULT', - data: { - id: '1', - role: '346243', - comparison: 'all', - }, - }, - ], - // [ - // { operator: 'any' }, - // { - // type: 'PUSH', - // category: 'INVITE', - // subcategory: 'DEFAULT', - // data: { - // inviterRoles: 'ADMIN', - // }, - // }, - // { - // type: 'PUSH', - // category: 'INVITE', - // subcategory: 'DEFAULT', - // data: { - // inviterRoles: 'OWNER', - // }, - // }, - // ], -]; - -const dummySingleCondtionData: ConditionArray[] = dummyConditonsData[2].map( - (criteria) => [criteria] -); - interface ConditionsInformationProps { theme: IChatTheme; groupInfo?: IGroup | null; + alert?: boolean; + header?: string; + subheader?: string; } export const ConditionsInformation = ({ theme, groupInfo, + alert, + header, + subheader, }: ConditionsInformationProps) => { + const groupRules = getRuleInfo(groupInfo?.rules); + const isMobile = useMediaQuery(device.mobileL); + + const getOperator = (key: keyof typeof groupRules) => { + if (groupRules[key as keyof typeof groupRules].length) { + return groupRules[key as keyof typeof groupRules][0][0] + ?.operator as keyof typeof OPERATOR_OPTIONS_INFO; + } + return null; + }; + return (
@@ -215,91 +166,147 @@ export const ConditionsInformation = ({ groupInfo?.rules?.entry?.conditions) && ( } + header={header ?? 'Gated group'} + subheader={subheader ?? 'Conditions must be true to join and chat'} + alert={alert} /> )} - {Object.keys(ACCESS_TYPE_TITLE).map((key) => ( - <> - - { ACCESS_TYPE_TITLE[key as keyof typeof ACCESS_TYPE_TITLE]?.heading} - - - - - - ))} + + {Object.keys(ACCESS_TYPE_TITLE).map((key, idx) => ( + <> + {getOperator(key as keyof typeof groupRules) ? ( +
+ + { + ACCESS_TYPE_TITLE[key as keyof typeof ACCESS_TYPE_TITLE] + ?.heading + } + + + + { + OPERATOR_OPTIONS_INFO[ + groupRules[key as keyof typeof groupRules][0][0] + ?.operator as keyof typeof OPERATOR_OPTIONS_INFO + ]?.head + } + + {' '} + { + OPERATOR_OPTIONS_INFO[ + groupRules[key as keyof typeof groupRules][0][0] + ?.operator as keyof typeof OPERATOR_OPTIONS_INFO + ]?.tail + } + + +
+ +
+
+ ) : null} + + ))} +
); }; interface GroupTypeProps { theme: IChatTheme; - icon: string; + icon: React.ReactNode; header: string; subheader: string; cursor?: string; handleNextInformation?: () => void; + alert?: boolean; } -const GroupTypeBadge = ({ +export const GroupTypeBadge = ({ theme, icon, header, subheader, handleNextInformation, cursor, + alert, }: GroupTypeProps) => { return ( -
- - + + {/* - -
*/} + {icon} +
+ - - {header} - - - {subheader} - -
- -
+ {header} + + + {subheader} + +
+ + //
); }; type GroupSectionProps = GroupInfoModalProps & { handleNextInformation: () => void; handlePreviousInformation?: () => void; + handleAddRemove: ({ + adminList, + memberList, + updateKey, + }: UpdateGroupType & { updateKey: UpdateKeys }) => void; + setShowAddMoreWalletModal: React.Dispatch>; + selectedMemberAddress: string | null; + setSelectedMemberAddress: React.Dispatch>; }; type GroupInfoModalProps = { @@ -307,6 +314,8 @@ type GroupInfoModalProps = { setModal: React.Dispatch>; groupInfo: IGroup; setGroupInfo: React.Dispatch>; + groupInfoModalBackground?: ModalBackgroundType; + groupInfoModalPositionType?: ModalPositionType; }; export const GROUPINFO_STEPS = { @@ -319,98 +328,25 @@ export type GROUP_INFO_TYPE = const GroupInformation = ({ theme, - setModal, groupInfo, - setGroupInfo, handleNextInformation, + handleAddRemove, + setShowAddMoreWalletModal, + selectedMemberAddress, + setSelectedMemberAddress, }: GroupSectionProps) => { const { account } = useChatData(); - const [showAddMoreWalletModal, setShowAddMoreWalletModal] = - useState(false); + const [showPendingRequests, setShowPendingRequests] = useState(false); - const [memberList, setMemberList] = useState([]); - const [isLoading, setIsLoading] = useState(false); - const [checkedValue, setchecked] = useState(false); - const [selectedMemberAddress, setSelectedMemberAddress] = useState< - string | null - >(null); - const { updateGroup } = useUpdateGroup(); + + const [copyText, setCopyText] = useState(''); + const isMobile = useMediaQuery(device.mobileL); - const handleClose = () => onClose(); const dropdownRef = useRef(null); useClickAway(dropdownRef, () => setSelectedMemberAddress(null)); - const groupInfoToast = useToast(); - const groupCreator = groupInfo?.groupCreator; - const membersExceptGroupCreator = groupInfo?.members?.filter( - (x) => x.wallet?.toLowerCase() !== groupCreator?.toLowerCase() - ); - - const groupMembers = [ - ...membersExceptGroupCreator, - ...groupInfo.pendingMembers, - ]; - - type UpdateGroupType = { - adminList: Array; - memberList: Array; - }; - - const handleUpdateGroup = async (options: UpdateGroupType) => { - const { adminList, memberList } = options || {}; - const updateResponse = await updateGroup({ - groupInfo, - memberList, - adminList, - }); - return { updateResponse }; - }; - - const handleAddRemove = async ( - options: UpdateGroupType & { updateKey: UpdateKeys } - ) => { - const { adminList, memberList, updateKey } = options || {}; - - try { - setIsLoading(true); - const { updateResponse } = await handleUpdateGroup({ - adminList, - memberList, - }); - - if (typeof updateResponse !== 'string') { - setGroupInfo(updateResponse); - - groupInfoToast.showMessageToast({ - toastTitle: 'Success', - toastMessage: SUCCESS_MESSAGE[updateKey], - toastType: 'SUCCESS', - getToastIcon: (size) => , - }); - } else { - groupInfoToast.showMessageToast({ - toastTitle: 'Error', - toastMessage: updateResponse, - toastType: 'ERROR', - getToastIcon: (size) => , - }); - } - } catch (error) { - console.error('Error', error); - groupInfoToast.showMessageToast({ - toastTitle: 'Error', - toastMessage: 'Please, try again', - toastType: 'ERROR', - getToastIcon: (size) => , - }); - } finally { - if (updateKey === UPDATE_KEYS.ADD_MEMBER) handleClose(); - setIsLoading(false); - setSelectedMemberAddress(null); - } - }; const removeMember = async () => { const updatedMemberList = getUpdatedMemberList( groupInfo, @@ -428,27 +364,6 @@ const GroupInformation = ({ }); }; - const addMembers = async () => { - //Already Present Members and PendingMembers - const groupMemberList = convertToWalletAddressList([ - ...groupInfo.members, - ...groupInfo.pendingMembers, - ]); - - //Newly Added Members and alreadyPresent Members in the groupchat - const newMembersToAdd = memberList.map((member: any) => member.wallets); - const members = [...groupMemberList, ...newMembersToAdd]; - - //Admins wallet address from both members and pendingMembers - const adminList = getAdminList?.(groupInfo); - - await handleAddRemove({ - memberList: members, - adminList, - updateKey: UPDATE_KEYS.ADD_MEMBER, - }); - }; - const updateGroupAdmin = async (updateKey: UpdateKeys) => { const groupMemberList = convertToWalletAddressList([ ...groupInfo.members, @@ -493,36 +408,69 @@ const GroupInformation = ({ textColor: '#ED5858', }; - //remove all testing things - - const a1: DropdownValueType = { - id: 'dismiss_admin', - title: 'Dismiss as admin', - function: () => updateGroupAdmin(UPDATE_KEYS.REMOVE_ADMIN), - }; - const a2: DropdownValueType = { - id: 'add_admin', - title: 'Make group admin', - function: () => updateGroupAdmin(UPDATE_KEYS.ADD_ADMIN), - }; - - const handlePrevious = () => { - setShowAddMoreWalletModal(false); - }; - - const onClose = (): void => { - setModal(false); - }; - return ( -
+ + + + Chat ID + +
{ + copyToClipboard(groupInfo?.chatId); + setCopyText('copied'); + }} + onMouseEnter={() => { + setCopyText('click to copy'); + }} + onMouseLeave={() => { + setCopyText(''); + }} + > + + {shortenText(groupInfo?.chatId, 8, true)} + + {!!copyText && ( + + {copyText} + + )} +
+
Group Description {groupInfo?.groupDescription} @@ -530,7 +478,15 @@ const GroupInformation = ({ + } header={groupInfo?.isPublic ? 'Open' : 'Encrypted'} subheader={ groupInfo?.isPublic @@ -538,17 +494,17 @@ const GroupInformation = ({ : 'Chats are end-to-end encrypted' } /> - {/* {(groupInfo.rules?.chat?.conditions || + {(groupInfo.rules?.chat?.conditions || groupInfo.rules?.entry?.conditions) && ( } header={'Gated group'} subheader={'Conditions must be true to join'} /> - )} */} + )} {isAccountOwnerAdmin(groupInfo, account!) && groupInfo?.members && @@ -588,7 +544,12 @@ const GroupInformation = ({ )}
-
+ {groupInfo?.members && groupInfo?.members?.length > 0 && groupInfo?.members.map((item, index) => ( @@ -607,20 +568,8 @@ const GroupInformation = ({ dropdownRef={dropdownRef} /> ))} -
- {showAddMoreWalletModal && ( - - )} - + + ); }; @@ -629,14 +578,36 @@ export const GroupInfoModal = ({ setModal, groupInfo, setGroupInfo, + groupInfoModalBackground = MODAL_BACKGROUND_TYPE.OVERLAY, + groupInfoModalPositionType = MODAL_POSITION_TYPE.GLOBAL, }: GroupInfoModalProps) => { const [activeComponent, setActiveComponent] = useState( GROUPINFO_STEPS.GROUP_INFO ); + const [memberList, setMemberList] = useState([]); + const [isLoading, setIsLoading] = useState(false); + const [showAddMoreWalletModal, setShowAddMoreWalletModal] = + useState(false); + useState(false); + const [selectedMemberAddress, setSelectedMemberAddress] = useState< + string | null + >(null); + + const isMobile = useMediaQuery(device.mobileL); + const groupInfoToast = useToast(); + const { updateGroup } = useUpdateGroup(); + const groupCreator = groupInfo?.groupCreator; + const membersExceptGroupCreator = groupInfo?.members?.filter( + (x) => x.wallet?.toLowerCase() !== groupCreator?.toLowerCase() + ); + const groupMembers = [ + ...membersExceptGroupCreator, + ...groupInfo.pendingMembers, + ]; + const dropdownRef = useRef(null); + const handleNextInfo = () => { - console.log('criteria'); setActiveComponent((activeComponent + 1) as GROUP_INFO_TYPE); - console.log(activeComponent); }; const handlePreviousInfo = () => { @@ -653,6 +624,10 @@ export const GroupInfoModal = ({ setModal={setModal} groupInfo={groupInfo} setGroupInfo={setGroupInfo} + handleAddRemove={handleAddRemove} + setShowAddMoreWalletModal={setShowAddMoreWalletModal} + selectedMemberAddress={selectedMemberAddress} + setSelectedMemberAddress={setSelectedMemberAddress} /> ); case GROUPINFO_STEPS.CRITERIA: @@ -666,34 +641,19 @@ export const GroupInfoModal = ({ setModal={setModal} groupInfo={groupInfo} setGroupInfo={setGroupInfo} + handleAddRemove={handleAddRemove} + setShowAddMoreWalletModal={setShowAddMoreWalletModal} + selectedMemberAddress={selectedMemberAddress} + setSelectedMemberAddress={setSelectedMemberAddress} /> ); } }; - const [showAddMoreWalletModal, setShowAddMoreWalletModal] = - useState(false); - useState(false); - const [memberList, setMemberList] = useState([]); - const [isLoading, setIsLoading] = useState(false); - const [selectedMemberAddress, setSelectedMemberAddress] = useState< - string | null - >(null); - const { updateGroup } = useUpdateGroup(); - const isMobile = useMediaQuery(device.mobileL); - const handleClose = () => onClose(); - const dropdownRef = useRef(null); useClickAway(dropdownRef, () => setSelectedMemberAddress(null)); - const groupInfoToast = useToast(); - const groupCreator = groupInfo?.groupCreator; - const membersExceptGroupCreator = groupInfo?.members?.filter( - (x) => x.wallet?.toLowerCase() !== groupCreator?.toLowerCase() - ); - - type UpdateGroupType = { - adminList: Array; - memberList: Array; + const onClose = (): void => { + setModal(false); }; const handleUpdateGroup = async (options: UpdateGroupType) => { @@ -706,6 +666,7 @@ export const GroupInfoModal = ({ return { updateResponse }; }; + const handleClose = () => onClose(); const handleAddRemove = async ( options: UpdateGroupType & { updateKey: UpdateKeys } ) => { @@ -749,22 +710,6 @@ export const GroupInfoModal = ({ setSelectedMemberAddress(null); } }; - const removeMember = async () => { - const updatedMemberList = getUpdatedMemberList( - groupInfo, - selectedMemberAddress! - ); - const adminList = getUpdatedAdminList( - groupInfo, - selectedMemberAddress, - true - ); - await handleAddRemove({ - memberList: updatedMemberList, - adminList, - updateKey: UPDATE_KEYS.REMOVE_MEMBER, - }); - }; const addMembers = async () => { //Already Present Members and PendingMembers @@ -786,35 +731,23 @@ export const GroupInfoModal = ({ updateKey: UPDATE_KEYS.ADD_MEMBER, }); }; - - const updateGroupAdmin = async (updateKey: UpdateKeys) => { - const groupMemberList = convertToWalletAddressList([ - ...groupInfo.members, - ...groupInfo.pendingMembers, - ]); - const newAdminList = getUpdatedAdminList( - groupInfo, - selectedMemberAddress, - !(updateKey === UPDATE_KEYS.ADD_ADMIN) - ); - await handleAddRemove({ - memberList: groupMemberList, - adminList: newAdminList, - updateKey, - }); - }; - - const onClose = (): void => { - setModal(false); + const handlePrevious = () => { + setShowAddMoreWalletModal(false); }; if (groupInfo) { return ( - + {!showAddMoreWalletModal && (
- + {groupInfo?.groupName} {groupInfo?.members?.length} Members @@ -849,6 +787,18 @@ export const GroupInfoModal = ({ {renderComponent()}
)} + {showAddMoreWalletModal && ( + + )} ); } else { @@ -858,7 +808,6 @@ export const GroupInfoModal = ({ //styles const GroupHeader = styled.div` - margin-top: 34px; display: flex; flex-direction: row; width: 100%; @@ -866,7 +815,6 @@ const GroupHeader = styled.div` `; const GroupDescription = styled.div` - margin-top: 34px; display: flex; flex-direction: column; width: 100%; @@ -874,22 +822,23 @@ const GroupDescription = styled.div` gap: 5px; `; -const PublicEncrypted = styled.div` - margin-top: 20px; +const PublicEncrypted = styled(Section)<{ alert?: boolean }>` display: flex; flex-direction: row; width: 100%; - gap: 19px; + gap: 12px; align-items: center; - border: ${(props) => props.theme.border.modalInnerComponents}; + border: ${(props) => + props?.alert + ? '1px solid #E93636' + : props.theme.border.modalInnerComponents}; border-radius: ${(props) => props.theme.borderRadius.modalInnerComponents}; - padding: 16px; + padding: 12px 16px; box-sizing: border-box; background: ${(props) => props.theme.backgroundColor.modalHoverBackground}; `; const AddWalletContainer = styled.div` - margin-top: 20px; border: ${(props) => props.theme.border.modalInnerComponents}; border-radius: ${(props) => props.theme.borderRadius.modalInnerComponents}; width: 100%; @@ -919,7 +868,6 @@ const GroupPendingMembers = styled.div` const PendingRequestWrapper = styled.div` width: 100%; - margin-top: 20px; border: ${(props) => props.theme.border.modalInnerComponents}; border-radius: ${(props) => props.theme.borderRadius.modalInnerComponents}; padding: 0px 0px; @@ -966,4 +914,21 @@ const ConditionSection = styled(Section)<{ theme: IChatTheme }>` } `; +const ProfileSection = styled(Section)` + height: fit-content; +`; +const ScrollSection = styled(Section)<{ theme: IChatTheme }>` + &::-webkit-scrollbar-thumb { + background: ${(props) => props.theme.scrollbarColor}; + border-radius: 10px; + } + &::-webkit-scrollbar-button { + height: 40px; + } + + &::-webkit-scrollbar { + width: 4px; + } +`; + //auto update members when an user accepts not done diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/MemberProfileCard.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/MemberProfileCard.tsx index 80b6bfa9f..a36d0848a 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/MemberProfileCard.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/MemberProfileCard.tsx @@ -115,7 +115,8 @@ export const MemberProfileCard = ({ const ProfileCardItem = styled(Section)<{ id: any; key: any; background: any }>` justify-content: space-between; padding: 8px 8px; - border-radius: 16px; + // border-radius: 16px; + border-bottom: ${(props) => props.theme.border.modalInnerComponents}; position: relative; box-sizing: border-box; width: 100%; diff --git a/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx b/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx index 1b388c4ed..e7a672dbb 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewBubble/ChatViewBubble.tsx @@ -336,18 +336,18 @@ const TwitterCard = ({ ); }; -export const ChatViewBubble = ({ chat }: { chat: IMessagePayload }) => { +export const ChatViewBubble = ({ decryptedMessagePayload }: { decryptedMessagePayload: IMessagePayload }) => { const { account } = useChatData(); const position = - pCAIP10ToWallet(chat.fromDID).toLowerCase() !== account?.toLowerCase() + pCAIP10ToWallet(decryptedMessagePayload.fromDID).toLowerCase() !== account?.toLowerCase() ? 0 : 1; const { tweetId, messageType }: TwitterFeedReturnType = checkTwitterUrl({ - message: chat?.messageContent, + message: decryptedMessagePayload?.messageContent, }); const [isGroup, setIsGroup] = useState(false); useEffect(() => { - if (chat.toDID.split(':')[0] === 'eip155') { + if (decryptedMessagePayload.toDID.split(':')[0] === 'eip155') { if (isGroup) { setIsGroup(false); } @@ -356,32 +356,32 @@ export const ChatViewBubble = ({ chat }: { chat: IMessagePayload }) => { setIsGroup(true); } } - }, [chat.toDID, isGroup]); + }, [decryptedMessagePayload.toDID, isGroup]); if (messageType === 'TwitterFeedLink') { - chat.messageType = 'TwitterFeedLink'; + decryptedMessagePayload.messageType = 'TwitterFeedLink'; } - if (chat.messageType === 'GIF') { - return ; + if (decryptedMessagePayload.messageType === 'GIF') { + return ; } - if (chat.messageType === 'Image') { - return ; + if (decryptedMessagePayload.messageType === 'Image') { + return ; } - if (chat.messageType === 'File') { - return ; + if (decryptedMessagePayload.messageType === 'File') { + return ; } - if (chat.messageType === 'TwitterFeedLink') { + if (decryptedMessagePayload.messageType === 'TwitterFeedLink') { return ( ); } - return ; + return ; }; const FileDownloadIcon = styled.i` diff --git a/packages/uiweb/src/lib/components/chat/ChatViewComponent/ChatViewComponent.tsx b/packages/uiweb/src/lib/components/chat/ChatViewComponent/ChatViewComponent.tsx index 9cd16d4da..09cf1366f 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewComponent/ChatViewComponent.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewComponent/ChatViewComponent.tsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { IChatTheme, IChatViewComponentProps } from '../exportedTypes'; +import { IChatTheme, IChatViewComponentProps, MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE } from '../exportedTypes'; import { Section, Span } from '../../reusables'; import { ChatViewList } from '../ChatViewList'; @@ -35,7 +35,11 @@ export const ChatViewComponent: React.FC = ( gif = true, isConnected = true, autoConnect = false, - onGetTokenClick, + onVerificationFail, + groupInfoModalBackground = MODAL_BACKGROUND_TYPE.OVERLAY, + groupInfoModalPositionType = MODAL_POSITION_TYPE.GLOBAL, + verificationFailModalBackground = MODAL_BACKGROUND_TYPE.OVERLAY, + verificationFailModalPosition = MODAL_POSITION_TYPE.GLOBAL, } = options || {}; const { env, signer, account, pgpPrivateKey } = useChatData(); @@ -58,7 +62,7 @@ export const ChatViewComponent: React.FC = ( padding="13px" theme={theme} > - {chatProfile && } + {chatProfile && }
= (
)} {(messageInput && (!!signer || (!!account && !!pgpPrivateKey) || isConnected )) && ( -
+
diff --git a/packages/uiweb/src/lib/components/chat/ChatViewComponent/index.ts b/packages/uiweb/src/lib/components/chat/ChatViewComponent/index.ts index 25a649344..7d3f2796f 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewComponent/index.ts +++ b/packages/uiweb/src/lib/components/chat/ChatViewComponent/index.ts @@ -1 +1,2 @@ -export {ChatViewComponent} from './ChatViewComponent'; \ No newline at end of file +export {ChatViewComponent} from './ChatViewComponent'; +export {ChatViewComponent as ChatView} from './ChatViewComponent'; \ No newline at end of file diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ApproveRequestBubble.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ApproveRequestBubble.tsx index 6df0a560b..140d7abc5 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewList/ApproveRequestBubble.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ApproveRequestBubble.tsx @@ -99,9 +99,9 @@ const Button = styled.button` border: none; cursor: pointer; border-radius: 8px; - background: ${(props) => props.theme.backgroundColor.buttonBackground}; + background: ${(props) => props.theme.backgroundColor!.buttonBackground}; border: none; - color: ${(props) => props.theme.textColor.buttonText}; + color: ${(props) => props.theme.textColor!.buttonText}; width: 100%; font-size: 16px; font-weight: 600; diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx index b63b1ee00..451df1678 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx @@ -380,7 +380,7 @@ export const ChatViewList: React.FC = ( justifyContent={position ? 'end' : 'start'} margin="7px" > - +
); diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/MessageEncryption.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/MessageEncryption.tsx index 74e307637..89a4cd2e2 100644 --- a/packages/uiweb/src/lib/components/chat/ChatViewList/MessageEncryption.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatViewList/MessageEncryption.tsx @@ -42,7 +42,7 @@ const EncryptionMessageContent = { margin="10px 10px 0px" width={isMobile ? '80%' : 'fit-content'} > - + {EncryptionMessageContent[id].IconComponent} { const {wallet, connecting , connect, disconnect} = useAccount(); const { signer, - pgpPrivateKey, - account, - env, - setPgpPrivateKey, setAccount, setSigner, } = useChatData(); const theme = useContext(ThemeContext); - const {fetchChatProfile} = useGetChatProfile(); - const {creteChatProfile} = useCreateChatProfile(); - const {decryptPGPKey} = useDecryptPGPKey(); const setUserData = () => { @@ -54,7 +43,6 @@ export const ConnectButtonSub = ({autoConnect = false}) => { } else if (!wallet) { setAccount('') setSigner(undefined) - setPgpPrivateKey(null) } } useEffect(() => { @@ -63,37 +51,6 @@ export const ConnectButtonSub = ({autoConnect = false}) => { setUserData() }, [wallet]) - useEffect(() => { - (async () => { - if (account && signer) { - if (!pgpPrivateKey) await handleUserCreation(); - } - })(); - }, [account, signer]); - - - const handleUserCreation = async () => { - if (!account && !env) return; - try { - let user = await fetchChatProfile({ profileId: account! ,env}); - if (!user) { - if (!signer) return; - user = await creteChatProfile({ signer: signer ,env}); - } - if (user?.encryptedPrivateKey && !pgpPrivateKey) { - const decryptPgpKey = await decryptPGPKey({ - encryptedPrivateKey: user.encryptedPrivateKey, - account: account!, - signer: signer, - env: env, - }); - if(decryptPgpKey) - setPgpPrivateKey(decryptPgpKey); - } - } catch (e: any) { - console.log(e); - } - }; return !signer ? ( @@ -108,8 +65,8 @@ const ConnectButtonDiv = styled.div` width: fit-content; button{ - background: ${(props) => `${props.theme.backgroundColor.buttonBackground}!important`}; - color: ${(props) => `${props.theme.textColor.buttonText}!important`}; + background: ${(props) => `${props.theme.backgroundColor?.buttonBackground}!important`}; + color: ${(props) => `${props.theme.textColor?.buttonText}!important`}; text-align:center; font-size: 1em; cursor:pointer; diff --git a/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx b/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx index b6b603fdf..19d4f96e8 100644 --- a/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx +++ b/packages/uiweb/src/lib/components/chat/ConnectButton/index.tsx @@ -7,10 +7,12 @@ import { Web3OnboardProvider } from '@web3-onboard/react'; import injectedModule, { ProviderLabel } from '@web3-onboard/injected-wallets'; import walletConnectModule from '@web3-onboard/walletconnect' import init from '@web3-onboard/core'; +import PushIcon from "../../../icons/Bell.svg" const APP_META_DATA = { name: 'Push Protocol', - icon: 'https://files.slack.com/files-pri/T011WQBLH39-F05QWQA0MSR/pushlogoblocknative.png', + logo: PushIcon, + icon: PushIcon, description: 'Example showcasing how to connect a wallet.', recommendedInjectedWallets: [ diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx index 8f9bbd0c2..a1b846f3e 100644 --- a/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/AddCriteria.tsx @@ -1,15 +1,19 @@ import { useContext, useEffect, useState } from 'react'; +import styled from 'styled-components'; +import { MdError } from 'react-icons/md'; + import { Button, DropDownInput, DropdownValueType, + InfoContainer, ModalHeader, TextInput, } from '../reusables'; -import { Section, } from '../../reusables'; +import { Section, Span, Spinner } from '../../reusables'; import useMediaQuery from '../../../hooks/useMediaQuery'; -import { GatingRulesInformation, ModalHeaderProps } from './CreateGroupModal'; +import { ModalHeaderProps } from './CreateGroupModal'; import { useChatData } from '../../../hooks'; import { QuantityInput } from '../reusables/QuantityInput'; import { ThemeContext } from '../theme/ThemeProvider'; @@ -18,6 +22,7 @@ import OptionButtons from '../reusables/OptionButtons'; import EthereumSvg from '../../../icons/ethereum.svg'; import PolygonSvg from '../../../icons/polygon.svg'; +import ArbitrumSvg from '../../../icons/arbitrum.svg'; import BSCSvg from '../../../icons/bsc.svg'; import OptimismSvg from '../../../icons/optimisim.svg'; import { BLOCKCHAIN_NETWORK, device } from '../../../config'; @@ -32,21 +37,39 @@ import { TypeKeys, ReadonlyInputType, } from '../types'; -import { Data, GuildData, PushData, Rule } from '../types/tokenGatedGroupCreationType'; - - - -const AddCriteria = ({ +import useToast from '../reusables/NewToast'; +import { + CriteriaValidationErrorType, + GuildData, + PushData, + Rule, +} from '../types/tokenGatedGroupCreationType'; +import { + checkIfCustomEndpoint, + checkIfGuild, + checkIfPushInvite, + checkIfTokenNFT, + fetchContractInfo, + getCategoryDropdownValues, + getCriteriaData, + getSubCategoryDropdownValues, + validationCriteria, +} from '../helpers'; +import { IChatTheme } from '../exportedTypes'; + +const AddCriteria = ({ handlePrevious, - handleNext, onClose, - criteriaStateManager + criteriaStateManager, }: ModalHeaderProps) => { const [selectedTypeValue, setSelectedTypeValue] = useState(0); + const [validationErrors, setValidationErrors] = + useState({}); const [selectedCategoryValue, setSelectedCategoryValue] = useState(0); const [selectedSubCategoryValue, setSelectedSubCategoryValue] = useState(0); - const [guildComparison, setGuildComparison] = useState('') + const [validationLoading, setValidationLoading] = useState(false); + const [guildComparison, setGuildComparison] = useState(''); const [selectedChainValue, setSelectedChainValue] = useState(0); const [contract, setContract] = useState(''); const [inviteCheckboxes, setInviteCheckboxes] = useState<{ @@ -56,6 +79,8 @@ const AddCriteria = ({ const [url, setUrl] = useState(''); const [guildId, setGuildId] = useState(''); const [specificRoleId, setSpecificRoleId] = useState(''); + const [unit, setUnit] = useState('TOKEN'); + const [decimals, setDecimals] = useState(18); const [quantity, setQuantity] = useState<{ value: number; range: number }>({ value: 0, @@ -63,6 +88,7 @@ const AddCriteria = ({ }); const { env } = useChatData(); const theme = useContext(ThemeContext); + const groupInfoToast = useToast(); const isMobile = useMediaQuery(device.mobileL); @@ -151,23 +177,15 @@ const AddCriteria = ({ }, }; - const tokenCategoryValues = [ - { - id: 0, + const dropdownSubCategoryValues: DropdownSubCategoryValuesType = { + ERC20: { value: SUBCATEGORY.HOLDER, title: 'Holder', - function: () => setSelectedSubCategoryValue(0), }, - { - id: 1, - value: SUBCATEGORY.OWENER, - title: 'Owner', - function: () => setSelectedSubCategoryValue(1), + ERC721: { + value: SUBCATEGORY.HOLDER, + title: 'Holder', }, - ]; - const dropdownSubCategoryValues: DropdownSubCategoryValuesType = { - ERC20: tokenCategoryValues, - ERC721: tokenCategoryValues, INVITE: { value: SUBCATEGORY.DEFAULT, title: 'Default', @@ -215,214 +233,201 @@ const AddCriteria = ({ icon: OptimismSvg, function: () => setSelectedChainValue(3), }, + { + id: 4, + value: BLOCKCHAIN_NETWORK[env].ARBITRUM, + title: 'Arbitrim', + icon: ArbitrumSvg, + function: () => setSelectedChainValue(4), + }, ]; - const getCategoryDropdownValues = () => { - return dropdownCategoryValues[ - dropdownTypeValues[selectedTypeValue].value as TypeKeys - ]; - }; - - const getSelectedCategoryValue = () => { - const category = getCategoryDropdownValues(); - if (Array.isArray(category)) - return (category as DropdownValueType[])[selectedCategoryValue].value!; - else return category.value! as SubCategoryKeys; - }; - - const getSelectedSubCategoryValue = () => { - const subCategory = getSubCategoryDropdownValues(); - if (Array.isArray(subCategory)) - return (subCategory as DropdownValueType[])[selectedCategoryValue].value!; - else return subCategory.value! as SubCategoryKeys; - }; - - const checkIfTokenNFT = () => { - const category = getSelectedCategoryValue(); - if (category === CATEGORY.ERC20 || category === CATEGORY.ERC721) - return true; - - return false; - }; - - const checkIfCustomEndpoint = () => { - const category = getSelectedCategoryValue(); - if (category === CATEGORY.CustomEndpoint) return true; - return false; - }; - - const checkIfPushInvite = () => { - const accessType = dropdownTypeValues[selectedTypeValue].value; - if (accessType === TYPE.PUSH) { - const category = getSelectedCategoryValue(); - if (category === CATEGORY.INVITE) return true; - } - - return false; - }; - - const checkIfGuild = () => { - const accessType = dropdownTypeValues[selectedTypeValue].value; - if (accessType === TYPE.GUILD) { - return true; - } - - return false; - }; - - const getSubCategoryDropdownValues = () => { - const category = getCategoryDropdownValues(); - if (Array.isArray(category)) - return dropdownSubCategoryValues[ - (category as DropdownValueType[])[selectedCategoryValue] - .value as SubCategoryKeys - ]; - else return dropdownSubCategoryValues[category.value as SubCategoryKeys]; - }; - const onQuantityChange = (e: any) => { setQuantity({ ...quantity, value: e.target.value }); }; - const verifyAndDoNext = ()=>{ - const _type = dropdownTypeValues[selectedTypeValue].value as 'PUSH' | 'GUILD' - const category:string = _type === "PUSH" ? (dropdownCategoryValues[_type] as DropdownValueType[])[ - selectedCategoryValue - ].value || CATEGORY.ERC20 : "ROLES" - - let subCategory = "DEFAULT" - if(_type === "PUSH"){ - if(category === CATEGORY.ERC20 || category === CATEGORY.ERC721){ - subCategory = tokenCategoryValues[selectedSubCategoryValue].value - }else if(category === CATEGORY.CustomEndpoint){ - subCategory = "GET" - } - } - - const getData = (type:string, category:string):Data=>{ - if(type === "PUSH"){ - if(category === CATEGORY.ERC20 || category === CATEGORY.ERC721){ - const selectedChain = dropdownChainsValues[selectedChainValue].value || 'eip155:1'; - return { - contract: `${selectedChain}:${contract}`, - amount: quantity.value, - comparison:dropdownQuantityRangeValues[quantity.range].value, - decimals: 18, - } - }else if(category === CATEGORY.INVITE){ - const _inviteRoles = [] - if(inviteCheckboxes.admin){ - _inviteRoles.push("ADMIN") - } - if(inviteCheckboxes.owner){ - _inviteRoles.push("OWNER") - } - - return{ - inviterRoles: _inviteRoles as ['OWNER' | 'ADMIN'] - } - }else{ - // CATEGORY.CustomEndpoint - // TODO: validate url - return{ - url:url - } - } - }else{ - // GUILD type - return { - id:guildId, - comparison:guildComparison, - role:guildComparison === 'specific' ? specificRoleId : "*", - } + const verifyAndDoNext = async () => { + setValidationLoading(true); + const _type = dropdownTypeValues[selectedTypeValue].value as + | 'PUSH' + | 'GUILD'; + const category: string = + _type === 'PUSH' + ? (dropdownCategoryValues[_type] as DropdownValueType[])[ + selectedCategoryValue + ].value || CATEGORY.ERC20 + : 'ROLES'; + + let subCategory = 'DEFAULT'; + if (_type === 'PUSH') { + if (category === CATEGORY.ERC20 || category === CATEGORY.ERC721) { + subCategory = SUBCATEGORY.HOLDER; + } else if (category === CATEGORY.CustomEndpoint) { + subCategory = 'GET'; } } - const rule:Rule = { + const rule: Rule = { type: _type, category: category, subcategory: subCategory, - data: getData(_type, category), + data: getCriteriaData({ + type: _type, + category, + contract, + quantity, + decimals, + unit, + url, + inviteCheckboxes, + guildComparison, + specificRoleId, + guildId, + dropdownQuantityRangeValues, + selectedChainValue, + dropdownChainsValues, + }), + }; + + //guild validation added + const errors = await validationCriteria(rule); + setValidationLoading(false); + if (Object.keys(errors).length) { + setValidationErrors(errors); + } else { + const isSuccess = criteriaState.addNewRule(rule); + if (!isSuccess) { + showError('Selected Criteria was already added'); + return; + } + if (handlePrevious) { + handlePrevious(); + } } + }; - criteriaState.addNewRule(rule) + const criteriaState = criteriaStateManager.getSelectedCriteria(); - if(handlePrevious){ - handlePrevious() - } + // Autofill the form for the update + useEffect(() => { + if (criteriaState.isUpdateCriteriaEnabled()) { + //Load the states + const oldValue = + criteriaState.selectedRules[criteriaState.updateCriteriaIdx]; + + if (oldValue.type === 'PUSH') { + // category + setSelectedCategoryValue( + (dropdownCategoryValues.PUSH as DropdownValueType[]).findIndex( + (obj) => obj.value === oldValue.category + ) + ); - } + const pushData = oldValue.data as PushData; - const criteriaState = criteriaStateManager.getSelectedCriteria() + // sub category + if ( + oldValue.category === CATEGORY.ERC20 || + oldValue.category === CATEGORY.ERC721 + ) { + if (pushData.token) { + setUnit(pushData.token); + } + if (pushData.decimals) { + setDecimals(decimals); + } - // Autofill the form for the update - useEffect(()=>{ - if(criteriaState.isUpdateCriteriaEnabled()){ - //Load the states - const oldValue = criteriaState.selectedRules[criteriaState.updateCriteriaIdx] - - if(oldValue.type === 'PUSH'){ - - // category - setSelectedCategoryValue( - (dropdownCategoryValues.PUSH as DropdownValueType[]).findIndex(obj => obj.value === oldValue.category) - ) - - const pushData = oldValue.data as PushData - - // sub category - if(oldValue.category === CATEGORY.ERC20 || oldValue.category === CATEGORY.ERC721){ - setSelectedSubCategoryValue( - tokenCategoryValues.findIndex(obj => obj.value === oldValue.subcategory) - ) - - const contractAndChain:string[] = (pushData.contract || "eip155:1:0x").split(':') - setSelectedChainValue( - dropdownChainsValues.findIndex( - obj => obj.value === contractAndChain[0]+":"+contractAndChain[1] - ) - ) - setContract(contractAndChain.length === 3 ? contractAndChain[2]: "") - setQuantity({ - value:pushData.amount || 0, - range:dropdownQuantityRangeValues.findIndex( - obj => obj.value === pushData.comparison - ) - }) - }else if(oldValue.category === CATEGORY.INVITE){ - setInviteCheckboxes({ - admin:true, - owner:true, - }) - }else{ - // invite - setUrl(pushData.url || "") + // TODO: make helper function for this + const contractAndChain: string[] = ( + pushData.contract || 'eip155:1:0x' + ).split(':'); + setSelectedChainValue( + dropdownChainsValues.findIndex( + (obj) => + obj.value === contractAndChain[0] + ':' + contractAndChain[1] + ) + ); + setContract(contractAndChain.length === 3 ? contractAndChain[2] : ''); + setQuantity({ + value: pushData.amount || 0, + range: dropdownQuantityRangeValues.findIndex( + (obj) => obj.value === pushData.comparison + ), + }); + } else if (oldValue.category === CATEGORY.INVITE) { + setInviteCheckboxes({ + admin: true, + owner: true, + }); + } else { + // invite + setUrl(pushData.url || ''); + } + } else { + // guild condition + setGuildId((oldValue.data as GuildData).id); + setSpecificRoleId((oldValue.data as GuildData).role); + setGuildComparison( + (oldValue.data as GuildData).comparison || + GUILD_COMPARISON_OPTIONS[2].value + ); } - }else{ - // guild condition - setGuildId((oldValue.data as GuildData).id) - setSpecificRoleId((oldValue.data as GuildData).role) - setGuildComparison((oldValue.data as GuildData).comparison) + + setSelectedTypeValue( + dropdownTypeValues.findIndex((obj) => obj.value === oldValue.type) + ); } - - setSelectedTypeValue( - dropdownTypeValues.findIndex(obj => obj.value === oldValue.type) - ) - } - },[]) + }, []); + + useEffect(() => { + // Debouncing + // Fetch the contract info + const getData = setTimeout(async () => { + await fetchContractInfo({ + setValidationErrors, + selectedCategoryValue, + selectedTypeValue, + dropdownCategoryValues, + dropdownTypeValues, + contract, + setUnit, + setDecimals, + selectedChainValue, + dropdownChainsValues, + }); + }, 2000); + return () => clearTimeout(getData); + }, [contract, selectedCategoryValue, selectedChainValue]); + + const showError = (errorMessage: string) => { + groupInfoToast.showMessageToast({ + toastTitle: 'Error', + toastMessage: errorMessage, + toastType: 'ERROR', + getToastIcon: (size) => , + }); + }; return ( -
-
+
- {Array.isArray(getCategoryDropdownValues()) ? ( - - ) : ( - - )} - - {Array.isArray(getSubCategoryDropdownValues()) ? ( - - ) : ( - - )} +
+
+ {Array.isArray( + getCategoryDropdownValues({ + dropdownCategoryValues, + dropdownTypeValues, + selectedTypeValue, + }) + ) ? ( + + ) : ( + + )} +
+
+ {Array.isArray( + getSubCategoryDropdownValues({ + dropdownCategoryValues, + dropdownTypeValues, + selectedCategoryValue, + dropdownSubCategoryValues, + selectedTypeValue, + }) + ) ? ( + + ) : ( + + )} +
+
{/* shift to minor components leave for now*/} - {checkIfTokenNFT() && ( + {checkIfTokenNFT({ + dropdownCategoryValues, + dropdownTypeValues, + selectedCategoryValue, + selectedTypeValue, + }) && ( <> - setContract(e.target.value)} - placeholder="e.g. 0x123..." - /> - +
+ setContract(e.target.value)} + placeholder="e.g. 0x123..." + error={!!validationErrors?.tokenError} + /> + {!!validationErrors?.tokenError && ( + {validationErrors?.tokenError} + )} +
+
+ + {!!validationErrors?.tokenAmount && ( + {validationErrors?.tokenAmount} + )} +
)} - {checkIfCustomEndpoint() && ( - setUrl(e.target.value)} - placeholder="e.g. abc.com" - /> + {checkIfCustomEndpoint({ + dropdownCategoryValues, + dropdownTypeValues, + selectedCategoryValue, + selectedTypeValue, + }) && ( +
+ setUrl(e.target.value)} + placeholder="e.g. abc.com" + error={!!validationErrors?.url} + /> + {!!validationErrors?.url && ( + {validationErrors?.url} + )} +
)} - {checkIfPushInvite() && ( + {checkIfPushInvite({ + dropdownCategoryValues, + dropdownTypeValues, + selectedCategoryValue, + selectedTypeValue, + }) && (
{Object.keys(INVITE_CHECKBOX_LABEL).map((key) => ( setInviteCheckboxes({ - admin:true, - owner:true + admin: true, + owner: true, }) } checked={ @@ -517,41 +613,78 @@ const AddCriteria = ({
)} - {checkIfGuild() && ( + {checkIfGuild(dropdownTypeValues, selectedTypeValue) && ( <> - setGuildId(e.target.value)} - placeholder="e.g. 4687" - /> - { - setGuildComparison(newEl)}} - /> - - {guildComparison === "specific" && +
setSpecificRoleId(e.target.value)} + labelName="ID" + inputValue={guildId} + onInputChange={(e: any) => setGuildId(e.target.value)} placeholder="e.g. 4687" + error={!!validationErrors?.guildId} /> - } - - + {!!validationErrors?.guildId && ( + {validationErrors?.guildId} + )} +
+
+ { + setGuildComparison(newEl); + }} + /> + {!!validationErrors?.guildComparison && ( + {validationErrors?.guildComparison} + )} +
+ {guildComparison === 'specific' && ( +
+ setSpecificRoleId(e.target.value)} + placeholder="e.g. 4687" + error={!!validationErrors?.guildRole} + /> + {!!validationErrors?.guildRole && ( + {validationErrors?.guildRole} + )} +
+ )} )} - -
+ + ); }; export default AddCriteria; +const ErrorSpan = styled(Span)` + font-size: 12px; + font-weight: 500; + color: #ed5858; +`; + +const ScrollSection = styled(Section)<{ theme: IChatTheme }>` + &::-webkit-scrollbar-thumb { + background: ${(props) => props.theme.scrollbarColor}; + border-radius: 10px; + } + &::-webkit-scrollbar-button { + height: 40px; + } + + &::-webkit-scrollbar { + width: 4px; + } +`; diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/AutoImageClipper.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/AutoImageClipper.tsx new file mode 100644 index 000000000..80a1628fe --- /dev/null +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/AutoImageClipper.tsx @@ -0,0 +1,153 @@ +// React + Web3 Essentials +import React, { Fragment, useCallback, useState } from "react"; + +// External Packages +import Cropper from "react-easy-crop"; +import styledComponents from "styled-components"; +import Resizer from "react-image-file-resizer"; + +type CropType = { + x: number; + y: number; +} + +type CroppedAreaPixels = { + height: number; + width: number; + x: number; + y: number; +} + +const AutoImageClipper = (props: { imageSrc: any; onImageCropped: any; width: any; height: any; }) => { + const { imageSrc, onImageCropped, width, height } = props; + const [crop, setCrop] = useState({ x: 0, y: 0 }); + const [zoom, setZoom] = useState(1); + const [croppedAreaPixels, setCroppedAreaPixels] = useState(null); + const [croppedImage, setCroppedImage] = useState(''); + const onCropComplete = useCallback((croppedArea, croppedAreaPixels) => { + setCroppedAreaPixels(croppedAreaPixels); + }, []); + + React.useEffect(() => { + async function showCroppedImage() { + try { + if (imageSrc) { + const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels!); + const image = await resizeFile(croppedImage); + onImageCropped(image); + + return; + + } else { + return; + } + } catch (e) { + console.error(e); + + return; + } + } + showCroppedImage(); + }, [crop]); + + async function getCroppedImg(imageSrc:string, pixelCrop: { height: any; width: any; x: any; y: any; }) { + const image = await createImage(imageSrc); + const canvas = document.createElement("canvas"); + canvas.width = pixelCrop?.width; + canvas.height = pixelCrop?.height; + const ctx = canvas.getContext("2d"); + const fileName = "none.jpg"; + + ctx!.drawImage( + image as CanvasImageSource, + pixelCrop.x, + pixelCrop.y, + pixelCrop.width, + pixelCrop.height, + 0, + 0, + pixelCrop.width, + pixelCrop.height + ); + + // As Base64 string + // return canvas.toDataURL('image/jpeg'); + + // As a blob + return new Promise((resolve, reject) => { + canvas.toBlob((file) => { + // resolve(URL.createObjectURL(file)); + resolve( + new File([file!], fileName, { + type: "image/jpeg", + lastModified: Date.now() + }) + ); + }, "image/jpeg"); + }); + } + + const resizeFile = (file: any) => { + return new Promise((resolve) => { + Resizer.imageFileResizer( + file, + 128, + 128, + "JPEG", + 80, + 0, + (uri) => { + resolve(uri); + setCroppedImage(uri as unknown as string); + }, + "base64" + ); + }); + }; + + const createImage = (url: string) => { + return new Promise((resolve, reject) => { + const image = new Image(); + image.addEventListener("load", () => resolve(image)); + image.addEventListener("error", (error) => reject(error)); + image.setAttribute("crossOrigin", "anonymous"); // needed to avoid cross-origin issues on CodeSandbox + image.src = url; + }); + }; + + const onZoomChange = (zoom: React.SetStateAction) => { + setZoom(zoom); + }; + return ( + + + + + + ); +}; + +const Container = styledComponents.div` + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + `; + +export default AutoImageClipper; diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx index 4efb0d594..6b960d7ae 100644 --- a/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/ConditionsComponent.tsx @@ -7,13 +7,19 @@ import { MoreDarkIcon } from '../../../icons/MoreDark'; import { ThemeContext } from '../theme/ThemeProvider'; import Dropdown, { DropdownValueType } from '../reusables/DropDown'; import { ConditionArray, ConditionData, IChatTheme } from '../exportedTypes'; -import { useClickAway } from '../../../hooks'; -import { CATEGORY, CRITERIA_TYPE, CriteriaType, TOKEN_NFT_COMPARISION, TokenNftComparision } from '../types'; +import { useClickAway, useTokenSymbolLoader } from '../../../hooks'; +import { + CATEGORY, + CRITERIA_TYPE, + CriteriaType, + TOKEN_NFT_COMPARISION, + TokenNftComparision, +} from '../types'; import EditSvg from '../../../icons/EditSvg.svg'; import RemoveSvg from '../../../icons/RemoveSvg.svg'; import { shortenText } from '../../../helpers'; -import { GUILD_COMPARISON_OPTIONS } from '../constants'; +import { GUILD_COMPARISON_OPTIONS, NETWORK_ICON_DETAILS } from '../constants'; export type CriteraValueType = { invertedIcon?: any; @@ -54,8 +60,12 @@ const MoreOptionsContainer = ({ useClickAway(dropdownRef, () => setSelectedIndex(null)); return ( -
handleMoreOptionsClick(row, col)} position='static'> - +
handleMoreOptionsClick(row, col)} position="static"> + {selectedIndex?.length && selectedIndex[0] === row && ( { return false; }; - const getGuildRole = () =>{ - return (GUILD_COMPARISON_OPTIONS.find(option => option.value === criteria?.data?.['comparison']))?.heading; - - } + const getGuildRole = () => { + if (!criteria?.data?.['comparison']) { + return 'SPECIFIC'; + } + return GUILD_COMPARISON_OPTIONS.find( + (option) => option.value === criteria?.data?.['comparison'] + )?.heading; + }; + + const [tokenSymbol] = useTokenSymbolLoader(criteria); return ( -
+
{ {CRITERIA_TYPE[criteria.category as CriteriaType]} {checkIfNftToken() && ( - - - {getTokenNftComparisionLabel()}{' '} +
+ + + {getTokenNftComparisionLabel()}{' '} + + {criteria?.data?.['amount']} {tokenSymbol} - {/* need to fetch token symbol */} - {criteria?.data?.['amount']} {criteria.category} - + + { + NETWORK_ICON_DETAILS[ + criteria?.data?.['contract'].split( + ':' + )[1] as keyof typeof NETWORK_ICON_DETAILS + ].icon + } + +
)} {criteria.category === CATEGORY.INVITE && ( @@ -121,17 +151,17 @@ const CriteriaSection = ({ criteria }: { criteria: ConditionData }) => { fontSize="14px" color={theme.textColor?.modalSubHeadingText} > - {shortenText(criteria.data?.['url'],30)} + {shortenText(criteria.data?.['url'], 30)} )} - {criteria.category === CATEGORY.ROLES && ( - - {criteria?.data?.['id']} {' '} - - with {' '} + {criteria.category === CATEGORY.ROLES && ( + + {criteria?.data?.['id']}{' '} + + with{' '} + + {getGuildRole()} role - {getGuildRole()} role - )}
); @@ -191,7 +221,7 @@ const ConditionsComponent = ({
{conditionData && conditionData.slice(1).map((criteria, row) => ( -
+
{criteria.length <= 2 && criteria.length >= 1 && criteria.map((singleCriteria, col) => ( @@ -200,7 +230,7 @@ const ConditionsComponent = ({
@@ -241,7 +271,7 @@ const ConditionsComponent = ({ background={ theme.backgroundColor?.modalHoverBackground } - padding="10px 4px 10px 12px" + padding="15px 4px 15px 12px" justifyContent="space-between" width="100%" > @@ -252,8 +282,7 @@ const ConditionsComponent = ({ ))}
-
+
{criteria.map((singleCriteria) => ( <> {criteria.length > 2 && @@ -296,7 +325,6 @@ export default ConditionsComponent; const DropdownContainer = styled.div` position: absolute; - // left: 48%; top: 0; right: 0; border-radius: ${(props) => props.theme.borderRadius.modalInnerComponents}; @@ -312,11 +340,23 @@ const DropdownContainer = styled.div` const OperatorSpan = styled(Span)<{ theme: IChatTheme }>` padding: 4px 8px; margin: 8px 0; - border-radius: ${(props) => props.theme.borderRadius.modalInnerComponents}; - background: ${(props) => props.theme.backgroundColor.modalHoverBackground}; + border-radius: ${(props) => props.theme.borderRadius?.modalInnerComponents}; + background: ${(props) => props.theme.backgroundColor?.modalHoverBackground}; color: ${(props) => props.theme.textColor?.modalSubHeadingText}; `; const CriteriaGroup = styled(Section)<{ theme: IChatTheme }>` border: ${(props) => props.theme.border?.modalInnerComponents}; `; + +const ChainIconSVG = styled(Section)` + width: 20px; + height: 20px; + + svg, + svg image, + img { + width: 100%; + height: 100%; + } +`; diff --git a/packages/uiweb/src/lib/components/chat/CreateGroup/CreateGroupModal.tsx b/packages/uiweb/src/lib/components/chat/CreateGroup/CreateGroupModal.tsx index 9b2ad7045..5c7252688 100644 --- a/packages/uiweb/src/lib/components/chat/CreateGroup/CreateGroupModal.tsx +++ b/packages/uiweb/src/lib/components/chat/CreateGroup/CreateGroupModal.tsx @@ -13,7 +13,7 @@ import { Section, Span } from '../../reusables'; import { Button } from '../reusables'; import { CreateGroupType } from './CreateGroupType'; import useToast from '../reusables/NewToast'; -import { CreateGroupModalProps, IChatTheme } from '../exportedTypes'; +import { CreateGroupModalProps, IChatTheme, MODAL_BACKGROUND_TYPE, MODAL_POSITION_TYPE } from '../exportedTypes'; import useMediaQuery from '../../../hooks/useMediaQuery'; import { DefineCondtion } from './DefineCondition'; import AddCriteria from './AddCriteria'; @@ -26,6 +26,8 @@ import { import { Image } from '../../../config/styles'; import { ProfilePicture, device } from '../../../config'; +import { CriteriaValidationErrorType } from '../types'; +import AutoImageClipper from './AutoImageClipper'; export const CREATE_GROUP_STEP_KEYS = { INPUT_DETAILS: 1, @@ -45,6 +47,8 @@ interface GroupInputDetailsType { export const CreateGroupModal: React.FC = ({ onClose, + modalBackground = MODAL_BACKGROUND_TYPE.OVERLAY, + modalPositionType = MODAL_POSITION_TYPE.GLOBAL }) => { const [activeComponent, setActiveComponent] = useState( // replace it with info one @@ -69,11 +73,14 @@ export const CreateGroupModal: React.FC = ({ } }, [activeComponent]); + const useDummyGroupInfo = false; const [groupInputDetails, setGroupInputDetails] = useState({ - groupName: '', - groupDescription: '', - groupImage: '', + groupName: useDummyGroupInfo ? 'This is duumy group name' : '', + groupDescription: useDummyGroupInfo + ? 'This is dummy group description for testing' + : '', + groupImage: useDummyGroupInfo ? ProfilePicture : '', }); const renderComponent = () => { @@ -129,7 +136,7 @@ export const CreateGroupModal: React.FC = ({ }; return ( - + {renderComponent()} ); @@ -162,9 +169,12 @@ const CreateGroupDetail = ({ const groupInfoToast = useToast(); const { groupName, groupDescription, groupImage } = groupInputDetails; const theme = useContext(ThemeContext); - + const [validationErrors, setValidationErrors] = + useState({}); const fileUploadInputRef = useRef(null); const isMobile = useMediaQuery(device.mobileL); + const [isImageUploaded, setIsImageUploaded] = useState(false); + const [imageSrc, setImageSrc] = useState(); const handleChange = (e: Event) => { if (!(e.target instanceof HTMLInputElement)) { @@ -177,15 +187,22 @@ const CreateGroupDetail = ({ (e.target as HTMLInputElement).files && ((e.target as HTMLInputElement).files as FileList).length ) { + setIsImageUploaded(true); + setGroupInputDetails({ + groupDescription, + groupName, + groupImage: '', + }); const reader = new FileReader(); reader.readAsDataURL(e.target.files[0]); reader.onloadend = function () { - setGroupInputDetails({ - groupDescription, - groupName, - groupImage: reader.result as string, - }); + setImageSrc(reader.result as string); + // setGroupInputDetails({ + // groupDescription, + // groupName, + // groupImage: reader.result as string, + // }); }; } }; @@ -205,21 +222,19 @@ const CreateGroupDetail = ({ if (!skipVerify) { // verify name if (groupName.trim().length === 0) { - showError('Group Name is empty'); + setValidationErrors({ + groupName: 'Group name cannot be empty', + }); return; } // verify description if (groupDescription.trim().length === 0) { - showError('Group Description is empty'); + setValidationErrors({ + groupDescription: 'Group Description is empty', + }); return; } - - // verify description - // if (!groupImage) { - // showError("Group image can't be empty"); - // return; - // } } if (handleNext) { @@ -238,28 +253,45 @@ const CreateGroupDetail = ({
- {!groupImage && ( + {isImageUploaded ? ( + groupImage ? ( + + group image + + ) : ( + + setGroupInputDetails({ + groupDescription, + groupName, + groupImage: croppedImage, + }) + } + width={undefined} + height={undefined} + /> + ) + ) : ( )} - {groupImage && ( - - group image - - )} + handleChange(e as unknown as Event)} /> - - setGroupInputDetails({ - groupDescription, - groupName: e.target.value, - groupImage, - }) - } - /> - -