diff --git a/frontend/pages/subscriptions.js b/frontend/pages/subscriptions.js index 54450d7d..a2afea4f 100644 --- a/frontend/pages/subscriptions.js +++ b/frontend/pages/subscriptions.js @@ -100,7 +100,7 @@ const Subscriptions = () => { Add new - + )} diff --git a/frontend/sample.env b/frontend/sample.env deleted file mode 100644 index 93aff9b8..00000000 --- a/frontend/sample.env +++ /dev/null @@ -1,7 +0,0 @@ -export REACT_APP_SIMIOTICS_SEARCH_URL=http://localhost:5000 -export REACT_APP_MIXPANEL_TOKEN="" -export REACT_APP_SIMIOTICS_AUTH_URL=http://localhost:7474 -export REACT_APP_SIMIOTICS_JOURNALS_URL=http://localhost:7475 -export REACT_APP_BUGOUT_CONTACTUS_TOKEN="" -export REACT_APP_BUGOUT_CONTACTUS_JOURNAL_ID="" -export REACT_APP_STRIPE_PUBLISHABLE_KEY="" diff --git a/frontend/src/components/NewSubscription.js b/frontend/src/components/NewSubscription.js index beb4ff8f..aa31450c 100644 --- a/frontend/src/components/NewSubscription.js +++ b/frontend/src/components/NewSubscription.js @@ -44,6 +44,7 @@ const NewSubscription = ({ isFreeOption, onClose }) => { type: isFreeOption ? "free" : radioState, }); }; + console.log(typesCache.data); return (
Subscribe to a new address @@ -68,9 +69,9 @@ const NewSubscription = ({ isFreeOption, onClose }) => { - {typesCache.data.map((type) => { + {typesCache.data.subscriptions.map((type) => { const radio = getRadioProps({ - value: type.subscription_type, + value: type.id, isDisabled: !type.active || (isFreeOption && @@ -79,8 +80,8 @@ const NewSubscription = ({ isFreeOption, onClose }) => { if (!type.subscription_plan_id) return ""; return ( console.log("hello")} - key={`subscription-type-${type.id}`} + onClick={() => setRadioState(type.id)} + key={`subscription_type_${type.id}`} {...radio} > {type.name} @@ -90,9 +91,10 @@ const NewSubscription = ({ isFreeOption, onClose }) => { + diff --git a/frontend/src/components/SubscriptionsList.js b/frontend/src/components/SubscriptionsList.js index 49fc4487..3293724e 100644 --- a/frontend/src/components/SubscriptionsList.js +++ b/frontend/src/components/SubscriptionsList.js @@ -18,13 +18,14 @@ import CopyButton from "./CopyButton"; import { useSubscriptions } from "../core/hooks"; import ConfirmationRequest from "./ConfirmationRequest"; -const List = () => { +const List = (data) => { const { subscriptionsCache, changeNote, deleteSubscription } = useSubscriptions(); const updateCallback = ({ id, note }) => { changeNote.mutate({ id, note }); }; + console.log(data); if (subscriptionsCache.data) { return ( @@ -45,7 +46,7 @@ const List = () => { Token Address Date Created - Note + label Actions @@ -85,11 +86,11 @@ const List = () => { updateCallback({ id: subscription.id, - note: nextValue, + label: nextValue, }) } > diff --git a/frontend/src/core/hooks/useSubscriptions.js b/frontend/src/core/hooks/useSubscriptions.js index 422ca0ec..64c798c9 100644 --- a/frontend/src/core/hooks/useSubscriptions.js +++ b/frontend/src/core/hooks/useSubscriptions.js @@ -27,7 +27,9 @@ const useSubscriptions = () => { const getSubscriptions = async () => { const response = await SubscriptionsService.getSubscriptions(); - return response.data.data; + console.log("getSubscriptions"); + console.log(response.data); + return response.data; }; const subscriptionsCache = useQuery(["subscriptions"], getSubscriptions, { @@ -39,7 +41,7 @@ const useSubscriptions = () => { const getSubscriptionTypes = async () => { const response = await SubscriptionsService.getTypes(); - return response.data.data; + return response.data; }; const typesCache = useQuery(["subscription_types"], getSubscriptionTypes, { @@ -73,14 +75,23 @@ const useSubscriptions = () => { }, }); - const deleteSubscription = useMutation(SubscriptionsService.deleteSubscription(), { - onError: (error) => toast(error, "error"), - onSuccess: (response) => { - subscriptionsCache.refetch(); - }, - }); + const deleteSubscription = useMutation( + SubscriptionsService.deleteSubscription(), + { + onError: (error) => toast(error, "error"), + onSuccess: (response) => { + subscriptionsCache.refetch(); + }, + } + ); - return { createSubscription, subscriptionsCache, typesCache, changeNote, deleteSubscription }; + return { + createSubscription, + subscriptionsCache, + typesCache, + changeNote, + deleteSubscription, + }; }; export default useSubscriptions; diff --git a/frontend/src/core/services/subscriptions.service.js b/frontend/src/core/services/subscriptions.service.js index b00a515e..6987167b 100644 --- a/frontend/src/core/services/subscriptions.service.js +++ b/frontend/src/core/services/subscriptions.service.js @@ -1,18 +1,31 @@ import { http } from "../utils"; // import axios from "axios"; -const API = process.env.NEXT_PUBLIC_SIMIOTICS_AUTH_URL; +const API = process.env.NEXT_PUBLIC_MOONSTREAM_API_URL; +console.log(API); + +// export const getTypes = () => +// http({ +// method: "GET", +// url: `${API}/subscription_types/`, +// }); + +// export const getSubscriptions = () => +// http({ +// method: "GET", +// url: `${API}/subscriptions/`, +// }); export const getTypes = () => http({ method: "GET", - url: `${API}/subscription_types/`, + url: `${API}/subscriptions/types`, }); export const getSubscriptions = () => http({ method: "GET", - url: `${API}/subscriptions/`, + url: `${API}/subscriptions`, }); export const create = ({ address, note, blockchain }) => { @@ -35,12 +48,13 @@ export const deleteJournal = (id) => () => export const createSubscription = () => - ({ address, type, note }) => { - console.log("createSubscription: ", address, type, note); + ({ address, type, label, color }) => { + console.log("createSubscription: ", address, type, label); const data = new FormData(); data.append("address", address); - data.append("subscription_type", type); - data.append("note", note); + data.append("subscription_type_id", type); + data.append("color", color); + data.append("label", label); return http({ method: "POST", url: `${API}/subscriptions/`, diff --git a/frontend/src/core/utils/mockupRequests.js b/frontend/src/core/utils/mockupRequests.js index b96c62c7..75cf33cb 100644 --- a/frontend/src/core/utils/mockupRequests.js +++ b/frontend/src/core/utils/mockupRequests.js @@ -90,12 +90,12 @@ const enableMockupRequests = (axiosInstance) => { ], }); - mock.onGet(`${MOCK_API}/subscriptions/`).reply(200, { - data: { - is_free_subscription_availible: true, - subscriptions: MockSubscriptions, - }, - }); + // mock.onGet(`${MOCK_API}/subscriptions/`).reply(200, { + // data: { + // is_free_subscription_availible: true, + // subscriptions: MockSubscriptions, + // }, + // }); mock.onPost(`${MOCK_API}/subscriptions/`).reply((config) => { const params = config.data; // FormData of {name: ..., file: ...}