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

Prevent freeze when legalOfficersWithNonVoidIdentityLoc is empty. #569

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/loc/IdentityLocRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function IdentityLocRequest(props: Props) {
const [ invalidCompanyName, setInvalidCompanyName ] = useState<string>();
const { accounts } = useLogionChain();
const navigate = useNavigate();
const selectablelegalOfficers = useMemo(() => {
const selectableLegalOfficers = useMemo(() => {
const legalOfficersWithNonVoidIdentityLoc = locsState?.legalOfficersWithNonVoidIdentityLoc.map(lo => lo.account.address);
return availableLegalOfficers?.filter(lo => legalOfficersWithNonVoidIdentityLoc?.includes(lo.account.address) === false);
}, [ locsState?.legalOfficersWithNonVoidIdentityLoc, availableLegalOfficers ]);
Expand Down Expand Up @@ -120,7 +120,7 @@ export default function IdentityLocRequest(props: Props) {
<SelectLegalOfficer
legalOfficer={ legalOfficer }
legalOfficerNumber={ 1 }
legalOfficers={ selectablelegalOfficers || [] }
legalOfficers={ selectableLegalOfficers || [] }
mode="select"
otherLegalOfficer={ null }
setLegalOfficer={ setLegalOfficer }
Expand Down
6 changes: 3 additions & 3 deletions src/wallet-user/protection/SelectLegalOfficer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export default function SelectLegalOfficer(props: Props) {
const colors = props.colors !== undefined ? props.colors : colorTheme.frame;
const feedback = props.feedback ? props.feedback : "Required and different from other legal officer";
const { label } = props;
const [ legalOfficersOptions, setLegalOfficersOptions ] = useState<OptionType<ValidAccountId>[]>([]);
const [ legalOfficersOptions, setLegalOfficersOptions ] = useState<OptionType<ValidAccountId>[]>();

const legalOfficersByAddress: Record<string, LegalOfficerClass> = {};
props.legalOfficers.forEach(legalOfficer => {
legalOfficersByAddress[legalOfficer.account.address] = legalOfficer;
});

useEffect(() => {
if(legalOfficersOptions.length === 0) {
if(legalOfficersOptions === undefined) {
buildOptions(props.legalOfficers)
.then(options => setLegalOfficersOptions(options));
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function SelectLegalOfficer(props: Props) {
control={
<Select
isInvalid={ props.legalOfficer === null || (props.otherLegalOfficer !== null && props.legalOfficer.account.equals(props.otherLegalOfficer.account)) }
options={ legalOfficersOptions }
options={ legalOfficersOptions || [] }
value={ props.legalOfficer !== null ? props.legalOfficer.account : null}
onChange={ value => props.setLegalOfficer!(legalOfficersByAddress[value!.address] || null) }
disabled={ props.mode === "view" }
Expand Down
Loading