Просмотр исходного кода

Properly display payment methods on creation

Mauricio Araujo 2 лет назад
Родитель
Сommit
c7802984cf
1 измененных файлов с 21 добавлено и 0 удалено
  1. 21 0
      dashboard/src/main/home/project-settings/BillingPage.tsx

+ 21 - 0
dashboard/src/main/home/project-settings/BillingPage.tsx

@@ -29,6 +29,7 @@ function BillingPage() {
     })();
   }, []);
 
+<<<<<<< Updated upstream
   if (shouldCreate) {
     return (
       <BillingModal
@@ -37,6 +38,15 @@ function BillingPage() {
         project_id={currentProject?.id}
       />
     );
+=======
+  const onCreate = async () => {
+    // Refetch the payment method list since Stripe won't return the newly
+    // created payment method
+    const listResponse = await api.listPaymentMethod("<token>", {}, { project_id: currentProject?.id })
+    const paymentMethodList = listResponse.data === null ? [] : listResponse.data
+    setPaymentMethods(paymentMethodList)
+    setShouldCreate(false)
+>>>>>>> Stashed changes
   }
 
   const deletePaymentMethod = async (paymentMethod) => {
@@ -50,6 +60,17 @@ function BillingPage() {
     setPaymentMethods(paymentMethods.filter(elem => elem !== paymentMethod))
   }
 
+  if (shouldCreate) {
+    return (
+      <BillingModal
+        onCreate={onCreate}
+        back={() => setShouldCreate(false)}
+        project_id={currentProject?.id}
+        defaultValues={null}
+      />
+    );
+  }
+
   return (
     <div style={{ height: "1000px" }}>
       <BillingModalWrapper>