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

feat: add legal-dao card and attester param in router #15

Merged
merged 3 commits into from
Feb 3, 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
12 changes: 12 additions & 0 deletions packages/app-config/src/ctypes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export const ctypeMeta: Record<HexString, CTypeMeta> = {
'0x15ea88be73bd78986a41141fc86497f0cfef4a0d1b5463d100758edca37c546b': {
type: 'all',
card: 'christmas2022/bac_card2.webp'
},
'0xa99186086d83f834f0bf951cb7f78cd142f147f3bd7a689086f157418944716c': {
type: 'attest',
card: 'legal-dao/bg2.jpeg',
icon: 'legal-dao/icon.jpeg',
color: '#FFFFFF'
},
'0xfd4a31cc472ab8fa4fdb8a1096cb3e8fc52514c92193602f5996b912ed898b02': {
type: 'attest',
card: 'legal-dao/bg2.jpeg',
icon: 'legal-dao/icon.jpeg',
color: '#FFFFFF'
}
};

Expand Down
1 change: 1 addition & 0 deletions packages/app-config/src/ctypes/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type CTypeMeta = {
icon?: string;
card?: string;
bg?: string;
color?: string;
};
Binary file added packages/app/public/legal-dao/bg2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/public/legal-dao/icon.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/page-account/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Account: React.FC = () => {
}

loginWallet().then(() => {
navigate(redirect ?? '/claimer/ctype');
navigate(redirect ?? '/claimer');
});
}, [loginWallet, redirect, login, navigate, toggleOpen]);

Expand Down
24 changes: 20 additions & 4 deletions packages/page-ctype/src/create/CreateClaim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import type { CType } from '@zcloak/ctype/types';
import type { AnyJson } from '@zcloak/vc/types';

import React, { useCallback, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import React, { useCallback, useMemo, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';

import { Did } from '@zcloak/did';

Expand All @@ -20,7 +20,7 @@ import {
} from '@credential/react-components';
import { CreateSubject } from '@credential/react-ctype';
import { InputDid } from '@credential/react-dids';
import { useCTypeMetaForAttest, useToggle } from '@credential/react-hooks';
import { useCTypeMetaForAttest, useQueryParam, useToggle } from '@credential/react-hooks';

import SubmitClaim from './SubmitClaim';

Expand All @@ -29,6 +29,17 @@ function CreateClaim({ ctype, isAuto }: { ctype: CType; isAuto: boolean }) {
const [attester, setAttester] = useState<Did | null>(null);
const [contents, setContents] = useState<AnyJson>({});
const navigate = useNavigate();
const { id } = useParams();

const [_attester] = useQueryParam<string>('attester');

const defaultAttester = useMemo(() => {
if (ctype.$id === id) {
return _attester ?? undefined;
}

return undefined;
}, [ctype, id, _attester]);

const ctypeMeta = useCTypeMetaForAttest(ctype.$id);

Expand Down Expand Up @@ -58,7 +69,12 @@ function CreateClaim({ ctype, isAuto }: { ctype: CType; isAuto: boolean }) {
<Typography mb={4} textAlign="center" variant="h2">
Create Claim
</Typography>
<InputDid label="Attester" onChange={setAttester} />
<InputDid
defaultValue={defaultAttester}
disabled={!!defaultAttester}
label="Attester"
onChange={setAttester}
/>
<Box mt={2}>
<CreateSubject onChange={setContents as any} schema={ctype} />
</Box>
Expand Down
3 changes: 2 additions & 1 deletion packages/react-components/src/CTypeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ function CTypeCard({ actions, ctype, meta }: Props) {
? {
background: `url(${meta.card}) no-repeat, #fff`,
backgroundSize: 'cover',
backgroundPosition: 'center'
backgroundPosition: 'center',
color: meta?.color
}
: {}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/react-dids/src/DidsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ function DidsProvider({ children, didRole }: { didRole: DidRole; children: React
{isLocked ? <UnlockModal did={did} onUnlock={unUnlock} open /> : children}
</DidsContext.Provider>
) : (
<Navigate to={{ pathname: '/account', search: `?redirect=${location.pathname}` }} />
<Navigate
to={{ pathname: '/account', search: `?redirect=${location.pathname}${location.search}` }}
/>
);
}

Expand Down