-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add BYOW step in flow #407
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
Open
saloniGargFEDev
wants to merge
14
commits into
eclipse-tractusx:main
Choose a base branch
from
Cofinity-X:feat/implement-BYOW-step
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+472
−48
Open
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2e35adc
feat: add BYOW step in flow
saloniGargFEDev 52b1d9f
fix: added generic font-family
saloniGargFEDev 193c8be
fix: formatting issue fixed
saloniGargFEDev 740be65
fix: revert unrelated file change
saloniGargFEDev 022bfda
fix:sonar issues and valid api call instance
saloniGargFEDev 1af7e7b
fix:remove unnecesarry copyright line and remove extra space from ENV…
saloniGargFEDev 7e79fb7
fix:sonar issue
saloniGargFEDev e45644d
fix:sonar issue
saloniGargFEDev a87ba72
Update index.html
saloniGargFEDev e3d6159
Update src/state/features/applicationWallet/applicationWalletApiSlice.ts
saloniGargFEDev 8090a02
Update src/components/cax-wallet.tsx
saloniGargFEDev bc43d1f
fix:snackbar should appear everytime an error is thrown
saloniGargFEDev ad3f3fb
Merge branch 'feat/implement-BYOW-step' of https://github.com/Cofinit…
saloniGargFEDev 821dec4
fix:formatting issues
saloniGargFEDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2025 Cofinity-X GmbH | ||
dhiren-singh-007 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * Copyright (c) 2025 Contributors to the Eclipse Foundation | ||
| * | ||
saloniGargFEDev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License, Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0. | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| * License for the specific language governing permissions and limitations | ||
| * under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
| import { useTranslation } from 'react-i18next' | ||
| import { useState, useCallback, useEffect } from 'react' | ||
| import { FooterButton } from './footerButton' | ||
| import { useDispatch, useSelector } from 'react-redux' | ||
| import { Row } from 'react-bootstrap' | ||
| import { | ||
| addCurrentStep, | ||
| getCurrentStep, | ||
| } from '../state/features/user/userApiSlice' | ||
| import { Notify } from './Snackbar' | ||
| import StepHeader from './StepHeader' | ||
| import FormGroup from '@mui/material/FormGroup' | ||
| import FormControlLabel from '@mui/material/FormControlLabel' | ||
| import Checkbox from '@mui/material/Checkbox' | ||
| import TextField from '@mui/material/TextField' | ||
| import { useValidateDidMutation } from '../state/features/applicationWallet/applicationWalletApiSlice' | ||
| import { DataErrorCodes } from '../helpers/DataError' | ||
|
|
||
| export const WalletCax = () => { | ||
| const { t } = useTranslation() | ||
| const dispatch = useDispatch() | ||
| const [loading, setLoading] = useState(false) | ||
| const [apiError, setApiError] = useState(false) | ||
| const [message, setMessage] = useState('') | ||
|
|
||
| const currentActiveStep = useSelector(getCurrentStep) | ||
|
|
||
| const [nextClicked, setNextClicked] = useState(false) | ||
| const [isChecked, setIsChecked] = useState(false) | ||
| const [did, setDid] = useState('') | ||
| const [ | ||
| validateDidTrigger, | ||
| { error: didValidationError, isLoading: isValidating }, | ||
| ] = useValidateDidMutation() | ||
| const didTrimmed = did.trim() | ||
| const isNextDisabled = isChecked && didTrimmed.length === 0 | ||
| const LS_KEY_WALLET_DID = 'registration.wallet.did' | ||
|
|
||
| const backClick = useCallback(() => { | ||
| dispatch(addCurrentStep(currentActiveStep - 1)) | ||
| }, [dispatch, currentActiveStep]) | ||
|
|
||
| const handleCheckboxChange = useCallback((e) => { | ||
| const checked = e.target.checked | ||
| setIsChecked(checked) | ||
| if (!checked) { | ||
| setDid('') | ||
| } | ||
| }, []) | ||
|
|
||
| const handleDidChange = useCallback((e) => { | ||
| setDid(e.target.value) | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| const stored = window.localStorage.getItem(LS_KEY_WALLET_DID) || '' | ||
| setDid(stored) | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| window.localStorage.setItem(LS_KEY_WALLET_DID, did) | ||
| }, [did]) | ||
|
|
||
| const nextClick = useCallback(async () => { | ||
| if (isNextDisabled) return | ||
| if (loading) return | ||
| setNextClicked(true) | ||
| try { | ||
| if (isChecked) { | ||
| setLoading(true) | ||
| await validateDidTrigger(didTrimmed).unwrap() | ||
| } | ||
| dispatch(addCurrentStep(currentActiveStep + 1)) | ||
| } catch (err) { | ||
| //backend is sending 400 as response whenever an invalid DID is being given | ||
| if (err.status == 400) { | ||
| setMessage(t('wallet.didValidationFailed')) | ||
| } | ||
|
|
||
| DataErrorCodes.includes(err.status) | ||
| ? setMessage(t(`ErrorMessage.${err.status}`)) | ||
| : setMessage(t('ErrorMessage.default')) | ||
| setApiError(true) | ||
| setLoading(false) | ||
| } | ||
| }, [ | ||
| isNextDisabled, | ||
| validateDidTrigger, | ||
| didTrimmed, | ||
| dispatch, | ||
| currentActiveStep, | ||
| ]) | ||
|
|
||
| const [notifyError, setNotifyError] = useState(false) | ||
| useEffect(() => { | ||
| if (nextClicked && (didValidationError || apiError)) { | ||
| setNotifyError(true) | ||
| } else { | ||
| setNotifyError(false) | ||
| } | ||
| }, [nextClicked, didValidationError, apiError]) | ||
|
|
||
| const renderSnackbar = () => { | ||
| return <Notify message={message} /> | ||
| } | ||
|
|
||
| const issuerId = (ENV as any).ISSUER_ID | ||
|
|
||
| return ( | ||
| <> | ||
| <div className="mx-auto col-9 container-registration"> | ||
| <StepHeader | ||
| step={currentActiveStep} | ||
| stepName={t('wallet.title')} | ||
| stepDescription={t('wallet.subtitle')} | ||
| additionalDescription={t('wallet.optional')} | ||
| className="wallet-header" | ||
| /> | ||
| <div className="mx-auto col-9"> | ||
| <FormGroup className="col-12 wallet-page-checkbox"> | ||
| <FormControlLabel | ||
| control={ | ||
| <Checkbox | ||
| checked={isChecked} | ||
| onChange={handleCheckboxChange} | ||
| inputProps={{ 'aria-label': t('wallet.userAgreementText') }} | ||
| /> | ||
| } | ||
| label={t('wallet.userAgreementText')} | ||
| /> | ||
| </FormGroup> | ||
| <Row className="col-12"> | ||
| <label htmlFor="wallet-did" className="did-label"> | ||
| {t('wallet.didLabel')} | ||
| </label> | ||
| <TextField | ||
| id="wallet-did" | ||
| value={did} | ||
| onChange={handleDidChange} | ||
| disabled={!isChecked} | ||
| placeholder="did:web:<URI>" | ||
| variant="filled" | ||
| className="did-input" | ||
| error={false} | ||
| helperText=" " | ||
| fullWidth | ||
| /> | ||
| {isChecked && ( | ||
| <div className="issuer-cred-info-container"> | ||
| <div className="issuer-cred-info"> | ||
| {t('wallet.issuerCredsInfo')} | ||
| </div> | ||
| <span className="issuer-cred-id">{issuerId}</span>{' '} | ||
| </div> | ||
| )} | ||
| </Row> | ||
| </div> | ||
| </div> | ||
|
|
||
| <FooterButton | ||
| labelNext={loading ? t('button.validating') : t('button.next')} | ||
| labelBack={t('button.back')} | ||
| handleBackClick={backClick} | ||
| handleNextClick={nextClick} | ||
| loading={loading} | ||
| disabled={isNextDisabled || isValidating} | ||
| helpUrl={ | ||
| '/documentation/?path=user%2F01.+Onboarding%2F02.+Registration%2F02.+Add+Company+Data.md' | ||
| } | ||
| /> | ||
| {notifyError && renderSnackbar()} | ||
| </> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export {} | ||
|
|
||
| declare global { | ||
| const ENV: { | ||
| PORTAL_ASSETS_URL: string | ||
| PORTAL_BACKEND_URL: string | ||
| CENTRALIDP_URL: string | ||
| REALM: string | ||
| CLIENT_ID_REGISTRATION: string | ||
| ISSUER_ID: string | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.