Skip to content

Commit

Permalink
Fix v0.9.0 testing errors (#336)
Browse files Browse the repository at this point in the history
* fix tool board error

* fix testing errors
  • Loading branch information
patelradhika authored Aug 21, 2024
1 parent b17f3a7 commit 03cf5c6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/pages/ProductRoadmap/forms/AddFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)),
Expand Down
1 change: 1 addition & 0 deletions src/pages/ProductRoadmap/forms/AddIssues.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ const AddIssues = ({ history, location }) => {
repository: repo.value,
column_id: colID,
issue_detail: {
...(editData.issue_detail || {}),
assignees,
},
...issueCred?.auth_detail,
Expand Down
11 changes: 7 additions & 4 deletions src/pages/ProductRoadmap/forms/ToolBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -137,15 +140,15 @@ 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,
status_tracking_id: sts.column_id || null,
is_default_status: !!(sts.column_name === defaultStatus),
}));

createBoardMutation(formData, statusData);
createBoardMutation({ formData, newStatusData });
};

const submitDisabled = () => {
Expand Down
22 changes: 12 additions & 10 deletions src/react-query/mutations/product/createBoardMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/`,
Expand All @@ -28,7 +29,7 @@ export const useCreateBoardMutation = (history, redirectTo, displayAlert) => {
const status = await httpService.makeRequest(
'post',
`${window.env.API_URL}release/status/`,
statusData,
newStatusData,
);
}
}
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/react-query/mutations/product/updateProductMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 03cf5c6

Please sign in to comment.