Skip to content

Commit

Permalink
feat: prevent creation of redundant IDLOC.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdethier committed May 7, 2024
1 parent 9d0e9cf commit 385b7be
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"@creativecommons/cc-assets": "^0.1.0",
"@logion/client": "^0.43.1-2",
"@logion/client": "^0.43.1-4",
"@logion/client-browser": "^0.3.5",
"@logion/crossmint": "^0.1.32",
"@logion/extension": "^0.8.0",
Expand Down
6 changes: 3 additions & 3 deletions src/loc/IdentityLocRequest.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GUILLAUME, oneLegalOfficer } from "../common/TestData";
import { shallowRender, clickByName } from "../tests";
import IdentityLocRequest from "./IdentityLocRequest";
import { fillInForm } from "../components/identity/IdentityFormTestHelper";
import { setMutateLocsState, setHasValidIdentityLoc, setLocsState } from "../wallet-user/__mocks__/UserContextMock";
import { setMutateLocsState, setHasNonVoidIdentityLoc, setLocsState } from "../wallet-user/__mocks__/UserContextMock";
import { navigate, setSearchParams } from '../__mocks__/ReactRouterMock';

jest.mock('../wallet-user/UserContext');
Expand All @@ -21,7 +21,7 @@ describe("IdentityLocRequest", () => {
beforeEach(() => {
jest.resetAllMocks();
setMutateLocsState(mutateLocsState);
setHasValidIdentityLoc(oneLegalOfficer);
setHasNonVoidIdentityLoc(oneLegalOfficer);
setSearchParams({
get: () => undefined,
})
Expand Down Expand Up @@ -75,7 +75,7 @@ describe("IdentityLocRequest", () => {
}),
} as DraftRequest;
const locsState = {
legalOfficersWithValidIdentityLoc: [ GUILLAUME ],
legalOfficersWithNonVoidIdentityLoc: [ GUILLAUME ],
requestIdentityLoc: () => Promise.resolve(draftRequest),
} as unknown as LocsState;
setLocsState(locsState);
Expand Down
10 changes: 5 additions & 5 deletions src/loc/IdentityLocRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export default function IdentityLocRequest(props: Props) {
const [ invalidCompanyName, setInvalidCompanyName ] = useState<string>();
const { accounts } = useLogionChain();
const navigate = useNavigate();
const legalOfficersWithoutValidIdentityLoc = useMemo(() => {
const legalOfficersWithValidIdentityLoc = locsState?.legalOfficersWithValidIdentityLoc.map(lo => lo.account.address);
return availableLegalOfficers?.filter(lo => legalOfficersWithValidIdentityLoc?.includes(lo.account.address) === false)
}, [ locsState?.legalOfficersWithValidIdentityLoc, availableLegalOfficers ]);
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 ]);
const [ sponsorshipId, setSponsorshipId ] = useState<UUID>();
const [ invalidSponsorshipId, setInvalidSponsorshipId ] = useState<string>();

Expand Down Expand Up @@ -120,7 +120,7 @@ export default function IdentityLocRequest(props: Props) {
<SelectLegalOfficer
legalOfficer={ legalOfficer }
legalOfficerNumber={ 1 }
legalOfficers={ legalOfficersWithoutValidIdentityLoc || [] }
legalOfficers={ selectablelegalOfficers || [] }
mode="select"
otherLegalOfficer={ null }
setLegalOfficer={ setLegalOfficer }
Expand Down
5 changes: 2 additions & 3 deletions src/wallet-user/__mocks__/UserContextMock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ export function setClosedVerifiedIssuerLocs(transactions: any[], collections: an
}
}


export function setHasValidIdentityLoc(legalOfficers: LegalOfficerClass[]) {
export function setHasNonVoidIdentityLoc(legalOfficers: LegalOfficerClass[]) {
locsState = {
legalOfficersWithValidIdentityLoc: legalOfficers
legalOfficersWithNonVoidIdentityLoc: legalOfficers
}
}

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3216,15 +3216,15 @@ __metadata:
languageName: node
linkType: hard

"@logion/client@npm:^0.43.1-2":
version: 0.43.1-2
resolution: "@logion/client@npm:0.43.1-2"
"@logion/client@npm:^0.43.1-4":
version: 0.43.1-4
resolution: "@logion/client@npm:0.43.1-4"
dependencies:
"@logion/node-api": ^0.29.0
axios: ^1.6.7
luxon: ^3.4.4
mime-db: ^1.52.0
checksum: 86d24ba8a4718aac96541e5a5684d5d47f1ee71321f89ed51156ccd86f3f8de7637f19f7c3f74ff826cad78dd68a27f2f5694dcd70b1be00bf72b04891ba0ed3
checksum: 959396385e6d42f5d5645c2a859c6fbc1a79fd237c54e5fb962338fac5a814e1071af4172dd02cf3370f7cb50bbcdac7af00fe99d9b26aba9f38b35647f0cbc4
languageName: node
linkType: hard

Expand Down Expand Up @@ -12106,7 +12106,7 @@ __metadata:
"@babel/preset-react": ^7.23.3
"@babel/preset-typescript": ^7.23.3
"@creativecommons/cc-assets": ^0.1.0
"@logion/client": ^0.43.1-2
"@logion/client": ^0.43.1-4
"@logion/client-browser": ^0.3.5
"@logion/crossmint": ^0.1.32
"@logion/extension": ^0.8.0
Expand Down

0 comments on commit 385b7be

Please sign in to comment.