feat: welcome screen add new request

This commit is contained in:
Anoop M D
2022-01-04 22:30:15 +05:30
parent 1f1e8a602e
commit 3ffcc0e9f2
6 changed files with 71 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ const REQUEST_TAB_CLICK = "REQUEST_TAB_CLICK";
const REQUEST_TAB_CLOSE = "REQUEST_TAB_CLOSE";
const RESPONSE_RECEIVED = "RESPONSE_RECEIVED";
const ADD_REQUEST = "ADD_REQUEST";
const ADD_NEW_HTTP_REQUEST = "ADD_NEW_HTTP_REQUEST";
export default {
SIDEBAR_COLLECTION_CLICK,
@@ -11,5 +12,6 @@ export default {
REQUEST_TAB_CLICK,
REQUEST_TAB_CLOSE,
RESPONSE_RECEIVED,
ADD_REQUEST
ADD_REQUEST,
ADD_NEW_HTTP_REQUEST
};

View File

@@ -57,6 +57,27 @@ const reducer = (state, action) => {
});
}
case actions.ADD_NEW_HTTP_REQUEST: {
return produce(state, (draft) => {
const uid = nanoid();
draft.requestTabs.push({
id: uid,
name: 'Untitled Request',
method: 'GET',
request: {
url: 'https://api.spacex.land/graphql/',
body: {
graphql: {
query: '{}'
}
}
},
collectionId: null
});
draft.activeRequestTabId = uid;
});
}
case actions.RESPONSE_RECEIVED: {
return produce(state, (draft) => {
const collection = find(draft.collections, (c) => c.id === action.collectionId);