@@ -7,26 +7,29 @@ import {
|
|||||||
} from "relay-runtime";
|
} from "relay-runtime";
|
||||||
import { buildEndpoint } from "./utils";
|
import { buildEndpoint } from "./utils";
|
||||||
|
|
||||||
const fetchRelay: FetchFunction = async (request, variables, _, uploadables) => {
|
const fetchRelay: FetchFunction = async (
|
||||||
|
request,
|
||||||
|
variables,
|
||||||
|
_,
|
||||||
|
uploadables,
|
||||||
|
) => {
|
||||||
const requestInit: RequestInit = {
|
const requestInit: RequestInit = {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
credentials: 'include',
|
credentials: "include",
|
||||||
headers: {},
|
headers: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (uploadables) {
|
if (uploadables) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(
|
formData.append(
|
||||||
'operations',
|
"operations",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
operationName: request.name,
|
operationName: request.name,
|
||||||
query: request.text,
|
query: request.text,
|
||||||
variables: variables,
|
variables: variables,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const uploadableMap: {
|
const uploadableMap: {
|
||||||
[key: string]: string[];
|
[key: string]: string[];
|
||||||
} = {};
|
} = {};
|
||||||
@@ -35,19 +38,19 @@ const fetchRelay: FetchFunction = async (request, variables, _, uploadables) =>
|
|||||||
uploadableMap[index] = [`variables.${key}`];
|
uploadableMap[index] = [`variables.${key}`];
|
||||||
});
|
});
|
||||||
|
|
||||||
formData.append('map', JSON.stringify(uploadableMap));
|
formData.append("map", JSON.stringify(uploadableMap));
|
||||||
|
|
||||||
Object.keys(uploadables).forEach((key, index) => {
|
Object.keys(uploadables).forEach((key, index) => {
|
||||||
formData.append(index.toString(), uploadables[key]);
|
formData.append(index.toString(), uploadables[key]);
|
||||||
});
|
});
|
||||||
|
|
||||||
requestInit.body = formData;
|
requestInit.body = formData;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
requestInit.headers = {
|
requestInit.headers = {
|
||||||
"Accept": "application/graphql-response+json; charset=utf-8, application/json; charset=utf-8",
|
Accept:
|
||||||
"Content-Type": "application/json"
|
"application/graphql-response+json; charset=utf-8, application/json; charset=utf-8",
|
||||||
}
|
"Content-Type": "application/json",
|
||||||
|
};
|
||||||
|
|
||||||
requestInit.body = JSON.stringify({
|
requestInit.body = JSON.stringify({
|
||||||
operationName: request.name,
|
operationName: request.name,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const Textarea = React.forwardRef<
|
|||||||
<textarea
|
<textarea
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
className
|
className,
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function BreadcrumbHome({ children }: { children: React.ReactNode }) {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ organizationId: organizationId! },
|
{ organizationId: organizationId! },
|
||||||
{ fetchPolicy: "store-or-network" }
|
{ fetchPolicy: "store-or-network" },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -118,7 +118,7 @@ function BreadcrumbFrameworkOverview() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ frameworkId: frameworkId! }
|
{ frameworkId: frameworkId! },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -152,7 +152,7 @@ function BreadcrumbUpdateFramework() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ frameworkId: frameworkId! },
|
{ frameworkId: frameworkId! },
|
||||||
{ fetchPolicy: "store-or-network" }
|
{ fetchPolicy: "store-or-network" },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -209,7 +209,7 @@ function BreadcrumbVendorOverview() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ vendorId: vendorId! },
|
{ vendorId: vendorId! },
|
||||||
{ fetchPolicy: "store-or-network" }
|
{ fetchPolicy: "store-or-network" },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -269,7 +269,7 @@ function BreadcrumbPeopleOverview() {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ peopleId: peopleId! },
|
{ peopleId: peopleId! },
|
||||||
{ fetchPolicy: "store-or-network" }
|
{ fetchPolicy: "store-or-network" },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -302,7 +302,7 @@ function BreadcrumbControlOverview() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ controlId: controlId! }
|
{ controlId: controlId! },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -333,7 +333,7 @@ function BreadcrumbCreateControl() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
{ frameworkId: frameworkId! }
|
{ frameworkId: frameworkId! },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ function ControlOverviewPageContent({
|
|||||||
}) {
|
}) {
|
||||||
const data = usePreloadedQuery<ControlOverviewPageQueryType>(
|
const data = usePreloadedQuery<ControlOverviewPageQueryType>(
|
||||||
controlOverviewPageQuery,
|
controlOverviewPageQuery,
|
||||||
queryRef
|
queryRef,
|
||||||
);
|
);
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { organizationId, frameworkId, controlId } = useParams();
|
const { organizationId, frameworkId, controlId } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [updateTaskState] =
|
const [updateTaskState] =
|
||||||
useMutation<ControlOverviewPageUpdateTaskStateMutationType>(
|
useMutation<ControlOverviewPageUpdateTaskStateMutationType>(
|
||||||
updateTaskStateMutation
|
updateTaskStateMutation,
|
||||||
);
|
);
|
||||||
const [createTask] =
|
const [createTask] =
|
||||||
useMutation<ControlOverviewPageCreateTaskMutationType>(createTaskMutation);
|
useMutation<ControlOverviewPageCreateTaskMutationType>(createTaskMutation);
|
||||||
@@ -138,7 +138,7 @@ function ControlOverviewPageContent({
|
|||||||
useMutation<ControlOverviewPageDeleteTaskMutationType>(deleteTaskMutation);
|
useMutation<ControlOverviewPageDeleteTaskMutationType>(deleteTaskMutation);
|
||||||
const [uploadEvidence] =
|
const [uploadEvidence] =
|
||||||
useMutation<ControlOverviewPageUploadEvidenceMutationType>(
|
useMutation<ControlOverviewPageUploadEvidenceMutationType>(
|
||||||
uploadEvidenceMutation
|
uploadEvidenceMutation,
|
||||||
);
|
);
|
||||||
const control = data.control;
|
const control = data.control;
|
||||||
const tasks = control?.tasks?.edges.map((edge) => edge?.node) ?? [];
|
const tasks = control?.tasks?.edges.map((edge) => edge?.node) ?? [];
|
||||||
@@ -281,7 +281,7 @@ function ControlOverviewPageContent({
|
|||||||
|
|
||||||
const handleEditControl = () => {
|
const handleEditControl = () => {
|
||||||
navigate(
|
navigate(
|
||||||
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${controlId}/update`
|
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${controlId}/update`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ function ControlOverviewPageFallback() {
|
|||||||
export default function ControlOverviewPage() {
|
export default function ControlOverviewPage() {
|
||||||
const { controlId } = useParams();
|
const { controlId } = useParams();
|
||||||
const [queryRef, loadQuery] = useQueryLoader<ControlOverviewPageQueryType>(
|
const [queryRef, loadQuery] = useQueryLoader<ControlOverviewPageQueryType>(
|
||||||
controlOverviewPageQuery
|
controlOverviewPageQuery,
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ function EditableField({
|
|||||||
}
|
}
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full resize-none",
|
"w-full resize-none",
|
||||||
required && !value && "border-red-500"
|
required && !value && "border-red-500",
|
||||||
)}
|
)}
|
||||||
placeholder={`Enter ${label.toLowerCase()}`}
|
placeholder={`Enter ${label.toLowerCase()}`}
|
||||||
rows={4}
|
rows={4}
|
||||||
@@ -134,7 +134,7 @@ function UpdateFrameworkPageContent({
|
|||||||
|
|
||||||
const [commit, isInFlight] =
|
const [commit, isInFlight] =
|
||||||
useMutation<UpdateFrameworkPageUpdateFrameworkMutation>(
|
useMutation<UpdateFrameworkPageUpdateFrameworkMutation>(
|
||||||
updateFrameworkMutation
|
updateFrameworkMutation,
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleFieldChange = (field: keyof typeof formData, value: unknown) => {
|
const handleFieldChange = (field: keyof typeof formData, value: unknown) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user