Update frontend to use reportFile on Audit
Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -41,7 +41,7 @@ const requestAccessMutation = graphql`
|
||||
mutation AuditRow_requestAccessMutation($input: RequestReportAccessInput!) {
|
||||
requestReportAccess(input: $input) {
|
||||
audit {
|
||||
report {
|
||||
reportFile {
|
||||
access {
|
||||
id
|
||||
status
|
||||
@@ -55,7 +55,7 @@ const requestAccessMutation = graphql`
|
||||
const auditRowFragment = graphql`
|
||||
fragment AuditRowFragment on Audit {
|
||||
name
|
||||
report {
|
||||
reportFile {
|
||||
id
|
||||
isUserAuthorized
|
||||
access {
|
||||
@@ -80,7 +80,7 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const audit = useFragment(auditRowFragment, props.audit);
|
||||
const hasRequested = audit.report?.access?.status === "REQUESTED";
|
||||
const hasRequested = audit.reportFile?.access?.status === "REQUESTED";
|
||||
|
||||
const [requestAccess, isRequestingAccess]
|
||||
= useMutation<AuditRow_requestAccessMutation>(requestAccessMutation);
|
||||
@@ -89,7 +89,7 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
|
||||
requestAccess({
|
||||
variables: {
|
||||
input: {
|
||||
reportId: audit.report?.id ?? "",
|
||||
reportId: audit.reportFile?.id ?? "",
|
||||
},
|
||||
},
|
||||
onCompleted: (_, errors) => {
|
||||
@@ -110,7 +110,7 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
|
||||
onError: (error) => {
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
const pathPrefix = getPathPrefix();
|
||||
searchParams.set("request-report-id", audit.report?.id ?? "");
|
||||
searchParams.set("request-report-id", audit.reportFile?.id ?? "");
|
||||
const urlSearchParams = new URLSearchParams([[
|
||||
"continue",
|
||||
window.location.origin + pathPrefix + location.pathname + "?" + searchParams.toString(),
|
||||
@@ -135,14 +135,14 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
|
||||
<IconMedal size={16} className="flex-none text-txt-tertiary" />
|
||||
{audit.name ?? audit.framework.name}
|
||||
</div>
|
||||
{audit.report && (
|
||||
audit.report.isUserAuthorized
|
||||
{audit.reportFile && (
|
||||
audit.reportFile.isUserAuthorized
|
||||
? (
|
||||
<Button
|
||||
className="w-full md:w-max"
|
||||
variant="secondary"
|
||||
icon={IconArrowLink}
|
||||
to={`/documents/${audit.report.id}`}
|
||||
to={`/documents/${audit.reportFile.id}`}
|
||||
>
|
||||
{__("View")}
|
||||
</Button>
|
||||
|
||||
@@ -48,7 +48,7 @@ const reportMutation = graphql`
|
||||
) {
|
||||
requestReportAccess(input: $input) {
|
||||
audit {
|
||||
report {
|
||||
reportFile {
|
||||
access {
|
||||
id
|
||||
status
|
||||
|
||||
@@ -70,9 +70,9 @@ export const documentPageQuery = graphql`
|
||||
status
|
||||
}
|
||||
}
|
||||
... on Report {
|
||||
... on AuditReport {
|
||||
id
|
||||
filename
|
||||
fileName
|
||||
isUserAuthorized
|
||||
access {
|
||||
id
|
||||
@@ -149,7 +149,7 @@ const requestReportAccessMutation = graphql`
|
||||
) {
|
||||
requestReportAccess(input: $input) {
|
||||
audit {
|
||||
report {
|
||||
reportFile {
|
||||
access {
|
||||
id
|
||||
status
|
||||
@@ -185,8 +185,8 @@ function getNodeTitle(node: DocumentPageQueryType["response"]["node"]): string |
|
||||
return node.title;
|
||||
case "TrustCenterFile":
|
||||
return node.name;
|
||||
case "Report":
|
||||
return node.filename;
|
||||
case "AuditReport":
|
||||
return node.fileName;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ function getNodeId(node: DocumentPageQueryType["response"]["node"]): string | un
|
||||
switch (node.__typename) {
|
||||
case "Document":
|
||||
case "TrustCenterFile":
|
||||
case "Report":
|
||||
case "AuditReport":
|
||||
return node.id;
|
||||
default:
|
||||
return undefined;
|
||||
@@ -221,7 +221,7 @@ export function DocumentPage({ queryRef }: Props) {
|
||||
if (
|
||||
node.__typename !== "Document"
|
||||
&& node.__typename !== "TrustCenterFile"
|
||||
&& node.__typename !== "Report"
|
||||
&& node.__typename !== "AuditReport"
|
||||
) {
|
||||
throw new Error(`Unexpected node type: ${node.__typename}`);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ export function DocumentPage({ queryRef }: Props) {
|
||||
onError,
|
||||
});
|
||||
break;
|
||||
case "Report":
|
||||
case "AuditReport":
|
||||
exportReport({
|
||||
variables: { input: { reportId: node.id } },
|
||||
onCompleted: (response, errors) => {
|
||||
@@ -358,7 +358,7 @@ export function DocumentPage({ queryRef }: Props) {
|
||||
onError,
|
||||
});
|
||||
break;
|
||||
case "Report":
|
||||
case "AuditReport":
|
||||
requestReportAccess({
|
||||
variables: { input: { reportId: node.id } },
|
||||
onCompleted,
|
||||
@@ -370,7 +370,7 @@ export function DocumentPage({ queryRef }: Props) {
|
||||
|
||||
const isRequesting = isRequestingAccess || isRequestingFileAccess || isRequestingReportAccess;
|
||||
const hasRequested = node.access?.status === "REQUESTED";
|
||||
const isPdf = node.__typename === "Document" || node.__typename === "Report" || (node.__typename === "TrustCenterFile" && pdfData !== null);
|
||||
const isPdf = node.__typename === "Document" || node.__typename === "AuditReport" || (node.__typename === "TrustCenterFile" && pdfData !== null);
|
||||
|
||||
const handleDownload = () => {
|
||||
if (!fileData || !nodeTitle) return;
|
||||
|
||||
Reference in New Issue
Block a user