Browse Source

Fix potential race condition, clean up copy, remove reset button

Rares Capilnar 2 years ago
parent
commit
3ff419b414

+ 6 - 20
src/admin/onboarding-flow/onboarding-flow.tsx

@@ -82,16 +82,16 @@ const OnboardingFlow = (props: ExtensionProps) => {
     navigate(`/a/products`);
   };
 
-  const setStepComplete = (step_id: STEP_ID) => {
+  const setStepComplete = (
+    step_id: STEP_ID,
+    extraData?: UpdateOnboardingStateInput
+  ) => {
     const next = STEP_FLOW[STEP_FLOW.findIndex(step => step === step_id) + 1];
-    updateServerState({ current_step: next });
-    // Also set local state in case we're reopening from "Next step" without changing the actual current step
-    setOpenStep(next);
+    updateServerState({ current_step: next, ...extraData });
   };
 
   const goToProductView = (product: any) => {
-    setStepComplete("create_product");
-    updateServerState({ product_id: product.id });
+    setStepComplete("create_product", { product_id: product.id });
     navigate(`/a/products/${product.id}`);
   };
 
@@ -183,20 +183,6 @@ const OnboardingFlow = (props: ExtensionProps) => {
                           Cancel Setup
                         </Button>
                       )}
-                      <Button
-                        variant="nuclear"
-                        size="small"
-                        onClick={() => {
-                          updateServerState({
-                            current_step: null,
-                            is_complete: null,
-                            product_id: null,
-                          });
-                          navigate("/a/products");
-                        }}
-                      >
-                        Reset flow (DEV)
-                      </Button>
                     </>
                   ) : (
                     <>

+ 0 - 1
src/admin/onboarding-flow/orders/orders-list.tsx

@@ -55,7 +55,6 @@ const OrdersList = ({ onNext, isComplete, data }: StepContentProps) => {
   return (
     <>
       <div className="py-4">
-        <p>We can now create an order.</p>
         <p>
           With a Product created, we can now place an Order. Click the button
           below to create a sample order.