kopia lustrzana https://github.com/bugout-dev/moonstream
temp state of subscription.
rodzic
13d96d5552
commit
7577a15d92
|
@ -100,7 +100,7 @@ const Subscriptions = () => {
|
||||||
Add new
|
Add new
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
<SubscriptionsList />
|
<SubscriptionsList data={subscriptionsCache.data} />
|
||||||
</Flex>
|
</Flex>
|
||||||
</ScaleFade>
|
</ScaleFade>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
export REACT_APP_SIMIOTICS_SEARCH_URL=http://localhost:5000
|
|
||||||
export REACT_APP_MIXPANEL_TOKEN="<YOUR MIXPANEL TOKEN HERE>"
|
|
||||||
export REACT_APP_SIMIOTICS_AUTH_URL=http://localhost:7474
|
|
||||||
export REACT_APP_SIMIOTICS_JOURNALS_URL=http://localhost:7475
|
|
||||||
export REACT_APP_BUGOUT_CONTACTUS_TOKEN="<Brood token for contact user>"
|
|
||||||
export REACT_APP_BUGOUT_CONTACTUS_JOURNAL_ID="<journal ID for contact journal>"
|
|
||||||
export REACT_APP_STRIPE_PUBLISHABLE_KEY="<stripe publishable key>"
|
|
|
@ -44,6 +44,7 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
|
||||||
type: isFreeOption ? "free" : radioState,
|
type: isFreeOption ? "free" : radioState,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
console.log(typesCache.data);
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(createSubscriptionWrap)}>
|
<form onSubmit={handleSubmit(createSubscriptionWrap)}>
|
||||||
<ModalHeader>Subscribe to a new address</ModalHeader>
|
<ModalHeader>Subscribe to a new address</ModalHeader>
|
||||||
|
@ -68,9 +69,9 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
|
||||||
|
|
||||||
<FormControl isInvalid={errors.type}>
|
<FormControl isInvalid={errors.type}>
|
||||||
<HStack {...group} alignItems="stretch">
|
<HStack {...group} alignItems="stretch">
|
||||||
{typesCache.data.map((type) => {
|
{typesCache.data.subscriptions.map((type) => {
|
||||||
const radio = getRadioProps({
|
const radio = getRadioProps({
|
||||||
value: type.subscription_type,
|
value: type.id,
|
||||||
isDisabled:
|
isDisabled:
|
||||||
!type.active ||
|
!type.active ||
|
||||||
(isFreeOption &&
|
(isFreeOption &&
|
||||||
|
@ -79,8 +80,8 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
|
||||||
if (!type.subscription_plan_id) return "";
|
if (!type.subscription_plan_id) return "";
|
||||||
return (
|
return (
|
||||||
<RadioCard
|
<RadioCard
|
||||||
onClick={() => console.log("hello")}
|
onClick={() => setRadioState(type.id)}
|
||||||
key={`subscription-type-${type.id}`}
|
key={`subscription_type_${type.id}`}
|
||||||
{...radio}
|
{...radio}
|
||||||
>
|
>
|
||||||
{type.name}
|
{type.name}
|
||||||
|
@ -90,9 +91,10 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
|
||||||
</HStack>
|
</HStack>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<Input placeholder="color" name="color" ref={register()}></Input>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Add some notes"
|
placeholder="Add some notes"
|
||||||
name="note"
|
name="label"
|
||||||
ref={register()}
|
ref={register()}
|
||||||
></Input>
|
></Input>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
|
|
@ -18,13 +18,14 @@ import CopyButton from "./CopyButton";
|
||||||
import { useSubscriptions } from "../core/hooks";
|
import { useSubscriptions } from "../core/hooks";
|
||||||
import ConfirmationRequest from "./ConfirmationRequest";
|
import ConfirmationRequest from "./ConfirmationRequest";
|
||||||
|
|
||||||
const List = () => {
|
const List = (data) => {
|
||||||
const { subscriptionsCache, changeNote, deleteSubscription } =
|
const { subscriptionsCache, changeNote, deleteSubscription } =
|
||||||
useSubscriptions();
|
useSubscriptions();
|
||||||
|
|
||||||
const updateCallback = ({ id, note }) => {
|
const updateCallback = ({ id, note }) => {
|
||||||
changeNote.mutate({ id, note });
|
changeNote.mutate({ id, note });
|
||||||
};
|
};
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
if (subscriptionsCache.data) {
|
if (subscriptionsCache.data) {
|
||||||
return (
|
return (
|
||||||
|
@ -45,7 +46,7 @@ const List = () => {
|
||||||
<Th>Token</Th>
|
<Th>Token</Th>
|
||||||
<Th>Address</Th>
|
<Th>Address</Th>
|
||||||
<Th>Date Created</Th>
|
<Th>Date Created</Th>
|
||||||
<Th>Note</Th>
|
<Th>label</Th>
|
||||||
<Th>Actions</Th>
|
<Th>Actions</Th>
|
||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
|
@ -85,11 +86,11 @@ const List = () => {
|
||||||
<Editable
|
<Editable
|
||||||
colorScheme="primary"
|
colorScheme="primary"
|
||||||
placeholder="enter note here"
|
placeholder="enter note here"
|
||||||
defaultValue={subscription.note}
|
defaultValue={subscription.label}
|
||||||
onSubmit={(nextValue) =>
|
onSubmit={(nextValue) =>
|
||||||
updateCallback({
|
updateCallback({
|
||||||
id: subscription.id,
|
id: subscription.id,
|
||||||
note: nextValue,
|
label: nextValue,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
|
@ -27,7 +27,9 @@ const useSubscriptions = () => {
|
||||||
|
|
||||||
const getSubscriptions = async () => {
|
const getSubscriptions = async () => {
|
||||||
const response = await SubscriptionsService.getSubscriptions();
|
const response = await SubscriptionsService.getSubscriptions();
|
||||||
return response.data.data;
|
console.log("getSubscriptions");
|
||||||
|
console.log(response.data);
|
||||||
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const subscriptionsCache = useQuery(["subscriptions"], getSubscriptions, {
|
const subscriptionsCache = useQuery(["subscriptions"], getSubscriptions, {
|
||||||
|
@ -39,7 +41,7 @@ const useSubscriptions = () => {
|
||||||
|
|
||||||
const getSubscriptionTypes = async () => {
|
const getSubscriptionTypes = async () => {
|
||||||
const response = await SubscriptionsService.getTypes();
|
const response = await SubscriptionsService.getTypes();
|
||||||
return response.data.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const typesCache = useQuery(["subscription_types"], getSubscriptionTypes, {
|
const typesCache = useQuery(["subscription_types"], getSubscriptionTypes, {
|
||||||
|
@ -73,14 +75,23 @@ const useSubscriptions = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteSubscription = useMutation(SubscriptionsService.deleteSubscription(), {
|
const deleteSubscription = useMutation(
|
||||||
onError: (error) => toast(error, "error"),
|
SubscriptionsService.deleteSubscription(),
|
||||||
onSuccess: (response) => {
|
{
|
||||||
subscriptionsCache.refetch();
|
onError: (error) => toast(error, "error"),
|
||||||
},
|
onSuccess: (response) => {
|
||||||
});
|
subscriptionsCache.refetch();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return { createSubscription, subscriptionsCache, typesCache, changeNote, deleteSubscription };
|
return {
|
||||||
|
createSubscription,
|
||||||
|
subscriptionsCache,
|
||||||
|
typesCache,
|
||||||
|
changeNote,
|
||||||
|
deleteSubscription,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useSubscriptions;
|
export default useSubscriptions;
|
||||||
|
|
|
@ -1,18 +1,31 @@
|
||||||
import { http } from "../utils";
|
import { http } from "../utils";
|
||||||
// import axios from "axios";
|
// 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 = () =>
|
export const getTypes = () =>
|
||||||
http({
|
http({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `${API}/subscription_types/`,
|
url: `${API}/subscriptions/types`,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getSubscriptions = () =>
|
export const getSubscriptions = () =>
|
||||||
http({
|
http({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `${API}/subscriptions/`,
|
url: `${API}/subscriptions`,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const create = ({ address, note, blockchain }) => {
|
export const create = ({ address, note, blockchain }) => {
|
||||||
|
@ -35,12 +48,13 @@ export const deleteJournal = (id) => () =>
|
||||||
|
|
||||||
export const createSubscription =
|
export const createSubscription =
|
||||||
() =>
|
() =>
|
||||||
({ address, type, note }) => {
|
({ address, type, label, color }) => {
|
||||||
console.log("createSubscription: ", address, type, note);
|
console.log("createSubscription: ", address, type, label);
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
data.append("address", address);
|
data.append("address", address);
|
||||||
data.append("subscription_type", type);
|
data.append("subscription_type_id", type);
|
||||||
data.append("note", note);
|
data.append("color", color);
|
||||||
|
data.append("label", label);
|
||||||
return http({
|
return http({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `${API}/subscriptions/`,
|
url: `${API}/subscriptions/`,
|
||||||
|
|
|
@ -90,12 +90,12 @@ const enableMockupRequests = (axiosInstance) => {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
mock.onGet(`${MOCK_API}/subscriptions/`).reply(200, {
|
// mock.onGet(`${MOCK_API}/subscriptions/`).reply(200, {
|
||||||
data: {
|
// data: {
|
||||||
is_free_subscription_availible: true,
|
// is_free_subscription_availible: true,
|
||||||
subscriptions: MockSubscriptions,
|
// subscriptions: MockSubscriptions,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
mock.onPost(`${MOCK_API}/subscriptions/`).reply((config) => {
|
mock.onPost(`${MOCK_API}/subscriptions/`).reply((config) => {
|
||||||
const params = config.data; // FormData of {name: ..., file: ...}
|
const params = config.data; // FormData of {name: ..., file: ...}
|
||||||
|
|
Ładowanie…
Reference in New Issue