Skip to content

Commit

Permalink
fix: create wallet UI for shared and dedicated agents. (#738)
Browse files Browse the repository at this point in the history
* fix: create did ui fixes

Signed-off-by: pranalidhanavade <[email protected]>

* fix: sonarcloud issues

Signed-off-by: pranalidhanavade <[email protected]>

---------

Signed-off-by: pranalidhanavade <[email protected]>
  • Loading branch information
pranalidhanavade authored Aug 26, 2024
1 parent 579d269 commit a22ec34
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/Resources/Schema/SchemasList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { checkEcosystem } from '../../../config/ecosystem';
import type { ICheckEcosystem } from '../../../config/ecosystem';

import { Create, SchemaEndorsement } from '../../Issuance/Constant';
import { DidMethod, SchemaType } from '../../../common/enums';
import { DidMethod, SchemaType, SchemaTypes } from '../../../common/enums';

const SchemaList = (props: {
schemaSelectionCallback: (
Expand Down Expand Up @@ -57,6 +57,8 @@ const SchemaList = (props: {
const [totalItem, setTotalItem] = useState(0);
const [isEcosystemData, setIsEcosystemData] = useState<ICheckEcosystem>();
const [searchValue, setSearchValue] = useState('');
const [schemaType, setSchemaType] = useState('');

const [w3cSchema,setW3CSchema]= useState<boolean>(false);
const [isNoLedger,setisNoLedger]= useState<boolean>(false);

Expand All @@ -70,7 +72,7 @@ const SchemaList = (props: {
setLoading(true);
let schemaList;
if (allSchemaFlag) {
schemaList = await getAllSchemas(schemaListAPIParameter, SchemaType.INDY);
schemaList = await getAllSchemas(schemaListAPIParameter, schemaType);
} else {
schemaList = await getAllSchemasByOrgId(
schemaListAPIParameter,
Expand Down Expand Up @@ -229,9 +231,11 @@ const SchemaList = (props: {
}
if (did.includes(DidMethod.POLYGON) || did.includes(DidMethod.KEY) || did.includes(DidMethod.WEB)) {
setW3CSchema(true);
setSchemaType(SchemaTypes.schema_W3C)
}
if (did.includes(DidMethod.INDY)) {
setW3CSchema(false);
setSchemaType(SchemaTypes.schema_INDY)
}
if (did.includes(DidMethod.KEY) || did.includes(DidMethod.WEB)) {
setisNoLedger(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import SetDomainValueInput from './SetDomainValueInput';
import SetPrivateKeyValueInput from './SetPrivateKeyValue';
import { getOrganizationById, setAgentConfigDetails } from '../../../api/organization';
import type { IDedicatedAgentConfig} from '../interfaces';
import React from 'react';

const RequiredAsterisk = () => <span className="text-xs text-red-500">*</span>

Expand All @@ -36,6 +37,7 @@ const DedicatedAgentForm = ({
const [selectedLedger, setSelectedLedger] = useState('');
const [selectedDid, setSelectedDid] = useState('');
const [selectedMethod, setSelectedMethod]=useState('')
const [isSelectedNetwork, setIsSelectedNetwork]=useState('')
const [privateKeyValue, setPrivateKeyValue] = useState<string>('');
const [domainValue, setDomainValue] = useState<string>('');
const [isLoading, setIsLoading] = useState<boolean>(false);
Expand Down Expand Up @@ -118,6 +120,7 @@ const DedicatedAgentForm = ({
const handleLedgerChanges = (e: ChangeEvent<HTMLInputElement>) => {
setSelectedLedger(e.target.value);
setSelectedMethod('');
setIsSelectedNetwork('');
setSelectedDid('');
};
const handleMethodChanges = (e: ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -248,6 +251,7 @@ const networkRenderOptions = (formikHandlers: { handleChange: (e: React.ChangeEv
onChange={(e) => {
formikHandlers.handleChange(e);
handleNetworkChanges(e);
setIsSelectedNetwork(networks[network])
}}
className="mr-2"
/>
Expand All @@ -258,7 +262,19 @@ const networkRenderOptions = (formikHandlers: { handleChange: (e: React.ChangeEv
));
};

const isSubmitButtonDisabled = () => {
if (!selectedLedger) {
return true;
}
else if ((selectedLedger === Ledgers.POLYGON && !privateKeyValue) || (selectedLedger === Ledgers.INDY && (!selectedMethod || !isSelectedNetwork))) {
return true;
}
else if ((selectedLedger === Ledgers.NO_LEDGER && !selectedMethod) ||(selectedLedger === Ledgers.NO_LEDGER && selectedMethod === DidMethod.WEB && !domainValue)) {
return true;
}

return false;
};

return (
<>
Expand Down Expand Up @@ -565,6 +581,7 @@ const networkRenderOptions = (formikHandlers: { handleChange: (e: React.ChangeEv


<Button
disabled={isSubmitButtonDisabled()}
isProcessing={loading}
type="submit"
className='float-right mb-2 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:!bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const SharedAgentForm = ({
}: ISharedAgentForm) => {
const [haveDidShared, setHaveDidShared] = useState(false);
const [selectedLedger, setSelectedLedger] = useState('');
const [selectedMethod, setSelectedMethod] = useState('');
const [selectedMethod, setSelectedMethod] = useState('');
const [selectedNetwork, setSelectedNetwork] = useState('');
const [seedVal, setSeedVal] = useState('');
const [maskedSeedVal, setMaskedSeedVal] = useState('');
const [selectedDid, setSelectedDid] = useState('');
Expand Down Expand Up @@ -119,6 +120,7 @@ const SharedAgentForm = ({
const handleLedgerChange = (e: ChangeEvent<HTMLInputElement>) => {
setSelectedLedger(e.target.value);
setSelectedMethod('');
setSelectedNetwork('');
setSelectedDid('');
};

Expand Down Expand Up @@ -222,6 +224,7 @@ const SharedAgentForm = ({
onChange={(e) => {
formikHandlers.handleChange(e)
handleNetworkChange(e)
setSelectedNetwork(networks[network])
}}
className="mr-2"
/>
Expand All @@ -232,6 +235,21 @@ const SharedAgentForm = ({
));
};

const isSubmitDisabled = () => {
if (!selectedLedger) {
return true;
}
else if ((selectedLedger === Ledgers.POLYGON && !privateKeyValue) || (selectedLedger === Ledgers.INDY && (!selectedMethod || !selectedNetwork))) {
return true;
}
else if ((selectedLedger === Ledgers.NO_LEDGER && !selectedMethod) ||(selectedLedger === Ledgers.NO_LEDGER && selectedMethod === DidMethod.WEB && !domainValue)) {
return true;
}

return false;
};


return (
<div className="mt-4 flex-col gap-4">
<div className="bg-[#F4F4F4] dark:bg-gray-700 max-w-lg">
Expand Down Expand Up @@ -508,6 +526,7 @@ const SharedAgentForm = ({

<div className="w-full flex justify-end">
<Button
disabled={isSubmitDisabled()}
type="submit"
className="flex h-min p-0.5 focus:z-10 focus:outline-none border border-transparent enabled:hover:bg-cyan-800 dark:enabled:hover:bg-cyan-700 mt-4 text-base font-medium text-center text-white bg-primary-700 rounded-md hover:!bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"
>
Expand Down

0 comments on commit a22ec34

Please sign in to comment.