mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 01:29:21 +00:00
* initial market - routing - store - load market data * move drawer/drawerSlider / count/star badge to components/ui * filter market categories * shopItem with gem / gold * show count of purchable items * show count of purchable itemsshow drawer with currently owned items + DrawerHeaderTabs-Component * show featured gear * show Gear - filter by class - sort by (type, price, stats) - sort market items * Component: ItemRows - shows only the max items in one row (depending on the available width) * Sell Dialog + Balance Component * generic buy-dialog / attributes grid with highlight * buyItem - hide already owned gear * filter: hide locked/pinned - lock items if not enough gold * API: Sell multiple items * show avatar in buy-equipment-dialog with changed gear * market banner * misc fixes * filter by text * pin/unpin gear store actions * Sell API: amount as query-parameter * Update user.js * fixes * fix sell api amount test * add back stroke/fill currentColor * use scss variables
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import axios from 'axios';
|
|
import { loadAsyncResource } from 'client/libs/asyncResource';
|
|
import buyOp from 'common/script/ops/buy';
|
|
import sellOp from 'common/script/ops/sell';
|
|
|
|
export function fetch (store, forceLoad = false) { // eslint-disable-line no-shadow
|
|
return loadAsyncResource({
|
|
store,
|
|
path: 'shops.market',
|
|
url: '/api/v3/shops/market',
|
|
deserialize (response) {
|
|
return response.data.data;
|
|
},
|
|
forceLoad,
|
|
});
|
|
}
|
|
|
|
export function buyItem (store, params) {
|
|
const user = store.state.user.data;
|
|
buyOp(user, {params});
|
|
axios
|
|
.post(`/api/v3/user/buy/${params.key}`);
|
|
// TODO
|
|
// .then((res) => console.log('equip', res))
|
|
// .catch((err) => console.error('equip', err));
|
|
}
|
|
|
|
export function sellItems (store, params) {
|
|
const user = store.state.user.data;
|
|
sellOp(user, {params, query: {amount: params.amount}});
|
|
axios
|
|
.post(`/api/v3/user/sell/${params.type}/${params.key}?amount=${params.amount}`);
|
|
// TODO
|
|
// .then((res) => console.log('equip', res))
|
|
// .catch((err) => console.error('equip', err));
|
|
}
|
|
|
|
|
|
export function pinGear (store, params) {
|
|
//axios
|
|
// .post(`/api/v3/user/pin/${params.key}`);
|
|
// TODO
|
|
// .then((res) => console.log('equip', res))
|
|
// .catch((err) => console.error('equip', err));
|
|
}
|
|
|
|
export function unpinGear (store, params) {
|
|
//axios
|
|
// .post(`/api/v3/user/unpin/${params.key}`);
|
|
// TODO
|
|
// .then((res) => console.log('equip', res))
|
|
// .catch((err) => console.error('equip', err));
|
|
}
|