|
@@ -217,42 +217,31 @@ export function* getOrderHistoryWatcher() {
|
|
|
yield takeEvery("GET_ORDER_HISTORY", getOrdersHistoryWorker);
|
|
|
}
|
|
|
|
|
|
-// export const actionGoodChange = (name, price, description, id) => {
|
|
|
-// return actionPromise(
|
|
|
-// 'goodChange', gql(`mutation g($name: String, $price: Float, $desc: String, $id: ID){
|
|
|
-// GoodUpsert(good:{
|
|
|
-// _id: $id,
|
|
|
-// name: $name,
|
|
|
-// price: $price,
|
|
|
-// description: $desc
|
|
|
-// }) {
|
|
|
-// _id
|
|
|
-// createdAt
|
|
|
-// name
|
|
|
-// description
|
|
|
-// price
|
|
|
-// }
|
|
|
-// }`, {name: name, price: price, desc: description, id: id}
|
|
|
-// ))
|
|
|
-// }
|
|
|
+export const actionGoodChange = (goodChange) => {
|
|
|
+ return actionPromise(
|
|
|
+ "goodChange",
|
|
|
+ gql(
|
|
|
+ `mutation g($good: GoodInput){
|
|
|
+ GoodUpsert(good:$good) {
|
|
|
+ _id
|
|
|
+ createdAt
|
|
|
+ name
|
|
|
+ description
|
|
|
+ price
|
|
|
+ categories {
|
|
|
+ name
|
|
|
+ }
|
|
|
+ images {
|
|
|
+ url
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }`,
|
|
|
+ { good: goodChange }
|
|
|
+ )
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
-export const actionGoodChange = (goodChange) => {
|
|
|
- return actionPromise(
|
|
|
- 'goodChange', gql(`mutation g($good: GoodInput){
|
|
|
- GoodUpsert(good: $good) {
|
|
|
- _id
|
|
|
- createdAt
|
|
|
- name
|
|
|
- description
|
|
|
- price
|
|
|
- categories {
|
|
|
- _id
|
|
|
- name
|
|
|
- }
|
|
|
- }
|
|
|
- }`, {good: goodChange}
|
|
|
- ))
|
|
|
-}
|
|
|
|
|
|
export const actionCategoryCreate = (name) => {
|
|
|
return actionPromise(
|
|
@@ -333,6 +322,7 @@ export const actionUploadFile = (file) => {
|
|
|
// };
|
|
|
|
|
|
export const actionSetAvatar = (file) => ({ type: "SET_AVATAR", file });
|
|
|
+
|
|
|
export function* setAvatarWorker(action) {
|
|
|
const { file } = action;
|
|
|
let result = yield call(promiseWorker, actionUploadFile(file));
|
|
@@ -352,6 +342,25 @@ export function* setAvatarWorker(action) {
|
|
|
);
|
|
|
yield put(actionAboutMe());
|
|
|
}
|
|
|
+
|
|
|
export function* setAvatarWatcher() {
|
|
|
yield takeEvery("SET_AVATAR", setAvatarWorker);
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+export function* setGoodImageWorker(action) {
|
|
|
+ const {
|
|
|
+ image: { _id, images },
|
|
|
+ } = action;
|
|
|
+ let result = yield call(promiseWorker, actionUploadFile(images[0]));
|
|
|
+ let imageId = result?._id;
|
|
|
+ yield put(actionGoodChange({ _id: _id, images: [{ _id: imageId }] }));
|
|
|
+}
|
|
|
+
|
|
|
+export function* setGoodImageWatcher() {
|
|
|
+ yield takeEvery("IMAGE_UPLOAD", setGoodImageWorker);
|
|
|
+}
|
|
|
+
|
|
|
+export const actionSetGoodImage = (image) => ({
|
|
|
+ type: "IMAGE_UPLOAD",
|
|
|
+ image,
|
|
|
+});
|