Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jprymak committed Mar 28, 2022
2 parents 947c503 + 2b7f4f5 commit cc9822a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
18 changes: 18 additions & 0 deletions src/api/issue/mockIssueDetails.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { mockIssues } from "../../mockData/mockIssues";

function sleep(ms = 1000) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

const mockIssueDetails = mockIssues[0];

const MockIssueDetailsAPI = {
getData: async function (url: string) {
await sleep();
return { data: mockIssueDetails };
},
};

export default MockIssueDetailsAPI;
1 change: 1 addition & 0 deletions src/mockData/mockIssues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const mockIssues = [
statusId: 1,
id: 0,
isActive: true,
assignUserId: "Han Solo",
},
{
alias: "mock issue 2",
Expand Down
4 changes: 4 additions & 0 deletions src/views/Board/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Board = () => {
const [isSuccess, setIsSuccess] = useState(false);

const { boardId, projectName, projectId, board } = useParams();
const [state, setState] = useState({});

useEffect(() => {
async function fetchStatus() {
Expand All @@ -63,6 +64,9 @@ export const Board = () => {
}
fetchStatus();
fetchIssues();
return () => {
setState({});
};
}, [isSuccess]);

const fetchIssues = useCallback(async () => {
Expand Down
64 changes: 49 additions & 15 deletions src/views/IssueDetails/IssueDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import Grid from "@mui/material/Grid";
Expand All @@ -15,21 +15,61 @@ import {
TextNormal,
TextOutlined,
} from "./IssueDetails.style";
import { useParams } from "react-router-dom";
import { API_ISSUE } from "../../api/contsans";

let FetchDataAPI: any;

async function importApiModule() {
if (localStorage["USE_MOCK"] === "true") {
const module = await import("../../api/issue/mockIssueDetails");
FetchDataAPI = module.default;
console.log(FetchDataAPI);
} else {
const module = await import("../../api/requestsApi");
FetchDataAPI = module.default;
}
}

export const IssueDetails = () => {
const { t } = useTranslation();

const issueStatus = [t("ToDo"), t("InProgress"), t("Done")];
const [status, setStatus] = useState<string>(t("ToDo"));

const handleSelect = (e: any) => {
const { issueId, projectName } = useParams();
const [issueTitle, setIssueTitle] = useState("");
const [issueDescription, setIssueDescription] = useState("");
const [assigneeName, setAssigneeName] = useState("");
const reporterName = "Joe Doe";
const linkedIssues = "Apples & Oranges";
const [state, setState] = useState({});

function handleSelect(e: any) {
setStatus(e.target.value);
};
}

const fetchIssueDetails = useCallback(async () => {
await importApiModule();
FetchDataAPI.getData(API_ISSUE.concat(issueId!)).then((res: any) => {
setIssueTitle(res.data.name);
setIssueDescription(res.data.description);
setAssigneeName(res.data.assignUserId);
});
}, []);

useEffect(() => {
fetchIssueDetails();
return () => {
setState({});
};
}, []);

return (
<StyledPageWrapper>
<PageHeader
returnLink='Return to Awesome project'
pageTitle='The Best Issue'
pageTitle={issueTitle}
interactiveElement={
<Select
options={issueStatus}
Expand All @@ -42,32 +82,26 @@ export const IssueDetails = () => {
<Grid container spacing={4}>
<Grid item xs={8}>
<Section>
<IssueTitle>{t("dialogCreateProjectTitle")}</IssueTitle>
<IssueTitle>{projectName}</IssueTitle>
<Box>
<Label>{t("labelDescription")}</Label>
<TextNormal>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure
iusto nostrum voluptatibus fugiat ducimus delectus officia
aspernatur adipisci quibusdam consectetur, facere aut!
Aspernatur quaerat dolorem repellat tempora possimus quas
soluta!
</TextNormal>
<TextNormal>{issueDescription}</TextNormal>
</Box>
<Box>
<Label>{t("labelLinkedIssues")}</Label>
<TextOutlined>Apples & Oranges</TextOutlined>
<TextOutlined>{linkedIssues}</TextOutlined>
</Box>
</Section>
</Grid>
<Grid item xs={4}>
<Section>
<Box>
<Label>{t("labelAssignee")}</Label>
<TextOutlined>Han Solo</TextOutlined>
<TextOutlined>{assigneeName}</TextOutlined>
</Box>
<Box>
<Label>{t("labelReporter")}</Label>
<TextOutlined>Joe Doe</TextOutlined>
<TextOutlined>{reporterName}</TextOutlined>
</Box>
</Section>
</Grid>
Expand Down

0 comments on commit cc9822a

Please sign in to comment.