Skip to content

Commit

Permalink
wip: Initiate Multi Sig from FullPageScanner button
Browse files Browse the repository at this point in the history
  • Loading branch information
sdisalvo-crd committed May 8, 2024
1 parent a3a5fb6 commit f3f3d13
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const IdentifierStage1 = ({
};
updateConnections();
}

currentOperation === OperationType.MULTI_SIG_INITIATOR_INIT &&
handleInitiateMultiSig();
}, [groupMetadata, currentOperation, groupId, multiSigGroupCache]);

const handleDone = () => {
Expand Down Expand Up @@ -99,6 +102,7 @@ const IdentifierStage1 = ({
};

const handleInitiateMultiSig = () => {
dispatch(setCurrentOperation(OperationType.IDLE));
setState((prevState: IdentifierStageProps) => ({
...prevState,
scannedConections,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const IdentifierStage2 = ({
}: IdentifierStageProps) => {
const [selectedConnections, setSelectedConnections] = useState<
ConnectionShortDetails[]
>([]);
>(state.scannedConections);

const handleSelectConnection = (connection: ConnectionShortDetails) => {
let data = selectedConnections;
Expand Down Expand Up @@ -86,7 +86,7 @@ const IdentifierStage2 = ({
checked={selectedConnections.includes(connection)}
data-testid={`connection-checkbox-${index}`}
onIonChange={() => handleSelectConnection(connection)}
aria-label=""
aria-label={`connection-checkbox-${index}`}
/>
</IonLabel>
</IonItem>
Expand Down
70 changes: 36 additions & 34 deletions src/ui/components/Scanner/Scanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ const Scanner = forwardRef(
}, [currentOperation, currentRoute]);

const handlePrimaryButtonAction = () => {
// TODO: Add content to initiate Multi Sig
console.log("click primary");
stopScan();
dispatch(setCurrentOperation(OperationType.MULTI_SIG_INITIATOR_INIT));
handleReset && handleReset();
};

const handleSubmitPastedValue = () => {
Expand All @@ -169,38 +170,39 @@ const Scanner = forwardRef(

const RenderPageFooter = () => {
switch (currentOperation) {
case OperationType.MULTI_SIG_INITIATOR_SCAN:
return (
<PageFooter
pageId={componentId}
primaryButtonText={`${i18n.t("createidentifier.scan.initiate")}`}
primaryButtonAction={handlePrimaryButtonAction}
secondaryButtonText={`${i18n.t(
"createidentifier.scan.pasteoobi"
)}`}
secondaryButtonAction={() => setPasteModalIsOpen(true)}
/>
);
case OperationType.MULTI_SIG_RECEIVER_SCAN:
return (
<PageFooter
pageId={componentId}
secondaryButtonText={`${i18n.t(
"createidentifier.scan.pasteoobi"
)}`}
secondaryButtonAction={() => setPasteModalIsOpen(true)}
/>
);
default:
return (
<PageFooter
pageId={componentId}
secondaryButtonText={`${i18n.t(
"createidentifier.scan.pastecontents"
)}`}
secondaryButtonAction={() => setPasteModalIsOpen(true)}
/>
);
case OperationType.MULTI_SIG_INITIATOR_SCAN:
return (
<PageFooter
pageId={componentId}
primaryButtonText={`${i18n.t("createidentifier.scan.initiate")}`}
primaryButtonAction={handlePrimaryButtonAction}
primaryButtonDisabled={false} // @TODO: sdisalvo - Get list of scanned QR codes to check if we can enable this button
secondaryButtonText={`${i18n.t(
"createidentifier.scan.pasteoobi"
)}`}
secondaryButtonAction={() => setPasteModalIsOpen(true)}
/>
);
case OperationType.MULTI_SIG_RECEIVER_SCAN:
return (
<PageFooter
pageId={componentId}
secondaryButtonText={`${i18n.t(
"createidentifier.scan.pasteoobi"
)}`}
secondaryButtonAction={() => setPasteModalIsOpen(true)}
/>
);
default:
return (
<PageFooter
pageId={componentId}
secondaryButtonText={`${i18n.t(
"createidentifier.scan.pastecontents"
)}`}
secondaryButtonAction={() => setPasteModalIsOpen(true)}
/>
);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/ui/globals/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum OperationType {
SHOW_SETTINGS = "showSettings",
MULTI_SIG_INITIATOR_SCAN = "multiSigInitiatorScan",
MULTI_SIG_RECEIVER_SCAN = "multiSigReceiverScan",
MULTI_SIG_INITIATOR_INIT = "multiSigInitiatorInit",
}

enum ToastMsgType {
Expand Down
1 change: 0 additions & 1 deletion src/ui/pages/FullPageScanner/FullPageScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const FullPageScanner = ({ showScan, setShowScan }: FullPageScannerProps) => {

const handleReset = () => {
setShowScan(false);
dispatch(setCurrentOperation(OperationType.IDLE));
scannerRef.current?.stopScan();
document?.querySelector("body")?.classList.remove("full-page-scanner");
document
Expand Down

0 comments on commit f3f3d13

Please sign in to comment.