Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notify block with store data #35

Merged
merged 1 commit into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import setupStore from './utils/setup';


const App: Component = () => {
let username = "kirahsapong";
let username = "tbd";
const { pathname } = useLocation();
const [ isLoading, setIsLoading ] = createSignal(true);

Expand Down
13 changes: 8 additions & 5 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { A } from '@solidjs/router';
import routes from '../../routes/routes';
import Icon, { ArrowRight, Bell, ChevronDown, ExternalArrow, Plus } from '../../icons/Icon';
import NotifyBlock, { NotifyBlockContent } from '../NotifyBlock/NotifyBlock';
import { store } from '../../utils/store';

const Header: Component<{ username: string }> = (props) => {
return (
Expand Down Expand Up @@ -82,22 +83,24 @@ export const notifications: NotifyBlockContent[] = [
{
title: "View applications",
href: "/credentials/applications",
hasNotify: true,
message: "You have pending applications to resolve"
hasNotify: !!store.applications?.length,
...!!store.applications?.length && { message: "You have pending applications to resolve" }
},
{
title: "View submissions",
href: "/verification/submissions"
href: "/verification/submissions",
hasNotify: store.submissions && !!Object.values(store.submissions)?.length,
...store.submissions && !!Object.values(store.submissions)?.length && { message: "You have pending applications to resolve" }
}
]

const createMenu = [
{
title: "new credential",
title: "New credential",
href: "/credentials"
},
{
title: "new submission link",
title: "New submission link",
href: "/verification"
}
]
1 change: 1 addition & 0 deletions src/components/NotifyBlock/NotifyBlock.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
color: var(--color-blue);
border: 1px solid;
padding: 1rem;
min-width: 300px;

&-content {
display: flex;
Expand Down
6 changes: 6 additions & 0 deletions src/components/Panel/Panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@
background: var(--orange-20);
border: 1px solid var(--color-orange);
}

&-info {
color: var(--color-black);
background: var(--blue-120);
border: 1px solid var(--color-blue);
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AdminOverview/AdminOverview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"c c d"
"c c e";
grid-template-columns: 3fr 1fr 3fr;
grid-template-rows: 3fr 1fr 1fr;
grid-template-rows: 1fr 1fr;

& > :is(:nth-child(1)) {
grid-area: a;
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Credentials/views/Applications/Applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Applications: Component = () => {
incoming: {
id: "incoming",
title: "Incoming",
listItems: transformApplications(store.applications),
listItems: transformApplications(applications),
fallback: "You have no new Applications to review, so there's nothing here.",
buttons: [
{
Expand Down Expand Up @@ -55,7 +55,10 @@ const transformApplications = (applications) => {
return {
name: `****-${application.id.slice(-4)}`,
id: Object.values(store.credentials).find((credential : { id, name}) => credential.id === application.manifest_id)?.["name"],
type: "Needs Review"
tag: {
type: "info",
label: "Needs Review",
}
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const IssueModal: Component<{ content }> = (props) => {
const isFormValid = () => {
const isExpiryValid = formValues().expires ? formValues().expiry !== '' : true;
const isSubjectValid = formValues().subject !== '';
const isSubjectDataValid = formValues().properties.trim() !== '' && formValues().properties.trim() !== schemaProperties;
const isSubjectDataValid = formValues().properties.trim() !== '' && formValues().properties.trim() !== schemaProperties
return isExpiryValid && isSubjectValid && isSubjectDataValid && !isError();
}

Expand Down
22 changes: 14 additions & 8 deletions src/pages/Verification/views/Submissions/Submissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Submissions: Component = () => {
"for-review": {
id: "for-review",
title: "For Review",
listItems: transformSubmissions(store.submissions),
listItems: transformSubmissions(store.submissions["pending"]),
fallback: "You have no new Submissions to review, so there's nothing here.",
buttons: [
{
Expand Down Expand Up @@ -49,14 +49,20 @@ const Submissions: Component = () => {
export default Submissions;

const transformSubmissions = (submissions) => {
return Object.values(submissions).flatMap((submissionSet: []) => {
return [...submissionSet.map((submission: { verifiablePresentation, status }) => {
if (typeof submissions === "object") {
submissions = Object.values(submissions);
}
if (submissions) {
return submissions.map((submission: { verifiablePresentation, status }) => {
return {
name: `****-${submission.verifiablePresentation.id.slice(-4)}`,
id: store.definitions.find(definition => definition.id === submission.verifiablePresentation.presentation_submission.definitionID)?.name,
type: submission.status
id: store.definitions?.find(definition => definition.id === submission.verifiablePresentation.presentation_submission.definitionID)?.name,
tag: {
type: "info",
label: submission.status[0].toUpperCase() + submission.status.substring(1)
}
}
})]

})
});
};
return [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const submissions = [
},
{
"reason": "good reasons",
"status": "approved",
"status": "pending",
"verifiablePresentation": {
"holder": "did:key:1234567",
"id": "12345-123456-123456",
Expand Down
12 changes: 6 additions & 6 deletions src/utils/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ const setupStore = async () => {
}

// hydrate the store
if (Object.values(store.user).length === 0) {
if (store.user && Object.values(store.user).length === 0) {
await hydrateDIDStore();
}
if (store.manifests.length === 0) {
if (store.manifests?.length === 0) {
await hydrateManifestStore();
}
if (store.applications.length === 0) {
if (store.applications?.length === 0) {
await hydrateApplicationStore();
}
if (store.definitions.length === 0) {
if (store.definitions?.length === 0) {
await hydrateDefinitionStore();
}
if (Object.values(store.submissions).length === 0) {
await hydrateSubmissionStore("pending");
await hydrateSubmissionStore("approved");
await hydrateSubmissionStore("denied");
}
if (store.schemas.length === 0) {
if (store.schemas?.length === 0) {
await hydrateSchemaStore();
}
if (store.deletedDIDs.length === 0) {
if (store.deletedDIDs?.length === 0) {
await hydrateDeletedDIDsStore();
}
// we hydrate these because there may be objects not issued by a newly set did
Expand Down