Merge pull request #20 from bugout-dev/v0

V0
pull/26/head
Neeraj Kashyap 2021-07-27 10:19:37 -07:00 zatwierdzone przez GitHub
commit 9a0d3888a1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 41 dodań i 51 usunięć

Wyświetl plik

@ -100,7 +100,7 @@ const Subscriptions = () => {
Add new Add new
</Button> </Button>
</Flex> </Flex>
<SubscriptionsList /> <SubscriptionsList data={subscriptionsCache.data} />
</Flex> </Flex>
</ScaleFade> </ScaleFade>
)} )}

Wyświetl plik

@ -1,7 +1,9 @@
export REACT_APP_SIMIOTICS_SEARCH_URL=http://localhost:5000 export NEXT_PUBLIC_SIMIOTICS_SEARCH_URL=http://localhost:5000
export REACT_APP_MIXPANEL_TOKEN="<YOUR MIXPANEL TOKEN HERE>" export NEXT_PUBLIC_MIXPANEL_TOKEN="<YOUR MIXPANEL TOKEN HERE>"
export REACT_APP_SIMIOTICS_AUTH_URL=http://localhost:7474 export NEXT_PUBLIC_SIMIOTICS_AUTH_URL=http://localhost:7474
export REACT_APP_SIMIOTICS_JOURNALS_URL=http://localhost:7475 export NEXT_PUBLIC_SIMIOTICS_JOURNALS_URL=http://localhost:7475
export REACT_APP_BUGOUT_CONTACTUS_TOKEN="<Brood token for contact user>" export NEXT_PUBLIC_BUGOUT_CONTACTUS_TOKEN="<Brood token for contact user>"
export REACT_APP_BUGOUT_CONTACTUS_JOURNAL_ID="<journal ID for contact journal>" export NEXT_PUBLIC_BUGOUT_CONTACTUS_JOURNAL_ID="<journal ID for contact journal>"
export REACT_APP_STRIPE_PUBLISHABLE_KEY="<stripe publishable key>" export NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="<stripe publishable key>"
export NEXT_PUBLIC_MOONSTREAM_API_URL=http://localhost:7481

Wyświetl plik

@ -44,6 +44,7 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
type: isFreeOption ? "free" : radioState, type: isFreeOption ? "free" : radioState,
}); });
}; };
return ( return (
<form onSubmit={handleSubmit(createSubscriptionWrap)}> <form onSubmit={handleSubmit(createSubscriptionWrap)}>
<ModalHeader>Subscribe to a new address</ModalHeader> <ModalHeader>Subscribe to a new address</ModalHeader>
@ -84,9 +85,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 &&
@ -94,7 +95,7 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
}); });
if (!type.subscription_plan_id) return ""; if (!type.subscription_plan_id) return "";
return ( return (
<RadioCard key={`subscription-type-${type.id}`} {...radio}> <RadioCard key={`subscription_type_${type.id}`} {...radio}>
{type.name} {type.name}
</RadioCard> </RadioCard>
); );
@ -102,6 +103,7 @@ const NewSubscription = ({ isFreeOption, onClose }) => {
</HStack> </HStack>
</FormControl> </FormControl>
</Stack> </Stack>
<Input placeholder="color" name="color" ref={register()}></Input>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button <Button

Wyświetl plik

@ -18,12 +18,11 @@ 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 }) => {
console.log('updateCallback', id)
changeNote.mutate({ id, note }); changeNote.mutate({ id, note });
}; };

Wyświetl plik

@ -27,7 +27,7 @@ const useSubscriptions = () => {
const getSubscriptions = async () => { const getSubscriptions = async () => {
const response = await SubscriptionsService.getSubscriptions(); const response = await SubscriptionsService.getSubscriptions();
return response.data.data; return response.data;
}; };
const subscriptionsCache = useQuery(["subscriptions"], getSubscriptions, { const subscriptionsCache = useQuery(["subscriptions"], getSubscriptions, {
@ -39,7 +39,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 +73,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;

Wyświetl plik

@ -1,7 +1,7 @@
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;
export const getStream = ({ searchTerm, limit, offset, isContent }) => export const getStream = ({ searchTerm, limit, offset, isContent }) =>
http({ http({
@ -18,13 +18,13 @@ export const getStream = ({ searchTerm, limit, offset, isContent }) =>
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 }) => {
@ -47,10 +47,11 @@ export const deleteJournal = (id) => () =>
export const createSubscription = export const createSubscription =
() => () =>
({ address, type, label }) => { ({ address, type, label, color }) => {
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("color", color);
data.append("label", label); data.append("label", label);
return http({ return http({
method: "POST", method: "POST",
@ -75,7 +76,7 @@ export const modifySubscription =
export const deleteSubscription = () => (id) => { export const deleteSubscription = () => (id) => {
return http({ return http({
method: "DELETE", method: "DELETE",
url: `${API}/subscription/${id}`, url: `${API}/subscriptions/${id}`,
}); });
}; };

Wyświetl plik

@ -234,28 +234,5 @@ const enableMockupRequests = (axiosInstance) => {
offset: 0, offset: 0,
}, },
}); });
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: ...}
const id = params.get("id");
const label = params.get("label");
const address = params.get("address");
const subscription_type = params.get("subscription_type");
return new Promise(function (resolve) {
setTimeout(function () {
const data = { id, label, address, subscription_type };
MockSubscriptions.push({ ...data });
resolve([200, { message: "OK", result: true }]);
}, 1000);
});
});
}; };
export default enableMockupRequests; export default enableMockupRequests;