Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
anny1021 committed Nov 20, 2023
1 parent 21592d0 commit 5ee33e2
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/page/SqlAuditRecord/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useCurrentProjectName } from '../../ProjectManage/ProjectDetail';
import AuditResult from '../../Order/AuditResult';
import sql_audit_record from '../../../api/sql_audit_record';
import { ICreateSQLAuditRecordV1Params } from '../../../api/sql_audit_record/index.d';
import { useRef, useState, useEffect } from "react";
import { useRef, useState } from "react";
import { IAuditTaskResV1, ISQLAuditRecordResData } from '../../../api/common';
import { ResponseCode } from '../../../data/common';
import EmptyBox from '../../../components/EmptyBox';
Expand All @@ -30,7 +30,6 @@ const SQLAuditCreate: React.FC = () => {
const [sqlInfoForm] = useForm<SQLInfoFormFields>();
const { projectName } = useCurrentProjectName();
const [task, setTask] = useState<IAuditTaskResV1>();
const [finishGetResult, setFinishGetResult] = useState(false);
const baseRef = useRef<BaseInfoFormRef>(null);
const sqlInfoRef = useRef<SQLInfoFormRef>(null);

Expand All @@ -46,7 +45,6 @@ const SQLAuditCreate: React.FC = () => {

const auditSQL: SQLInfoFormProps['submit'] = async (values) => {
const baseValues = await baseForm.validateFields();
setFinishGetResult(false);
const params: ICreateSQLAuditRecordV1Params = {
project_name: projectName,
sqls: values.sql,
Expand All @@ -66,6 +64,7 @@ const SQLAuditCreate: React.FC = () => {
if ((baseValues.tags?.length ?? 0) > 0) {
return updateTags(res.data.data, baseValues);
} else {
message.success(t("sqlAudit.create.SQLInfo.successTips"));

Check warning on line 67 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
setTask(res.data.data.task);
}

Check warning on line 69 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 69 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 69 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

Check warning on line 70 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 70 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
Expand All @@ -84,6 +83,7 @@ const SQLAuditCreate: React.FC = () => {
})
.then((res) => {
if (res.data.code === ResponseCode.SUCCESS) {
message.success(t("sqlAudit.create.SQLInfo.successTips"));

Check warning on line 86 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
setTask(record.task);
}

Check warning on line 88 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 88 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
});

Check warning on line 89 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
Expand All @@ -93,18 +93,8 @@ const SQLAuditCreate: React.FC = () => {
baseRef.current?.reset();
sqlInfoRef.current?.reset();
setTask(undefined);
setFinishGetResult(false);
};

useEffect(() => {
if ((typeof task?.task_id === "number" && finishGetResult)) {
message.success(t("sqlAudit.create.SQLInfo.successTips"));
setTimeout(() => {
scrollToAuditResult();
}, 500);
}
}, [task, t, finishGetResult]);

return (
<>
<PageHeader title={t("sqlAudit.create.title")} ghost={false}>
Expand Down Expand Up @@ -141,7 +131,7 @@ const SQLAuditCreate: React.FC = () => {
auditScore={task?.score}
passRate={task?.pass_rate}
getResultCallBack={() => {
setFinishGetResult(true);
scrollToAuditResult();

Check warning on line 134 in src/page/SqlAuditRecord/Create/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}}
/>
</EmptyBox>
Expand Down

0 comments on commit 5ee33e2

Please sign in to comment.