Skip to content

Commit

Permalink
devonfw-forge#41: added headers to some requests
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahffm committed Dec 23, 2022
1 parent 8fffc71 commit df2905e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export const Estimation: FunctionComponent<EstimationProps> = ({ id }) => {
method: "put",
url: url,
data: { id: evaluatedTask.id, status: Status.Ended, result: res },
headers: {
Accept: "application/json",
"Content-Type": " application/json",
Authorization: `Bearer ${token}`,
}
});

if (result.status == 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTaskStore } from "../Stores/TaskStore";
import { baseUrl, serviceUrl } from "../../../../../Constants/url";
import { Checkbox } from "./Checkmark";
import { useAuthStore } from "../../../Authentication/Stores/AuthStore";
import React from "react";

export const TaskCard: FunctionComponent<{
id: String;
Expand All @@ -23,6 +24,11 @@ export const TaskCard: FunctionComponent<{
finalValue?: Number;
}> = ({ id, parentSession, title, url, description, status, complexityAverage, finalValue }) => {
const { isAdmin, userId, token } = useAuthStore();
const authHeaders = {
Accept: "application/json",
"Content-Type": " application/json",
Authorization: `Bearer ${token}`,
};

const requestStatusChange = async (newStatus: Status) => {
const url = baseUrl + serviceUrl + parentSession + "/task/status";
Expand All @@ -31,40 +37,22 @@ export const TaskCard: FunctionComponent<{
method: "put",
url: url,
data: { id: id, status: convertStatusToNumber(newStatus) },
headers: {
Accept: "application/json",
"Content-Type": " application/json",
Authorization: `Bearer ${token}`,
},
headers: authHeaders
});
};

console.log("Average: " + complexityAverage);
console.log("FinalValue: " + finalValue);

const { deleteTask } = useTaskStore();
const requestDeleteTask = async () => {
const url = baseUrl + serviceUrl + parentSession + "/task/" + id;
const result = await axios.delete(url);
const result = await axios.delete(url, {
headers: authHeaders
});

if (result.status == 200) {
deleteTask(id);
}
};

const renderCheckmark = () => {

return (
<Checkbox
key = {"checkbox"}
size = {"25px"}
backgroundColor = {"#0DA65A"}
accentColor = {" #FFFFFF"}
/>
)

}

const renderAdministrativeView = () => {
return (
<>
Expand Down Expand Up @@ -105,19 +93,19 @@ export const TaskCard: FunctionComponent<{
);
case Status.Ended:
return (
<>
<>
{renderFinalValueOnClosedTasks()}
</>
<button
className={
"bg-orange-500 p-2 mb-2 bg-warning font-bold p-1 mt-2 rounded"
<>
{renderFinalValueOnClosedTasks()}
</>
<button
className={
"bg-orange-500 p-2 mb-2 bg-warning font-bold p-1 mt-2 rounded"
}
onClick={() => requestStatusChange(Status.Open)}
>
Vote again
</button>
</>
>
Vote again
</button>
</>
);
default:
return <></>
Expand Down Expand Up @@ -154,13 +142,23 @@ export const TaskCard: FunctionComponent<{
<>
{renderCheckmark()}
</>
<div style={colorStyle}>
Rated: {finalValue}
</div>

<div style={colorStyle}>
Rated: {finalValue}
</div>
</>
);

const renderCheckmark = () => {
return (
<Checkbox
key={"checkbox"}
size={"25px"}
backgroundColor={"#0DA65A"}
accentColor={" #FFFFFF"}
/>
)
}

return (
<>
<div
Expand Down
3 changes: 1 addition & 2 deletions client/pages/session/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export default function Session({ id, tasks, users, auth, inviteToken }: any) {
const { addUser } = useSessionUserStore();

useEffect(() => {
const { tasks } = data;
setCurrentTasks(tasks);

setCurrentUsers(users);
const { role, username, userId, token } = auth;
login(username, token, userId, role);
Expand Down

0 comments on commit df2905e

Please sign in to comment.