Skip to content

Commit

Permalink
order mock donw
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammed Tareq Aziz committed Aug 29, 2021
1 parent e672f36 commit 667149e
Show file tree
Hide file tree
Showing 21 changed files with 1,285 additions and 3,252 deletions.
8 changes: 6 additions & 2 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ export function getSearchItems (query, params, authToken) {
}
const requestConfig = {
name: 'getSearchItems',
url: getUrlFromTemplate(API.PRODUCTS_BY_QUERY, { query })
url: getUrlFromTemplate(API.PRODUCTS_BY_QUERY, { query }),
query
}
params && params.limit === 0 && params.offset === 0 ? requestConfig.params = params : null
authToken ? requestConfig.access_token = authToken : null
Expand Down Expand Up @@ -756,7 +757,10 @@ export function updateServiceReview (authToken, reviewId, params) {
export function getBlocks (contextType, contextValue, section) {
let requestConfig = {
name: 'getBlocks',
url: `${API.BLOCKS}/${contextType}/${contextValue}/${section}`
url: `${API.BLOCKS}/${contextType}/${contextValue}/${section}`,
contextType,
contextValue,
section
}

return callApi(requestConfig)
Expand Down
51 changes: 26 additions & 25 deletions api/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { categories } from '~/api/mock/categories'
import { mockSaveCart, mockValidateCart } from './mock/cart'
import { getCategoryProducts, getProductBySlug } from '~/api/mock/products/getCategoryProducts'
import { getOrderSummaryById, getOrderSummaries, createOrder } from '~/api/mock/order/order'
import { getSearchItems } from '~/api/mock/products/getSearchItems'
import { getBlocks } from '~/api/mock/block/getBlocks'
import portwalletInvoice from '~/api/mock/order/portwalletInvoice.json'

import {
Expand All @@ -16,7 +18,6 @@ import isString from 'lodash/isString'
import extend from 'lodash/extend'
import omit from 'lodash/omit'
import get from 'lodash/get'
import trim from 'lodash/trim'

import logger from '~/utils/logger'

Expand Down Expand Up @@ -197,7 +198,7 @@ export function callMockApi (requestConfig) {
case 'getOrderSummaryById':
return getOrderSummaryById(requestConfig)
case 'createOrder':
return createOrder()
return createOrder(requestConfig)
case 'confirmPaymentMethod':
return Promise.resolve([])
case 'createPortWalletInvoice':
Expand All @@ -209,11 +210,11 @@ export function callMockApi (requestConfig) {
// return verifyBkashPaymentWithTrxId()
return callApi(requestConfig)
case 'productRequest':
// return productRequest()
return callApi(requestConfig)
return Promise.resolve({})
// return callApi(requestConfig)
case 'getSearchItems':
// return getSearchItems()
return callApi(requestConfig)
return getSearchItems(requestConfig)
// return callApi(requestConfig)
case 'getAgentCommission':
// return getAgentCommission()
return callApi(requestConfig)
Expand Down Expand Up @@ -242,8 +243,8 @@ export function callMockApi (requestConfig) {
// return updateServiceReview()
return callApi(requestConfig)
case 'getBlocks':
// return getBlocks()
return callApi(requestConfig)
return getBlocks(requestConfig)
// return callApi(requestConfig)
}
}

Expand Down Expand Up @@ -669,18 +670,18 @@ export function productRequest (authToken, productId) {

// Search

export function getSearchItems (query, params, authToken) {
if (!query || trim(query) === '') {
return Promise.resolve([])
}
const requestConfig = {
url: getUrlFromTemplate(API.PRODUCTS_BY_QUERY, { query })
}
params && params.limit === 0 && params.offset === 0 ? requestConfig.params = params : null
authToken ? requestConfig.access_token = authToken : null
// export function getSearchItems (query, params, authToken) {
// if (!query || trim(query) === '') {
// return Promise.resolve([])
// }
// const requestConfig = {
// url: getUrlFromTemplate(API.PRODUCTS_BY_QUERY, { query })
// }
// params && params.limit === 0 && params.offset === 0 ? requestConfig.params = params : null
// authToken ? requestConfig.access_token = authToken : null

return callApi(requestConfig)
}
// return callApi(requestConfig)
// }

export function getAgentCommission (authToken) {
const requestConfig = {
Expand Down Expand Up @@ -779,10 +780,10 @@ export function updateServiceReview (authToken, reviewId, params) {
})
}

export function getBlocks (contextType, contextValue, section) {
let requestConfig = {
url: `${API.BLOCKS}/${contextType}/${contextValue}/${section}`
}
// export function getBlocks (contextType, contextValue, section) {
// let requestConfig = {
// url: `${API.BLOCKS}/${contextType}/${contextValue}/${section}`
// }

return callApi(requestConfig)
}
// return callApi(requestConfig)
// }
11 changes: 11 additions & 0 deletions api/mock/block/getBlocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pageHomeTop from '~/api/mock/block/pageHomeTop.json'
import pageHomeMid from '~/api/mock/block/pageHomeMid.json'

export const getBlocks = ({ contextType, contextValue, section }) => {
if (contextType === 'page' && contextValue === 'home' && section === 'top') {
return Promise.resolve(pageHomeTop)
} else if (contextType === 'page' && contextValue === 'home' && section === 'mid') {
return Promise.resolve(pageHomeMid)
}
return null
}
3 changes: 3 additions & 0 deletions api/mock/block/pageHomeMid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Mid": []
}
94 changes: 94 additions & 0 deletions api/mock/block/pageHomeTop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"Top": [
{
"id": 3,
"section": "Top",
"context_type": "page",
"context_value": 3,
"block_id": 8,
"block": {
"id": 8,
"title": {
"en": "Hero Banner"
},
"sub_title": {
"en": "Hero Banner"
},
"slug": "hero-banner-1",
"description": null,
"status": 1,
"platform": "web/*",
"created_at": "2021-07-27T14:12:09+06:00",
"updated_at": "2021-08-19T19:02:01+06:00",
"offers": [
{
"id": 9,
"title": {
"en": "Hero Banner 2"
},
"details": {
"en": "<div style=\"display: none;\">&nbsp;</div>\r\n\r\n<p>Hero Banner Image</p>"
},
"status": 1,
"sort_position": 2,
"created_at": "2021-07-05T12:58:41+06:00",
"updated_at": "2021-08-19T19:03:35+06:00",
"type": 1,
"link": null,
"expire_at": "2022-05-27 12:57:35",
"misc": null,
"related_id": 4,
"related_type": "App\\Models\\Category",
"logo_image": null,
"banner_image": "https://store.dglink.co/storage/media/84/offer-9.bin",
"related_slug": "face"
},
{
"id": 8,
"title": {
"en": "Hero Banner 1"
},
"details": {
"en": "<div style=\"display: none;\">&nbsp;</div>\r\n\r\n<div>&nbsp;</div>\r\n\r\n<p>Hero Banner Image</p>"
},
"status": 1,
"sort_position": 1,
"created_at": "2021-07-05T12:47:17+06:00",
"updated_at": "2021-08-19T19:03:53+06:00",
"type": 1,
"link": "http://bronx.dglink.co/category/hidden-category",
"expire_at": "2022-05-20 12:46:28",
"misc": null,
"related_id": null,
"related_type": null,
"logo_image": null,
"banner_image": "https://store.dglink.co/storage/media/83/offer-8.bin",
"related_slug": null
},
{
"id": 10,
"title": {
"en": "Hero Banner 3"
},
"details": {
"en": "<div style=\"display: none;\">&nbsp;</div>\r\n\r\n<p>Hero Banner Image 3</p>"
},
"status": 1,
"sort_position": 3,
"created_at": "2021-07-05T13:00:32+06:00",
"updated_at": "2021-08-19T19:03:19+06:00",
"type": 1,
"link": null,
"expire_at": "2022-02-24 18:00:00",
"misc": null,
"related_id": 4,
"related_type": "App\\Models\\Category",
"logo_image": null,
"banner_image": "https://store.dglink.co/storage/media/85/offer-10.bin",
"related_slug": "face"
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion api/mock/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// 'suggestion': null
// }

import { products } from '~/api/mock/products/getCategoryProducts'
import { products } from '~/api/mock/products'
export const mockSaveCart = (cartPayload) => {
return mockValidateCart(cartPayload)
}
Expand Down
6 changes: 3 additions & 3 deletions api/mock/categories/category10.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": 125,
"slug": "men-s-fashion",
"slug": "category-1",
"name": {
"en": "Men's Fashion",
"bn": "ছেলেদের ফ্যাশন"
"en": "Category 1",
"bn": "ক্যাটাগরি ১"
},
"parent_id": null,
"featured_categories": [],
Expand Down
Loading

0 comments on commit 667149e

Please sign in to comment.