Skip to content

Commit

Permalink
Merge pull request #1329 from AletheiaFact/bug-fix-verification-reque…
Browse files Browse the repository at this point in the history
…st-recomendations

BugFix: VerificationRequest
  • Loading branch information
thesocialdev authored Aug 8, 2024
2 parents 7f85ae2 + 505da94 commit f4c8fbb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ const VerificationRequestList = () => {
title={t(
"verificationRequest:verificationRequestListHeader"
)}
renderItem={(item, index) => (
renderItem={(item) => (
<VerificationRequestCard
key={index}
key={item._id}
content={item}
t={t}
expandable={false}
actions={[
<AletheiaButton
key={`open|${item._id}`}
href={`/verification-request/${item.data_hash}`}
>
{t(
Expand Down
19 changes: 12 additions & 7 deletions src/components/VerificationRequest/VerificationRequestProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const VerificationRequestProvider = ({
const addRecommendation = async (
newVerificationRequest: VerificationRequest
): Promise<void> => {
const groupContent = group.content.filter(
(v) => v._id !== verificationRequest._id
);
const groupContent =
group?.content?.filter((v) => v._id !== verificationRequest._id) ||
[];

await verificationRequestApi.updateVerificationRequest(
verificationRequest._id,
Expand All @@ -52,10 +52,15 @@ export const VerificationRequestProvider = ({
};

const addInGroup = (newVerificationRequest: VerificationRequest): void => {
setGroup((prev) => ({
...prev,
content: [...prev.content, newVerificationRequest],
}));
setGroup((prev) => {
if (!prev) {
return { content: [newVerificationRequest] };
}
return {
...prev,
content: [...prev.content, newVerificationRequest],
};
});
};

const removeFromGroup = (verificationRequestId: string): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/types/Group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VerificationRequest } from "./VerificationRequest";

export type Group = {
_id: string;
_id?: string;
content: VerificationRequest[];
};
2 changes: 1 addition & 1 deletion src/types/VerificationRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export type VerificationRequest = {
group: Group;
date: Date;
sources?: string[];
_id: string;
_id?: string;
};

0 comments on commit f4c8fbb

Please sign in to comment.