From 03cf5c6d93a35daf46b6c903e24f0e72f6bcdf7f Mon Sep 17 00:00:00 2001 From: Radhika Patel <64517071+patelradhika@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:16:08 +0530 Subject: [PATCH] Fix v0.9.0 testing errors (#336) * fix tool board error * fix testing errors --- package.json | 2 +- src/pages/ProductRoadmap/forms/AddFeatures.js | 1 + src/pages/ProductRoadmap/forms/AddIssues.js | 1 + src/pages/ProductRoadmap/forms/ToolBoard.js | 11 ++++++---- .../mutations/product/createBoardMutation.js | 22 ++++++++++--------- .../product/updateProductMutation.js | 4 +++- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 6865e587..3f9802b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "buildly-react-template", - "version": "v0.9.1", + "version": "v0.9.2", "description": "Frontend Template from Buildly built using the React framework", "main": "src/index.js", "private": true, diff --git a/src/pages/ProductRoadmap/forms/AddFeatures.js b/src/pages/ProductRoadmap/forms/AddFeatures.js index 9c86dfdc..4243c79d 100644 --- a/src/pages/ProductRoadmap/forms/AddFeatures.js +++ b/src/pages/ProductRoadmap/forms/AddFeatures.js @@ -244,6 +244,7 @@ const AddFeatures = ({ location, history }) => { product_uuid, ...featCred?.auth_detail, feature_detail: { + ...(editData.feature_detail || {}), assigneees: _.filter(assigneeData, (u) => ( !!u && _.includes(assignees, u.username) )), diff --git a/src/pages/ProductRoadmap/forms/AddIssues.js b/src/pages/ProductRoadmap/forms/AddIssues.js index cd700b93..18348b69 100644 --- a/src/pages/ProductRoadmap/forms/AddIssues.js +++ b/src/pages/ProductRoadmap/forms/AddIssues.js @@ -186,6 +186,7 @@ const AddIssues = ({ history, location }) => { repository: repo.value, column_id: colID, issue_detail: { + ...(editData.issue_detail || {}), assignees, }, ...issueCred?.auth_detail, diff --git a/src/pages/ProductRoadmap/forms/ToolBoard.js b/src/pages/ProductRoadmap/forms/ToolBoard.js index cf08f4ee..b31e7a3b 100644 --- a/src/pages/ProductRoadmap/forms/ToolBoard.js +++ b/src/pages/ProductRoadmap/forms/ToolBoard.js @@ -15,6 +15,7 @@ import { } from '@mui/material'; import FormModal from '@components/Modal/FormModal'; import Loader from '@components/Loader/Loader'; +import { getUser } from '@context/User.context'; import useAlert from '@hooks/useAlert'; import { getBoardQuery } from '@react-query/queries/product/getBoardQuery'; import { useCreateBoardMutation } from '@react-query/mutations/product/createBoardMutation.js'; @@ -40,8 +41,10 @@ const useStyles = makeStyles((theme) => ({ }, })); -const ToolBoard = ({ history }) => { +const ToolBoard = ({ history, location }) => { const classes = useStyles(); + const user = getUser(); + const organization = user.organization.organization_uuid; const { displayAlert } = useAlert(); const redirectTo = location.state && location.state.from; @@ -69,7 +72,7 @@ const ToolBoard = ({ history }) => { () => getBoardQuery(product_uuid, displayAlert), { refetchOnWindowFocus: false, enabled: !_.isEmpty(product_uuid) && !_.isEqual(_.toNumber(product_uuid), 0) }, ); - const { mutate: createBoardMutation, isLoading: isCreatingBoardLoading } = useCreateBoardMutation(history, redirectTo, displayAlert); + const { mutate: createBoardMutation, isLoading: isCreatingBoardLoading } = useCreateBoardMutation(organization, product_uuid, history, redirectTo, displayAlert); useEffect(() => { if (!_.isEmpty(boards)) { @@ -137,7 +140,7 @@ const ToolBoard = ({ history }) => { const statusCols = !_.isEmpty(status) ? _.map(status, (sts) => ({ column_name: sts })) : featStatusList; - const statusData = _.map(statusCols, (sts) => ({ + const newStatusData = _.map(statusCols, (sts) => ({ product_uuid, name: sts.column_name, description: sts.column_name, @@ -145,7 +148,7 @@ const ToolBoard = ({ history }) => { is_default_status: !!(sts.column_name === defaultStatus), })); - createBoardMutation(formData, statusData); + createBoardMutation({ formData, newStatusData }); }; const submitDisabled = () => { diff --git a/src/react-query/mutations/product/createBoardMutation.js b/src/react-query/mutations/product/createBoardMutation.js index c89814cf..dc82c2ed 100644 --- a/src/react-query/mutations/product/createBoardMutation.js +++ b/src/react-query/mutations/product/createBoardMutation.js @@ -2,21 +2,22 @@ import { useMutation, useQueryClient } from 'react-query'; import { httpService } from '@modules/http/http.service'; import _ from 'lodash'; -export const useCreateBoardMutation = (history, redirectTo, displayAlert) => { +export const useCreateBoardMutation = (organization, product_uuid, history, redirectTo, displayAlert) => { const queryClient = useQueryClient(); return useMutation( - async (createBoardData, statusData) => { + async (multipleData) => { + const { formData, newStatusData } = multipleData; const response = await httpService.makeRequest( 'post', - `${window.env.API_URL}product/board-configuration/?product_uuid=${createBoardData.product_uuid}`, - createBoardData, + `${window.env.API_URL}product/board-configuration/?product_uuid=${product_uuid}`, + formData, ); if (response && response.data) { - if (!_.isEmpty(statusData)) { - if (_.size(statusData) > 1) { + if (!_.isEmpty(newStatusData)) { + if (_.size(newStatusData) > 1) { const statuses = await Promise.all( - _.map(statusData, (status_data) => ( + _.map(newStatusData, (status_data) => ( httpService.makeRequest( 'post', `${window.env.API_URL}release/status/`, @@ -28,7 +29,7 @@ export const useCreateBoardMutation = (history, redirectTo, displayAlert) => { const status = await httpService.makeRequest( 'post', `${window.env.API_URL}release/status/`, - statusData, + newStatusData, ); } } @@ -37,8 +38,9 @@ export const useCreateBoardMutation = (history, redirectTo, displayAlert) => { }, { onSuccess: async (data) => { - await queryClient.invalidateQueries({ queryKey: ['board', data.product_uuid] }); - await queryClient.invalidateQueries({ queryKey: ['allStatuses', data.product_uuid] }); + await queryClient.invalidateQueries({ queryKey: ['board', product_uuid] }); + await queryClient.invalidateQueries({ queryKey: ['allStatuses', product_uuid] }); + await queryClient.invalidateQueries({ queryKey: ['allProducts', organization] }); displayAlert('success', 'Product Board and Statuses created successfully'); if (history) { history.push(redirectTo); diff --git a/src/react-query/mutations/product/updateProductMutation.js b/src/react-query/mutations/product/updateProductMutation.js index d789e26e..fb5d37e3 100644 --- a/src/react-query/mutations/product/updateProductMutation.js +++ b/src/react-query/mutations/product/updateProductMutation.js @@ -16,8 +16,10 @@ export const useUpdateProductMutation = (organization, history, redirectTo, clea { onSuccess: async (data) => { await queryClient.invalidateQueries({ queryKey: ['allProducts', organization] }); - clearProductFormData(); displayAlert('success', 'Product updated successfully'); + if (clearProductFormData) { + clearProductFormData(); + } if (history) { history.push(redirectTo); }