From a62deeef5d0cbe5fa98be390eac0e03bcae0f0b5 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Wed, 10 Nov 2021 10:20:52 -0300
Subject: prettier

---
 .../anastasis-webui/src/pages/home/SolveScreen.tsx | 196 ++++++++++++++-------
 1 file changed, 132 insertions(+), 64 deletions(-)

(limited to 'packages/anastasis-webui/src/pages/home/SolveScreen.tsx')

diff --git a/packages/anastasis-webui/src/pages/home/SolveScreen.tsx b/packages/anastasis-webui/src/pages/home/SolveScreen.tsx
index 5e17c9aa1..b87dad2ce 100644
--- a/packages/anastasis-webui/src/pages/home/SolveScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/SolveScreen.tsx
@@ -2,76 +2,126 @@ import { h, VNode } from "preact";
 import { AnastasisClientFrame } from ".";
 import {
   ChallengeFeedback,
-  ChallengeFeedbackStatus
+  ChallengeFeedbackStatus,
 } from "../../../../anastasis-core/lib";
 import { Notifications } from "../../components/Notifications";
 import { useAnastasisContext } from "../../context/anastasis";
 import { authMethods, KnownAuthMethods } from "./authMethod";
 
-export function SolveOverviewFeedbackDisplay(props: { feedback?: ChallengeFeedback }): VNode {
+export function SolveOverviewFeedbackDisplay(props: {
+  feedback?: ChallengeFeedback;
+}): VNode {
   const { feedback } = props;
   if (!feedback) {
     return <div />;
   }
   switch (feedback.state) {
     case ChallengeFeedbackStatus.Message:
-      return (<Notifications notifications={[{
-        type: "INFO",
-        message: `Message from provider`,
-        description: feedback.message
-      }]} />);
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "INFO",
+              message: `Message from provider`,
+              description: feedback.message,
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.Payment:
-      return <Notifications notifications={[{
-        type: "INFO",
-        message: `Message from provider`,
-        description: <span>
-          To pay you can <a href={feedback.taler_pay_uri}>click here</a>
-        </span>
-      }]} />
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "INFO",
+              message: `Message from provider`,
+              description: (
+                <span>
+                  To pay you can <a href={feedback.taler_pay_uri}>click here</a>
+                </span>
+              ),
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.AuthIban:
-      return <Notifications notifications={[{
-        type: "INFO",
-        message: `Message from provider`,
-        description: `Need to send a wire transfer to "${feedback.business_name}"`
-      }]} />;
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "INFO",
+              message: `Message from provider`,
+              description: `Need to send a wire transfer to "${feedback.business_name}"`,
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.ServerFailure:
-      return (<Notifications notifications={[{
-        type: "ERROR",
-        message: `Server error: Code ${feedback.http_status}`,
-        description: feedback.error_response
-      }]} />);
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "ERROR",
+              message: `Server error: Code ${feedback.http_status}`,
+              description: feedback.error_response,
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.RateLimitExceeded:
-      return (<Notifications notifications={[{
-        type: "ERROR",
-        message: `Message from provider`,
-        description: "There were to many failed attempts."
-      }]} />);
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "ERROR",
+              message: `Message from provider`,
+              description: "There were to many failed attempts.",
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.Redirect:
-      return (<Notifications notifications={[{
-        type: "INFO",
-        message: `Message from provider`,
-        description: <span>
-          Please visit this link: <a>{feedback.redirect_url}</a>
-        </span>
-      }]} />);
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "INFO",
+              message: `Message from provider`,
+              description: (
+                <span>
+                  Please visit this link: <a>{feedback.redirect_url}</a>
+                </span>
+              ),
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.Unsupported:
-      return (<Notifications notifications={[{
-        type: "ERROR",
-        message: `This client doesn't support solving this type of challenge`,
-        description: `Use another version or contact the provider. Type of challenge "${feedback.unsupported_method}"`
-      }]} />);
+      return (
+        <Notifications
+          notifications={[
+            {
+              type: "ERROR",
+              message: `This client doesn't support solving this type of challenge`,
+              description: `Use another version or contact the provider. Type of challenge "${feedback.unsupported_method}"`,
+            },
+          ]}
+        />
+      );
     case ChallengeFeedbackStatus.TruthUnknown:
-      return (<Notifications notifications={[{
-        type: "ERROR",
-        message: `Provider doesn't recognize the type of challenge`,
-        description: "Contact the provider for further information"
-      }]} />);
-    default:
       return (
-        <div>
-          <pre>{JSON.stringify(feedback)}</pre>
-        </div>
+        <Notifications
+          notifications={[
+            {
+              type: "ERROR",
+              message: `Provider doesn't recognize the type of challenge`,
+              description: "Contact the provider for further information",
+            },
+          ]}
+        />
       );
+    default:
+      return <div />;
   }
 }
 
@@ -110,8 +160,16 @@ export function SolveScreen(): VNode {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
-        <div style={{ marginTop: '2em', display: 'flex', justifyContent: 'space-between' }}>
-          <button class="button" onClick={() => reducer.back()}>Back</button>
+        <div
+          style={{
+            marginTop: "2em",
+            display: "flex",
+            justifyContent: "space-between",
+          }}
+        >
+          <button class="button" onClick={() => reducer.back()}>
+            Back
+          </button>
         </div>
       </AnastasisClientFrame>
     );
@@ -120,26 +178,36 @@ export function SolveScreen(): VNode {
     return (
       <AnastasisClientFrame hideNav title="Not implemented">
         <p>
-          The challenge selected is not supported for this UI. Please update this
-          version or try using another policy.
+          The challenge selected is not supported for this UI. Please update
+          this version or try using another policy.
         </p>
-        {reducer &&
-          <div style={{ marginTop: '2em', display: 'flex', justifyContent: 'space-between' }}>
-            <button class="button" onClick={() => reducer.back()}>Back</button>
+        {reducer && (
+          <div
+            style={{
+              marginTop: "2em",
+              display: "flex",
+              justifyContent: "space-between",
+            }}
+          >
+            <button class="button" onClick={() => reducer.back()}>
+              Back
+            </button>
           </div>
-        }
+        )}
       </AnastasisClientFrame>
     );
   }
 
-
   const chArr = reducer.currentReducerState.recovery_information.challenges;
   const selectedUuid = reducer.currentReducerState.selected_challenge_uuid;
-  const selectedChallenge = chArr.find(ch => ch.uuid === selectedUuid)
+  const selectedChallenge = chArr.find((ch) => ch.uuid === selectedUuid);
 
-  const SolveDialog = !selectedChallenge || !authMethods[selectedChallenge.type as KnownAuthMethods] ?
-    SolveNotImplemented :
-    authMethods[selectedChallenge.type as KnownAuthMethods].solve ?? SolveNotImplemented
+  const SolveDialog =
+    !selectedChallenge ||
+    !authMethods[selectedChallenge.type as KnownAuthMethods]
+      ? SolveNotImplemented
+      : authMethods[selectedChallenge.type as KnownAuthMethods].solve ??
+        SolveNotImplemented;
 
-  return <SolveDialog id={selectedUuid} />
+  return <SolveDialog id={selectedUuid} />;
 }
-- 
cgit v1.2.3

