Skip to content

Commit

Permalink
Merge pull request stakwork#615 from MahtabBukhari/onLoad-of-Modal-pu…
Browse files Browse the repository at this point in the history
…ll-data-object-for-workflow-on-load-of-feature-feature-id-stories

on load of modal pull data object for workflow on load of feature
  • Loading branch information
humansinstitute authored Nov 8, 2024
2 parents 179f26d + 869c5b1 commit 0b136f4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
52 changes: 50 additions & 2 deletions src/people/widgetViews/GenerateStoriesView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom';
import { EuiOverlayMask } from '@elastic/eui';
import { useStores } from '../../store';
import { getHost } from '../../config';
import {
GenerateStoriesModal,
GenerateStoriesHeader,
Expand All @@ -13,20 +15,66 @@ import {

const GenerateStoriesView: React.FC = () => {
const history = useHistory();
const { main } = useStores();
const { feature_uuid } = useParams<{ feature_uuid: string }>();
const [featureName, setFeatureName] = useState<string | undefined>('');
const [featureBrief, setFeatureBrief] = useState<string | undefined>('');
const [mission, setMission] = useState<string | undefined>('');
const [tactics, setTactics] = useState<string | undefined>('');

useEffect(() => {
const fetchData = async () => {
try {
if (!feature_uuid) return;

const featureData = await main.getFeaturesByUuid(feature_uuid);

setFeatureName(featureData?.name);
setFeatureBrief(featureData?.brief);

if (featureData?.workspace_uuid) {
const workspaceData = await main.getUserWorkspaceByUuid(featureData.workspace_uuid);

setMission(workspaceData?.mission);
setTactics(workspaceData?.tactics);
}
} catch (error) {
console.error('Error fetching data:', error);
}
};

fetchData();
}, [feature_uuid, main]);

const handleClose = () => {
history.push(`/feature/${feature_uuid}`);
};

const host = getHost();

const postData = {
productBrief: `Product: ${featureName}. \nProduct Brief: \n* Mission: ${mission} \n* Objectives: \n${tactics}`,
featureName: featureName ?? '',
description: featureBrief ?? '',
examples: [],
webhook_url: `${host}/features/stories`,
featureUUID: feature_uuid ?? ''
};

return (
<EuiOverlayMask>
<GenerateStoriesModal>
<GenerateStoriesHeader>
<GenerateStoriesTitle>User Story Automation</GenerateStoriesTitle>
</GenerateStoriesHeader>
<GenerateStoriesContent>
<GenerateStoriesText>Story Generation Coming Soon!</GenerateStoriesText>
<GenerateStoriesText>
{postData ? (
<pre>{JSON.stringify(postData, null, 2)}</pre>
) : (
'Story Generation Coming Soon!'
)}
</GenerateStoriesText>
</GenerateStoriesContent>
<GenerateStoriesFooter>
<GenerateStoriesButton onClick={handleClose}>Cancel</GenerateStoriesButton>
Expand Down
2 changes: 1 addition & 1 deletion src/people/widgetViews/workspace/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ export const GenerateStoriesText = styled.p`
font-size: 18px;
color: #5f6368;
margin: 0;
text-align: center;
width: 500px;
`;

export const GenerateStoriesFooter = styled.div`
Expand Down

0 comments on commit 0b136f4

Please sign in to comment.