Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partner Config: create and manage CMAccount #245

Merged
merged 34 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
32783b1
chore: Update docker-compose commands in cypress.yml
Ysrbolles Aug 5, 2024
e4cca41
Merge pull request #225 from chain4travel/fix-cypress-docker-tests
Ysrbolles Sep 4, 2024
20fd048
feat: Update og:image and twitter:image meta tags to use preview.jpg …
Ysrbolles Sep 10, 2024
f89e70a
feat(suite): add CMAccount creation functionality and a new partners …
aeddaqqa Sep 12, 2024
5788a44
Refactor social media links and icons in footer
Ysrbolles Sep 12, 2024
b555faf
Refactor social media links and icons in footer
Ysrbolles Sep 12, 2024
80f0969
Refactor API call in Footer component
Ysrbolles Sep 12, 2024
d87ee2b
Merge pull request #233 from chain4travel/change-thumblnail
Ysrbolles Sep 13, 2024
155f099
Merge pull request #236 from chain4travel/integrate-footer-API
Ysrbolles Sep 13, 2024
292ace3
refactor: fix compiling issue
aeddaqqa Sep 15, 2024
c4299a8
feat(MyMessenger): add my messenger view and withdraw model
aeddaqqa Sep 15, 2024
58c7083
feat(partnerConfig): add withdraw modal wich input checks
aeddaqqa Sep 15, 2024
485125c
feat(partnerConfig): add upgrade CMAccount
aeddaqqa Sep 16, 2024
6bb2c33
fix(partnerConfiguration): fix creating CMAccount with withdraw role …
aeddaqqa Sep 17, 2024
7aff61d
fix(partnerConfig): fix removing wanted services
aeddaqqa Sep 17, 2024
0923b9e
fix(partnerConfig): add init after checking for selected network
aeddaqqa Sep 17, 2024
125f855
Merge pull request #235 from chain4travel/aeddaqqa/partner-config-v2
aeddaqqa Sep 17, 2024
9fcd438
fix(partnerConfig): address multiple issues
aeddaqqa Sep 18, 2024
b1b7196
feat(partnerConfig): add matching partners functionality
aeddaqqa Sep 19, 2024
21957ad
feat(partnerConfig): ad matching partners and on messenger filter
aeddaqqa Sep 20, 2024
f25d434
fix(partnerConfig): add alerts for estimating creation of CMAccount &…
aeddaqqa Sep 20, 2024
4a4abaf
Merge pull request #237 from chain4travel/aeddaqqa/partner-config-v2
aeddaqqa Sep 20, 2024
d9b1656
fix(partnerConfig): fix matching partner with current logged in wallet
aeddaqqa Sep 20, 2024
0bcbe0f
Merge pull request #238 from chain4travel/aeddaqqa/partner-config-v2
aeddaqqa Sep 20, 2024
c2cf5ac
fix(partnerConfig): adjustment of styling and text modifications
aeddaqqa Sep 24, 2024
2c9a8c2
Merge pull request #239 from chain4travel/aeddaqqa/partner-config-v2
aeddaqqa Sep 24, 2024
b511e18
fix(partnerConfig): fix typo
aeddaqqa Sep 24, 2024
22cfab2
fix(partnerConfig): small adjustment to infos and matching email body
aeddaqqa Sep 25, 2024
92511ab
Merge pull request #241 from chain4travel/aeddaqqa/partner-config-fixes
aeddaqqa Sep 25, 2024
7a46b21
fix(partnerConfig): fix typo
aeddaqqa Sep 25, 2024
9485948
Merge pull request #242 from chain4travel/aeddaqqa/partner-config-fixes
aeddaqqa Sep 25, 2024
0944a33
fix(partnerConfig): adjust baseUrl for partners depending on the sele…
aeddaqqa Sep 25, 2024
11f0cca
Merge pull request #244 from chain4travel/aeddaqqa/partner-config-fixes
aeddaqqa Sep 25, 2024
da09ebe
Merge branch 'suite-c4t' into suite
mo-c4t Sep 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@
"@emotion/styled": "^11.10.5",
"@mdi/js": "^7.0.96",
"@mdi/react": "^1.6.1",
"@reduxjs/toolkit": "^1.8.1",
"@testing-library/dom": "^8.19.0",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@mui/system": "^5.15.11",
"@reduxjs/toolkit": "^1.8.1",
"@testing-library/dom": "^8.19.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.0.1",
"@testing-library/user-event": "^14.1.1",
"@types/big.js": "^6.2.2",
"@types/ethereum-protocol": "^1.0.5",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.189",
"@types/node": "^17.0.25",
Expand All @@ -61,6 +63,7 @@
"formik": "^2.2.9",
"framer-motion": "^8.4.3",
"html-webpack-plugin": "^5.3.2",
"json-loader": "^0.5.7",
"lodash": "^4.17.21",
"path": "^0.12.7",
"postcss": "^8.2.1",
Expand All @@ -79,9 +82,11 @@
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.3.1",
"webpack-merge": "^5.8.0",
"yup": "^0.32.11"
"yup": "^0.32.11",
"ethers": "^6.13.2"
},
"dependencies": {
"big.js": "^6.2.1",
"react": "^18.2.0",
"react-circle-flags": "^0.0.18",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/>
<title>Camino Suite Application</title>

<meta property="og:image" content="/preview.png" />
<meta property="og:image" content="/preview.jpg" />
<meta
property="og:title"
content="Camino Suite Camino Suite Application: Your Gateway to Revolutionary Travel"
Expand All @@ -32,7 +32,7 @@
name="twitter:description"
content="Camino Suite for everything Camino by Chain4Travel."
/>
<meta name="twitter:image" content="/preview.png" />
<meta name="twitter:image" content="/preview.jpg" />
<meta name="twitter:image:alt" content="Camino Suite Application" />

<link rel="preconnect" href="https://cdn.jsdelivr.net" />
Expand Down
Binary file added public/preview.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/preview.png
Binary file not shown.
2 changes: 2 additions & 0 deletions src/@types/partners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ export interface PartnerDataType {
}

export interface AttributesType {
cChainAddress?: string
contactEmail?: string
companyName?: string
companyCountry?: string
companyWebsite?: string
contactFirstname?: string
contactLastname?: string
contactPhone?: string
pChainAddresses?: string[]
pChainAddress?: string
companyShortDescription?: string
companyLongDescription?: string
Expand Down
93 changes: 93 additions & 0 deletions src/components/Alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Box, SxProps, Typography } from '@mui/material'
import React from 'react'

const Alert = ({
variant,
title,
content,
sx,
}: {
variant: 'info' | 'negative' | 'warning'
title?: string
content: string
sx?: SxProps
}) => {
return (
<Box
sx={{
display: 'flex',
gap: '14px',
padding: '16px',
border: '1px solid',
borderColor:
variant === 'info'
? 'rgba(0, 133, 255, 0.5)'
: variant === 'warning'
? 'rgba(229, 162, 31, 0.5)'
: 'rgba(229, 67, 31, 0.5)',
background:
variant === 'info'
? 'rgba(0, 133, 255, 0.05)'
: variant === 'warning'
? 'rgba(229, 162, 31, 0.05)'
: 'rgba(229, 67, 31, 0.05)',
borderRadius: '6px',
maxWidth: '350px',
...sx,
...(!title && { alignItems: 'center' }),
}}
>
<Box sx={{ ...(!title && { display: 'flex', alignItems: 'center' }) }}>
{variant === 'info' && (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 22C17.5 22 22 17.5 22 12C22 6.5 17.5 2 12 2C6.5 2 2 6.5 2 12C2 17.5 6.5 22 12 22ZM11 7H13V9H11V7ZM14 17H10V15H11V13H10V11H13V15H14V17Z"
fill="#0085FF"
/>
</svg>
)}
{variant === 'negative' && (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 2C17.53 2 22 6.47 22 12C22 17.53 17.53 22 12 22C6.47 22 2 17.53 2 12C2 6.47 6.47 2 12 2ZM15.59 7L12 10.59L8.41 7L7 8.41L10.59 12L7 15.59L8.41 17L12 13.41L15.59 17L17 15.59L13.41 12L17 8.41L15.59 7Z"
fill="#E5431F"
/>
</svg>
)}
{variant === 'warning' && (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z" fill="#E5A21F" />
</svg>
)}
</Box>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
{title && (
<Typography variant="body2" fontWeight={600}>
{title}
</Typography>
)}
{content && <Typography variant="caption">{content}</Typography>}
</Box>
</Box>
)
}

export default Alert
137 changes: 137 additions & 0 deletions src/components/CamInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import Big from 'big.js'
import BN from 'bn.js'
import React, { useCallback, useEffect, useState } from 'react'

Big.PE = 32

function bnToBig(val, denomination) {
return new Big(val.toString()).div(Math.pow(10, denomination))
}

function bigToBN(val, denomination) {
return new BN(val.mul(Math.pow(10, denomination)).toString())
}

const DecimalInput = ({
denomination = 0,
max = null,
min = 0,
step = null,
placeholder,
value,
initial = null,
onChange,
}) => {
const [val, setVal] = useState(bnToString(initial))

Check warning on line 25 in src/components/CamInput.tsx

View workflow job for this annotation

GitHub Actions / yarn-build

'bnToString' was used before it was defined

Check warning on line 25 in src/components/CamInput.tsx

View workflow job for this annotation

GitHub Actions / yarn-build

'bnToString' was used before it was defined

const bnToString = useCallback(
val => {
return val ? bnToBig(val, denomination).toString() : null
},
[denomination],
)

const stringToBN = useCallback(
strVal => {
return bigToBN(new Big(strVal), denomination)
},
[denomination],
)

const maxNumBN = max
const maxNumString = bnToString(maxNumBN)

const stepNum = (() => {
if (!step) {
if (denomination >= 2) {
return 0.01
} else {
return Math.pow(10, -denomination)
}
}
try {
return bnToString(step)
} catch (e) {
console.error(e)
return '0.01'
}
})()

useEffect(() => {
if (!val) {
onChange(new BN(0))
return
}
try {
let splitVal = val.toString().split('.')
let wholeVal = splitVal[0]
let denomVal = splitVal[1]
if (denomVal) {
if (denomVal.length > denomination) {
let newDenom = denomVal.substring(0, denomination)
setVal(`${wholeVal}.${newDenom}`)
return
}
}
} catch (e) {
console.log(e)
}
if (parseFloat(val) < min) {
setVal(min.toString())
return
}
let valBn = stringToBN(val)
onChange(valBn)
}, [val, denomination, min, onChange, stringToBN])

useEffect(() => {
setVal(bnToString(value))
}, [value, bnToString])

const handleChange = e => {
setVal(e.target.value)
}

const handleBlur = () => {
// If number is above max amount, correct it
const valBig = Big(val || '0')
const valBN = bigToBN(valBig, denomination)
if (maxNumBN != null) {
if (valBN.gt(maxNumBN)) {
setVal(bnToString(maxNumBN))
}
}
}

const maxout = () => {

Check warning on line 106 in src/components/CamInput.tsx

View workflow job for this annotation

GitHub Actions / yarn-build

'maxout' is assigned a value but never used

Check warning on line 106 in src/components/CamInput.tsx

View workflow job for this annotation

GitHub Actions / yarn-build

'maxout' is assigned a value but never used
if (maxNumBN != null) {
setVal(bnToString(maxNumBN))
}
}

const clear = () => {

Check warning on line 112 in src/components/CamInput.tsx

View workflow job for this annotation

GitHub Actions / yarn-build

'clear' is assigned a value but never used

Check warning on line 112 in src/components/CamInput.tsx

View workflow job for this annotation

GitHub Actions / yarn-build

'clear' is assigned a value but never used
setVal(undefined)
}

return (
<input
type="number"
inputMode="decimal"
placeholder={placeholder}
value={val}
min={min}
max={maxNumString}
step={stepNum}
onChange={handleChange}
onBlur={handleBlur}
style={{
textAlign: 'right',
outline: 'none',
WebkitAppearance: 'none',
MozAppearance: 'textfield',
}}
/>
)
}

export default DecimalInput
Loading
Loading