fix: fix details when record already soft deleted

This commit is contained in:
yosaphatprs 2025-12-05 17:05:22 +07:00
parent 2cae1902dd
commit e6fcb80d88
2 changed files with 32 additions and 4 deletions

View File

@ -25,7 +25,7 @@ export class TindakanDokterService {
timestamp: rawFabricLog.value.timestamp,
};
console.log('Processed flat log:', flatLog);
// console.log('Processed flat log:', flatLog);
if (
index === arrLength - 1 &&
@ -303,9 +303,13 @@ export class TindakanDokterService {
});
const latestPayload = rawLogs?.[0]?.value?.payload;
const isTampered = latestPayload
? currentDataHash !== latestPayload
: false;
let isTampered;
const isDeleted = rawLogs?.[0].value?.event?.split('_')[2] === 'deleted';
if (isDeleted) {
isTampered = false;
} else {
isTampered = latestPayload ? currentDataHash !== latestPayload : false;
}
const processedLogs = Array.isArray(rawLogs)
? rawLogs.map((log, index) =>
@ -316,6 +320,7 @@ export class TindakanDokterService {
return {
logs: processedLogs,
isTampered,
isDeleted,
currentDataHash,
};
}

View File

@ -20,6 +20,7 @@ void LOG_TABLE_COLUMNS;
const tindakan = ref<TindakanDokter>();
const dataLog = ref<BlockchainLog[]>([]);
const isTampered = ref<boolean>(false);
const isDeleted = ref<boolean>(false);
const currentHash = ref<string>("");
const route = useRoute();
@ -112,9 +113,11 @@ const fetchLogData = async () => {
currentDataHash?: string;
logs?: any[];
isTampered?: boolean;
isDeleted?: boolean;
}>(`/tindakan/${route.params.id}/log`);
currentHash.value = result.currentDataHash ?? "";
isTampered.value = Boolean(result.isTampered);
isDeleted.value = Boolean(result.isDeleted);
console.log("Tindakan Log API Result:", result);
const logs = Array.isArray(result.logs) ? result.logs : [];
dataLog.value = normalizeLogEntries(logs, isTampered.value);
@ -185,6 +188,26 @@ onMounted(async () => {
</svg>
<span>Warning! Data Manipulation Detected.</span>
</div>
<div
role="alert"
class="alert alert-warning"
v-if="!isTampered && isDeleted"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 shrink-0 stroke-current"
fill="none"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<span>This data has been deleted.</span>
</div>
<DataTable
:data="dataLog"