Skip to content

Commit e420008

Browse files
feat: added configuration options to K-menu (#109)
Signed-off-by: Jim Ezesinachi <[email protected]>
1 parent 95f474a commit e420008

30 files changed

+609
-36
lines changed

client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function App() {
4242
if (connectionDate && lastServerReset) {
4343
if (connectionDate < lastServerReset) {
4444
navigate('/')
45-
dispatch({ type: 'demo/RESET' })
45+
dispatch({ type: 'demo/resetState' })
4646
}
4747
}
4848
}, [connectionDate, lastServerReset])

client/src/api/ConnectionApi.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import type { AxiosResponse } from 'axios'
22

33
import { apiCall } from './BaseUrl'
44

5-
export const createInvitation = (agentName?: string, agentImageUrl?: string): Promise<AxiosResponse> => {
5+
export const createOobInvitation = (agentName?: string, agentImageUrl?: string): Promise<AxiosResponse> => {
6+
return apiCall.post('/oob/create-invitation', {
7+
autoAcceptConnection: true,
8+
label: agentName,
9+
imageUrl: agentImageUrl,
10+
})
11+
}
12+
13+
export const createLegacyInvitation = (agentName?: string, agentImageUrl?: string): Promise<AxiosResponse> => {
614
return apiCall.post('/oob/create-legacy-invitation', {
715
autoAcceptConnection: true,
816
label: agentName,

client/src/api/CredentialApi.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ import type { AxiosResponse } from 'axios'
33

44
import { apiCall } from './BaseUrl'
55

6-
export const issueCredential = async (connectionId: string, data: CredentialData): Promise<AxiosResponse> => {
6+
export const issueCredential = async (
7+
connectionId: string,
8+
data: CredentialData,
9+
protocolVersion: 'v1' | 'v2'
10+
): Promise<AxiosResponse> => {
711
return apiCall.post(`/credentials/offer-credential`, {
8-
protocolVersion: 'v1',
12+
protocolVersion: protocolVersion,
913
connectionId: connectionId,
1014
credentialFormats: {
1115
indy: {

client/src/pages/dashboard/DashboardPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export const DashboardPage: React.FC = () => {
6262
const ERROR_DESCRIPTION = `That's not gone well. Please restart the demo.`
6363
const routeError = () => {
6464
navigate('/demo')
65-
dispatch({ type: 'demo/RESET' })
65+
dispatch({ type: 'demo/resetState' })
6666
}
6767

6868
const completeDemo = () => {
6969
navigate('/')
70-
dispatch({ type: 'demo/RESET' })
70+
dispatch({ type: 'demo/resetState' })
7171

7272
if (currentCharacter)
7373
trackEvent('demo-character-completed', {

client/src/pages/dashboard/components/ProfileCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const ProfileCard: React.FC<Props> = ({ currentCharacter }) => {
2222
before you switch to another character.`
2323

2424
const reset = () => {
25-
dispatch({ type: 'demo/RESET' })
25+
dispatch({ type: 'demo/resetState' })
2626
}
2727

2828
const cancel = () => {

client/src/pages/landing/components/MainSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const MainSection: React.FC = () => {
8383
</div>
8484
<div className="flex flex-row justify-start text-base sxl:text-lg font-normal mt-6">
8585
<motion.button
86+
data-cy="try-demo-button"
8687
variants={fadeDelay}
8788
whileHover={buttonHover}
8889
className="bg-animo-black dark:bg-animo-white text-animo-white dark:text-animo-black py-3 px-5 rounded-lg font-semibold shadow-sm dark:shadow-none select-none "

client/src/pages/onboarding/OnboardingContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export const OnboardingContainer: React.FC<Props> = ({
219219
dispatch(fetchAllUseCasesByCharId(currentCharacter.id))
220220
} else {
221221
// something went wrong so reset
222-
dispatch({ type: 'demo/RESET' })
222+
dispatch({ type: 'demo/resetState' })
223223
}
224224
}
225225

@@ -235,7 +235,7 @@ export const OnboardingContainer: React.FC<Props> = ({
235235

236236
const leave = () => {
237237
navigate('/')
238-
dispatch({ type: 'demo/RESET' })
238+
dispatch({ type: 'demo/resetState' })
239239
}
240240

241241
return (

client/src/pages/onboarding/OnboardingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const OnboardingPage: React.FC = () => {
4141
dispatch(fetchAllUseCasesByCharId(currentCharacter.id))
4242
navigate('/dashboard')
4343
} else {
44-
dispatch({ type: 'demo/RESET' })
44+
dispatch({ type: 'demo/resetState' })
4545
dispatch(fetchWallets())
4646
dispatch(fetchAllCharacters())
4747
setMounted(true)

client/src/pages/onboarding/steps/AcceptCredential.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ export const AcceptCredential: React.FC<Props> = ({ content, connectionId, crede
4949
(x) => x.state === 'credential-issued' || x.state === 'done'
5050
)
5151

52+
let { protocolVersion } = useCredentials()
5253
useEffect(() => {
5354
if (credentials.length === 0) {
5455
currentCharacter.starterCredentials.forEach((item) => {
55-
dispatch(issueCredential({ connectionId: connectionId, cred: item }))
56+
dispatch(issueCredential({ connectionId: connectionId, cred: item, protocolVersion }))
5657
trackEvent('credential-issued')
5758
})
5859
setCredentialsIssued(true)
@@ -94,9 +95,11 @@ export const AcceptCredential: React.FC<Props> = ({ content, connectionId, crede
9495

9596
const routeError = () => {
9697
navigate('/demo')
97-
dispatch({ type: 'demo/RESET' })
98+
dispatch({ type: 'demo/resetState' })
9899
}
99100

101+
protocolVersion = useCredentials().protocolVersion
102+
100103
const sendNewCredentials = () => {
101104
credentials.forEach((cred) => {
102105
if (cred.state !== 'credential-issued' && cred.state !== 'done') {
@@ -110,7 +113,8 @@ export const AcceptCredential: React.FC<Props> = ({ content, connectionId, crede
110113
)
111114
})
112115

113-
if (newCredential) dispatch(issueCredential({ connectionId: connectionId, cred: newCredential }))
116+
if (newCredential)
117+
dispatch(issueCredential({ connectionId: connectionId, cred: newCredential, protocolVersion }))
114118
}
115119
})
116120
closeFailedRequestModal()

client/src/pages/onboarding/steps/SetupConnection.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Loader } from '../../../components/Loader'
1010
import { QRCode } from '../../../components/QRCode'
1111
import { useAppDispatch } from '../../../hooks/hooks'
1212
import { useInterval } from '../../../hooks/useInterval'
13+
import { useConnection } from '../../../slices/connection/connectionSelectors'
1314
import {
1415
createInvitation,
1516
fetchConnectionById,
@@ -36,9 +37,10 @@ export const SetupConnection: React.FC<Props> = ({
3637
}) => {
3738
const dispatch = useAppDispatch()
3839
const isCompleted = connectionState === 'response-sent' || connectionState === 'completed'
40+
const { useLegacyInvitations } = useConnection()
3941

4042
useEffect(() => {
41-
if (!isCompleted) dispatch(createInvitation())
43+
if (!isCompleted) dispatch(createInvitation({ useLegacyInvitations }))
4244
}, [])
4345

4446
useEffect(() => {

0 commit comments

Comments
 (0)