Skip to content

Commit

Permalink
fix(cards): fix add cart bug (#5194)
Browse files Browse the repository at this point in the history
  • Loading branch information
ariunzayarin committed May 10, 2024
1 parent e36c05b commit 2379d14
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/plugin-viber-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,4 @@ jobs:
run: |
tar -cf build.tar --directory=packages/plugin-viber-ui/dist .
cp build.tar packages/plugin-viber-ui/dist
aws s3 sync packages/plugin-viber-ui/dist s3://erxes-${GITHUB_REF#refs/heads/}-plugins/uis/plugin-viber-ui --delete
13 changes: 4 additions & 9 deletions packages/plugin-clientportal-ui/src/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ module.exports = {
"./routes": "./src/routes.tsx",
"./cardDetailAction": "./src/containers/comments/CardDetailAction.tsx",
"./fieldConfig": "./src/containers/FieldConfigForm.tsx",
"./vendorSection":
"./clientPortalSection":
"./src/containers/cardsRightSidebarSection/VendorSection.tsx",
"./clientSection":
"./src/containers/cardsRightSidebarSection/ClientSection.tsx",
},
cardDetailAction: "./cardDetailAction",
fieldConfig: "./fieldConfig",
Expand All @@ -30,10 +28,7 @@ module.exports = {
permissions: [],
},
],
// taskRightSidebarSection: "./clientSection",
taskRightSidebarSection: "./vendorSection",
// ticketRightSidebarSection: "./clientSection",
ticketRightSidebarSection: "./vendorSection",
// dealRightSidebarSection: "./clientSection",
dealRightSidebarSection: "./vendorSection",
taskRightSidebarSection: "./clientPortalSection",
ticketRightSidebarSection: "./clientPortalSection",
dealRightSidebarSection: "./clientPortalSection",
};
22 changes: 19 additions & 3 deletions packages/ui-cards/src/boards/containers/Pipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { graphql } from "@apollo/client/react/hoc";
import { queries } from "../graphql";
import styled from "styled-components";
import { withProps } from "@erxes/ui/src/utils";
import { useLocation, useNavigate } from "react-router-dom";

const Container = styled.div`
height: 100%;
Expand All @@ -30,6 +31,8 @@ type Props = {
initialItemMap?: IItemMap;
stageMap?: IStageMap;
queryParams: any;
navigate: any;
location: any;
options: IOptions;
};

Expand Down Expand Up @@ -67,6 +70,8 @@ class WithStages extends Component<WithStagesQueryProps> {
options,
queryParams,
stagesQuery,
navigate,
location,
} = this.props;

const stagesCount = this.countStages(stageMap);
Expand All @@ -89,6 +94,8 @@ class WithStages extends Component<WithStagesQueryProps> {
queryParams={queryParams}
options={options}
queryParamsChanged={this.queryParamsChanged}
navigate={navigate}
location={location}
>
<PipelineConsumer>
{({
Expand Down Expand Up @@ -155,11 +162,12 @@ class WithStages extends Component<WithStagesQueryProps> {

type WithStagesQueryProps = {
stagesQuery: StagesQueryResponse;
} &
Props;
} & Props;

const WithStagesQuery = (props: WithStagesQueryProps) => {
const { stagesQuery } = props;
const navigate = useNavigate();
const location = useLocation();

if (stagesQuery.loading) {
return <Spinner />;
Expand All @@ -175,7 +183,15 @@ const WithStagesQuery = (props: WithStagesQueryProps) => {
stageMap[stage._id] = stage;
}

return <WithStages {...props} stageMap={stageMap} initialItemMap={itemMap} />;
return (
<WithStages
{...props}
navigate={navigate}
location={location}
stageMap={stageMap}
initialItemMap={itemMap}
/>
);
};

type WithQueryProps = Props & { abortController };
Expand Down
8 changes: 5 additions & 3 deletions packages/ui-cards/src/boards/containers/PipelineContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type WrapperProps = {
initialItemMap?: IItemMap;
options: IOptions;
children: any;
navigate: any;
location: any;
queryParams: IFilterParams & INonFilterParams;
queryParamsChanged: (
queryParams: IFilterParams,
Expand Down Expand Up @@ -532,15 +534,15 @@ class PipelineProviderInner extends React.Component<Props, State> {
const { itemMap, itemIds } = this.state;
const items = itemMap[stageId] || [];

const { queryParams } = this.props;
const { queryParams, navigate, location } = this.props;

if (!aboveItemId) {
this.setState({
itemMap: { ...itemMap, [stageId]: [item, ...items] },
itemIds: [...itemIds, item._id],
});

isRefresh(queryParams, routerUtils);
isRefresh(queryParams, routerUtils, navigate, location);

return;
}
Expand All @@ -559,7 +561,7 @@ class PipelineProviderInner extends React.Component<Props, State> {
});
}

isRefresh(queryParams, routerUtils);
isRefresh(queryParams, routerUtils, navigate, location);
};

onRemoveItem = (itemId: string, stageId: string) => {
Expand Down
11 changes: 6 additions & 5 deletions packages/ui-cards/src/boards/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Amount, HeaderAmount } from "./styles/stage";
import { ColumnProps, getCommonParams } from "./components/Calendar";
import { IDraggableLocation, IFilterParams, IItem, IItemMap } from "./types";
import { STORAGE_BOARD_KEY, STORAGE_PIPELINE_KEY } from "./constants";
import { useLocation, useNavigate } from "react-router-dom";

import { IDateColumn } from "@erxes/ui/src/types";
import PriorityIndicator from "./components/editForm/PriorityIndicator";
Expand Down Expand Up @@ -286,12 +285,14 @@ export const getColors = (index: number) => {
return COLORS[index];
};

export const isRefresh = (queryParams: any, routerUtils: any) => {
export const isRefresh = (
queryParams: any,
routerUtils: any,
navigate: any,
location: any
) => {
const keys = Object.keys(queryParams || {});

const navigate = useNavigate();
const location = useLocation();

if (!(keys.length === 2 || (keys.includes("key") && keys.length === 3))) {
routerUtils.setParams(navigate, location, { key: Math.random() });
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/pluginsMap.js

Large diffs are not rendered by default.

0 comments on commit 2379d14

Please sign in to comment.