Ver código fonte

Merged with payments

bugfix/4515
jovan.cirkovic 2 anos atrás
pai
commit
35177a6e4b

+ 24
- 19
src/pages/AdminHomePage/AdminPaymentPage/AdminPaymentPage.js Ver arquivo

AdminPaymentPageContainer, AdminPaymentPageContainer,
AdminPaymentsHeader, AdminPaymentsHeader,
AdminPaymentsSearchField, AdminPaymentsSearchField,
// FilterButtonIcon,
// FilterButtonContainer,
NewPaymentButton, NewPaymentButton,
PaymentsList, PaymentsList,
// FilterButton,
} from "./AdminPaymentPage.styled"; } from "./AdminPaymentPage.styled";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import useSorting from "../../../hooks/useOffers/useSorting"; import useSorting from "../../../hooks/useOffers/useSorting";
import { selectManualSearchString } from "../../../store/selectors/filtersSelectors"; import { selectManualSearchString } from "../../../store/selectors/filtersSelectors";
import { fetchPayments } from "../../../store/actions/payment/paymentActions"; import { fetchPayments } from "../../../store/actions/payment/paymentActions";
import { adminSortMethod } from "../../../util/helpers/adminSortHelper"; import { adminSortMethod } from "../../../util/helpers/adminSortHelper";
import { useHistory } from "react-router-dom";
import { selectAllProfiles } from "../../../store/selectors/profileSelectors"; import { selectAllProfiles } from "../../../store/selectors/profileSelectors";
import { fetchAllProfiles } from "../../../store/actions/profile/profileActions"; import { fetchAllProfiles } from "../../../store/actions/profile/profileActions";
import useQueryString from "../../../hooks/useOffers/useQueryString";


const AdminPaymentPage = () => { const AdminPaymentPage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const payments = useSelector(selectPayments); const payments = useSelector(selectPayments);
const users = useSelector(selectAllProfiles); const users = useSelector(selectAllProfiles);
const manualSearchString = useSelector(selectManualSearchString); const manualSearchString = useSelector(selectManualSearchString);
const history = useHistory();
const user = history?.location?.search?.split("=")[1];
const userName = user?.replaceAll("+", " ");
const userId = users?.filter?.((user) => user.companyName === userName);
const queryObject = useQueryString();

useEffect(() => { useEffect(() => {
dispatch(fetchPayments()); dispatch(fetchPayments());
dispatch(fetchAllProfiles()); dispatch(fetchAllProfiles());
sorting.clear(); sorting.clear();
}; };
}, []); }, []);

const checkedUsers = useMemo(() => {
if (queryObject.queryObject.companyName) {
return users?.filter?.((user) =>
queryObject?.queryObject?.companyName?.includes(user.companyName)
);
} else {
return "";
}
}, [users, queryObject?.queryObject]);

const checkedUsersIds =
checkedUsers && checkedUsers?.map((item) => item?._id);

const paymentsToShow = useMemo(() => { const paymentsToShow = useMemo(() => {
if (payments && history?.location?.search === "") {
if (payments && !queryObject?.queryObject?.companyName) {
return adminSortMethod(payments, manualSearchString, sorting); return adminSortMethod(payments, manualSearchString, sorting);
} }
if (history.location.search) {
const filteredPayments = payments?.filter(
(payment) => payment?.user?._id === userId[0]?._id
if (queryObject?.queryObject?.companyName.length > 0) {
const filteredPayments = payments?.filter((payment) =>
checkedUsersIds.includes(payment?.user?._id)
); );
return filteredPayments;
return adminSortMethod(filteredPayments, manualSearchString, sorting);
} }
}, [ }, [
payments, payments,
manualSearchString, manualSearchString,
sorting.selectedSortOptionLocally, sorting.selectedSortOptionLocally,
history.location.search,
queryObject.queryObject.companyName,
]); ]);


const handleSearch = (value) => { const handleSearch = (value) => {
> >
{t("admin.payment.addPayment")} {t("admin.payment.addPayment")}
</NewPaymentButton> </NewPaymentButton>
{/* <FilterButtonContainer>
<FilterButton>
<FilterButtonIcon />
</FilterButton>
</FilterButtonContainer> */}

<AdminPaymentsHeader <AdminPaymentsHeader
myOffers myOffers
payments payments

+ 2
- 2
src/request/index.js Ver arquivo

// baseURL: "http://192.168.88.143:3001/", // DULE // baseURL: "http://192.168.88.143:3001/", // DULE
// baseURL: "https://trampa-api.dilig.net/", // baseURL: "https://trampa-api.dilig.net/",
// baseURL: "https://trampa-api-test.dilig.net/", // baseURL: "https://trampa-api-test.dilig.net/",
// baseURL: "http://localhost:3001/",
baseURL: process.env.REACT_APP_BASE_API_URL,
baseURL: "http://localhost:3001/",
// baseURL: process.env.REACT_APP_BASE_API_URL,
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },

+ 2
- 2
src/store/middleware/accessTokensMiddleware.js Ver arquivo

// const baseURL = "https://trampa-api.dilig.net/"; // const baseURL = "https://trampa-api.dilig.net/";
// const baseURL = "https://trampa-api-test.dilig.net/"; // const baseURL = "https://trampa-api-test.dilig.net/";
// const baseURL = "http://192.168.88.150:3001/"; // DJOLE // const baseURL = "http://192.168.88.150:3001/"; // DJOLE
// const baseURL = "http://localhost:3001/";
const baseURL = process.env.REACT_APP_BASE_API_URL;
const baseURL = "http://localhost:3001/";
// const baseURL = process.env.REACT_APP_BASE_API_URL;


//Interceptor unique name //Interceptor unique name
export const accessTokensMiddlewareInterceptorName = "ACCESS_TOKEN_INTERCEPTOR"; export const accessTokensMiddlewareInterceptorName = "ACCESS_TOKEN_INTERCEPTOR";

Carregando…
Cancelar
Salvar