Base changes to job upload screen.
This commit is contained in:
66
client/src/redux/media/media.sagas.js
Normal file
66
client/src/redux/media/media.sagas.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { all, call, takeLatest, put, select } from "redux-saga/effects";
|
||||
import { getJobMediaError, setJobMedia } from "./media.actions";
|
||||
import MediaActionTypes from "./media.types";
|
||||
import cleanAxios from "../../utils/CleanAxios";
|
||||
import normalizeUrl from "normalize-url";
|
||||
export function* onSetJobMedia() {
|
||||
yield takeLatest(MediaActionTypes.GET_MEDIA_FOR_JOB, getJobMedia);
|
||||
}
|
||||
export function* getJobMedia({ payload: jobid }) {
|
||||
try {
|
||||
const localmediaserverhttp = (yield select(
|
||||
(state) => state.user.bodyshop.localmediaserverhttp
|
||||
)).trim();
|
||||
|
||||
if (localmediaserverhttp && localmediaserverhttp !== "") {
|
||||
const imagesFetch = yield cleanAxios.post(
|
||||
`${localmediaserverhttp}/jobs/list`,
|
||||
{
|
||||
jobid,
|
||||
}
|
||||
);
|
||||
const documentsFetch = yield cleanAxios.post(
|
||||
`${localmediaserverhttp}/bills/list`,
|
||||
{
|
||||
jobid,
|
||||
}
|
||||
);
|
||||
|
||||
yield put(
|
||||
setJobMedia({
|
||||
jobid,
|
||||
media: [
|
||||
...imagesFetch.data.map((d, idx) => {
|
||||
return {
|
||||
...d,
|
||||
src: normalizeUrl(`${localmediaserverhttp}/${d.src}`),
|
||||
thumbnail: normalizeUrl(
|
||||
`${localmediaserverhttp}/${d.thumbnail}`
|
||||
),
|
||||
|
||||
key: idx,
|
||||
};
|
||||
}),
|
||||
...documentsFetch.data.map((d, idx) => {
|
||||
return {
|
||||
...d,
|
||||
src: normalizeUrl(`${localmediaserverhttp}/${d.src}`),
|
||||
thumbnail: normalizeUrl(
|
||||
`${localmediaserverhttp}/${d.thumbnail}`
|
||||
),
|
||||
|
||||
key: idx,
|
||||
};
|
||||
}),
|
||||
],
|
||||
})
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(getJobMediaError(error));
|
||||
}
|
||||
}
|
||||
|
||||
export function* mediaSagas() {
|
||||
yield all([call(onSetJobMedia)]);
|
||||
}
|
||||
Reference in New Issue
Block a user