Skip to content

Commit e46b04f

Browse files
Merge pull request #9 from Web3-Plurality/orbis-map-api
Orbis map api
2 parents 88e2f62 + d3b800f commit e46b04f

File tree

10 files changed

+106
-97
lines changed

10 files changed

+106
-97
lines changed

.env

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
11
PORT=4000
22
NEXT_PUBLIC_DASHBOARD_API=https://app.plurality.local
3-
4-
# Orbis
5-
NEXT_PUBLIC_CERAMIC_URL=https://ceramic-orbisdb-mainnet-direct.hirenodes.io/
6-
NEXT_PUBLIC_ORBIS_NODE_URL=https://studio.useorbis.com
7-
NEXT_PUBLIC_ORBIS_ENV=did:pkh:eip155:1:0x49b330af2e9b16189a55d45bcf808d2d92bce1f6
8-
NEXT_PUBLIC_PLURALITY_CONTEXT=kjzl6kcym7w8y5af2n9u66uif7kb9xqxstaybypzg3hewlm7y1cg2746mo6dbkj
9-
NEXT_PUBLIC_PROFILE_TYPE_MODEL=kjzl6hvfrbw6c604bf1hd7tfooalbcgzwvu3aprhghe7t6k96tb5iowkjo7f1ps

.env.production.example

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
NEXT_PUBLIC_DASHBOARD_API=https://app.plurality.network/api
2-
3-
# Orbis
4-
NEXT_PUBLIC_CERAMIC_URL=https://ceramic-orbisdb-mainnet-direct.hirenodes.io/
5-
NEXT_PUBLIC_ORBIS_NODE_URL=https://studio.useorbis.com
6-
NEXT_PUBLIC_ORBIS_ENV=did:pkh:eip155:1:0x75ae41fd57f7f0ffdfdab923cae384944764e743
7-
NEXT_PUBLIC_PLURALITY_CONTEXT=kjzl6kcym7w8yb7hqhsjcbdikv8valtk5quvnbt1xbkzdlf8snqi9flidx6t35y
8-
NEXT_PUBLIC_PROFILE_TYPE_MODEL=kjzl6hvfrbw6cavbybdjvudbpn7in15h7zdlk6dg5h31o9s6qsfew32ky0qty19

.env.staging.example

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
NEXT_PUBLIC_DASHBOARD_API=https://app.plurality.local
2-
3-
# Orbis
4-
NEXT_PUBLIC_CERAMIC_URL=https://ceramic-orbisdb-mainnet-direct.hirenodes.io/
5-
NEXT_PUBLIC_ORBIS_NODE_URL=https://studio.useorbis.com
6-
NEXT_PUBLIC_ORBIS_ENV=did:pkh:eip155:1:0x49b330af2e9b16189a55d45bcf808d2d92bce1f6
7-
NEXT_PUBLIC_PLURALITY_CONTEXT=kjzl6kcym7w8y5af2n9u66uif7kb9xqxstaybypzg3hewlm7y1cg2746mo6dbkj
8-
NEXT_PUBLIC_PROFILE_TYPE_MODEL=kjzl6hvfrbw6c604bf1hd7tfooalbcgzwvu3aprhghe7t6k96tb5iowkjo7f1ps

app/dashboard/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function DashboardPage() {
7171
const stream_data = await selectProfileType(streamId);
7272

7373
// If the rows array is empty, we can set default values
74-
const { profile_name = '', description = '' } = stream_data?.rows[0] || {};
74+
const { profile_name = '', description = '' } = stream_data?.profileTypeData || {}
7575

7676
return {
7777
...app, // Retain the existing app properties

app/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProjectProvider } from "@/contexts/ProjectContext"
2-
import { ThemeProvider } from "next-themes"
2+
// import { ThemeProvider } from "next-themes"
33
import "./globals.css"
44
import Navbar from "@/components/ui/navbar"
55
import { Lexend } from 'next/font/google';
@@ -23,7 +23,7 @@ export default function RootLayout({
2323
<link rel="icon" href="favicon.png" type="image/x-icon" />
2424
</head>
2525
<body>
26-
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
26+
{/* <ThemeProvider attribute="class" defaultTheme="system" enableSystem> */}
2727
<AuthProvider>
2828
<Navbar />
2929
<ProjectProvider>
@@ -38,7 +38,7 @@ export default function RootLayout({
3838
</Suspense>
3939
</ProjectProvider>
4040
</AuthProvider>
41-
</ThemeProvider>
41+
{/* </ThemeProvider> */}
4242
</body>
4343
</html>
4444
)

components/WidgetCard.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,14 @@ export default function WidgetCard({
479479
const data = await selectProfileType(profile.streamId)
480480

481481
const profileDetails = {
482-
profileName: data?.rows?.[0]?.profile_name,
483-
profileDescription: data?.rows?.[0]?.description,
484-
id: data?.rows?.[0]?.profile_name,
485-
label: toTitleCase(data?.rows?.[0]?.profile_name),
482+
profileName: data?.profileTypeData?.profileName,
483+
profileDescription: data?.profileTypeData?.description,
484+
id: data?.profileTypeData?.id,
485+
label: toTitleCase(data?.profileTypeData?.profileName),
486486
streamId: profile.streamId,
487487
}
488-
const platforms = data?.rows?.[0]?.platforms
489-
? JSON.parse(data.rows[0].platforms)?.map((platformObj: any) => platformObj.platform)
488+
const platforms = data?.profileTypeData?.platforms
489+
? JSON.parse(data.profileTypeData.platforms)?.map((platformObj: any) => platformObj.platform)
490490
: []
491491
return { platforms, profileDetails }
492492
} catch (error) {
@@ -533,8 +533,8 @@ export default function WidgetCard({
533533

534534
const getCustomAppPlatforms = async (appStreamId: string) => {
535535
const data = await selectProfileType(appStreamId)
536-
const customPlatforms = data?.rows?.[0]?.platforms
537-
? JSON.parse(data.rows[0].platforms)?.map((platformObj: any) => platformObj.platform)
536+
const customPlatforms = data?.profileTypeData?.platforms
537+
? JSON.parse(data.profileTypeData.platforms)?.map((platformObj: any) => platformObj.platform)
538538
: []
539539
setSelectedProfileType((prev) => ({
540540
...prev,
@@ -741,7 +741,7 @@ export default function WidgetCard({
741741
description: (
742742
<span>
743743
Unlock personalized experiences, gated access, cross-device storage & much more.
744-
<a href="#" className="text-teal-500 hover:underline ml-1 underline">
744+
<a href="https://docs.plurality.network/the-core-protocol/structure-of-a-smart-profile" className="text-teal-500 hover:underline ml-1 underline">
745745
Learn more
746746
</a>
747747
</span>
@@ -765,15 +765,15 @@ export default function WidgetCard({
765765

766766
return (
767767
<Button
768-
key={type.profileDetails.id}
768+
key={type.profileDetails?.id}
769769
disabled={id ? disable || (!disable && type.profileDetails.id !== "custom") : false}
770770
variant={isSelected ? "default" : "outline"}
771771
className={`
772772
${isSelected ? "bg-teal-500 hover:bg-teal-600 text-white" : "bg-white text-gray-700 hover:bg-gray-50"}
773773
`}
774774
onClick={() => setSelectedProfileType(type)}
775775
>
776-
{type.profileDetails.label}
776+
{type.profileDetails?.label}
777777
</Button>
778778
)
779779
})}

components/clientInterface.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ export default function ClientInterface({
2121
const { general, authOptions } = customizationData;
2222
const isDark = general.theme === "dark";
2323

24+
25+
const progress = ((currentQuestionIndex + 1) / questions.length) * 100
26+
2427
return (
2528
<div
2629
className={`w-[450px] h-[600px] rounded-[30px] overflow-auto shadow-lg border ${isDark
2730
? "bg-gray-900 border-gray-700 text-white"
2831
: "bg-[#F9F9F9] border-gray-100 text-gray-900"
2932
} flex flex-col`}
3033
>
31-
<div className="mb-8 mt-8 flex flex-col items-center">
34+
{expandedSection === 'userOnboarding' && <p className="text-black text-[25px] w-full px-8 py-3">Profile Setup</p>}
35+
<div className={`${expandedSection === 'userOnboarding' ? '' : 'mb-8 mt-8'} flex flex-col items-center`}>
3236
{expandedSection === 'platformConnection' && <p className="text-[30px] font-semibold mb-2
3337
leading-[1.2]
3438
max-w-[80%]
@@ -46,14 +50,31 @@ export default function ClientInterface({
4650
general.theme === 'dark' && general.icon.light ? (
4751
<img src={general.icon.dark} alt="Client Logo" className="h-full object-contain" />) : 'Client Logo'}
4852
</div>}
53+
54+
55+
{expandedSection === 'userOnboarding' && (
56+
<>
57+
<div className="w-full">
58+
<div className="h-1.5 w-full bg-gray-200 rounded-full overflow-hidden">
59+
{questions.length > 0 && (
60+
<div
61+
className="bg-gray-800 h-full transition-all duration-300"
62+
style={{ width: `${progress}%` }}
63+
/>
64+
)}
65+
</div>
66+
</div>
67+
</>
68+
)}
69+
4970
</div>
5071

5172
{/* Content Section */}
5273
<div className={`flex-grow flex-col
5374
flex overflow-y-auto gap-4
54-
${expandedSection === 'userOnboarding' ? questions[currentQuestionIndex]?.type != 'CATEGORY_QUESTION' ? "justify-center" : "px-4": "justify-center"}
75+
${expandedSection === 'userOnboarding' ? questions[currentQuestionIndex]?.type != 'CATEGORY_QUESTION' ? "justify-center" : "px-4" : "justify-center"}
5576
${expandedSection === 'profileConfig' ? 'mb-[5rem]' :
56-
expandedSection === 'deploymentConfig' || expandedSection === 'userOnboarding' ? '' :
77+
expandedSection === 'deploymentConfig' || expandedSection === 'userOnboarding' ? '' :
5778
'mb-12'}`}
5879
>
5980
{(expandedSection === 'customize' || !expandedSection) &&
@@ -72,6 +93,8 @@ export default function ClientInterface({
7293
{expandedSection === 'deploymentConfig' &&
7394
<DeploymentConfig
7495
appName={appName}
96+
profileName={profileName}
97+
selectedProfileType={selectedProfileType}
7598
/>}
7699

77100
{expandedSection === 'platformConnection' &&

components/clientInterface/deploymentConfig.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
import { Button } from "@/components/ui/button"
44

55
interface ConfirmationDialogProps {
6-
appName?: string
7-
profileName?: string
6+
appName: string
7+
profileName: string
8+
selectedProfileType: any
89
}
910

10-
export default function DeploymentConfig({
11-
appName = "TheApp",
12-
profileName = "XSmartProfile",
13-
}: ConfirmationDialogProps) {
11+
export default function DeploymentConfig({ appName, profileName, selectedProfileType }: ConfirmationDialogProps) {
12+
console.log(selectedProfileType, 'sele')
1413
return (
1514
<div className="max-w-sm mx-auto rounded-xl overflow-hidden">
1615
<div className="p-6 flex flex-col items-center">
@@ -21,7 +20,7 @@ export default function DeploymentConfig({
2120
{/* Description */}
2221
<p className="text-sm text-gray-700 mb-4 text-center">
2322
You are allowing <span className="font-semibold">{appName}</span> to access private data from your{" "}
24-
<span className="font-semibold">{profileName}</span>:
23+
<span className="font-semibold">{profileName !== '<profile_name>' ? profileName : `${selectedProfileType?.profileDetails?.profileName} profile`}</span>:
2524
</p>
2625

2726
{/* Data Points List */}

components/clientInterface/oboardingQuestions.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const OnboardingQuestions = ({ questions, currentQuestionIndex, setCurrentQuesti
7272
setAnswers(questions.map((q) => {
7373
if (q.type === "CATEGORY_QUESTION") {
7474
// Flatten tags from all categories
75-
const allTags = q.categories.flatMap(cat =>
75+
const allTags = q.categories.flatMap(cat =>
7676
cat.tags?.map(tag => ({ ...tag, selected: false })) || []
7777
)
7878
return {
@@ -199,11 +199,10 @@ const OnboardingQuestions = ({ questions, currentQuestionIndex, setCurrentQuesti
199199
<button
200200
key={tag.id}
201201
onClick={() => handleTagToggle(tag.id)}
202-
className={`px-4 py-2 rounded-full text-sm font-medium transition-colors ${
203-
isSelected
204-
? "bg-gray-900 text-white"
205-
: "bg-white text-gray-800 border border-gray-300 hover:bg-gray-100"
206-
}`}
202+
className={`px-4 py-2 rounded-full text-sm font-medium transition-colors ${isSelected
203+
? "bg-gray-900 text-white"
204+
: "bg-white text-gray-800 border border-gray-300 hover:bg-gray-100"
205+
}`}
207206
>
208207
{tag.text}
209208
</button>
@@ -230,13 +229,13 @@ const OnboardingQuestions = ({ questions, currentQuestionIndex, setCurrentQuesti
230229

231230
<h2 className="text-2xl font-bold text-gray-800 mb-3">
232231
{questions[currentQuestionIndex]?.type === 'CATEGORY_QUESTION' ? (
233-
<>{questions[currentQuestionIndex]?.mainQuestion}</>
232+
<>{questions[currentQuestionIndex]?.mainQuestion}</>
234233
) : (
235234
<>
236-
{questions[currentQuestionIndex]?.mainQuestion || `Question ${currentQuestionIndex + 1}`}
235+
{questions[currentQuestionIndex]?.mainQuestion || `Question ${currentQuestionIndex + 1}`}
237236
</>
238237
)}
239-
238+
240239
</h2>
241240

242241
{questions[currentQuestionIndex]?.type !== 'CATEGORY_QUESTION' && <p className="text-gray-600 mb-6">

lib/orbis-utils.ts

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,55 @@
1-
import { OrbisDB } from "@useorbis/db-sdk";
1+
//import { OrbisDB } from "@useorbis/db-sdk";
2+
import axios from "axios";
23

3-
const orbisdb = new OrbisDB({
4-
ceramic: {
5-
gateway: process.env.NEXT_PUBLIC_CERAMIC_URL || ''
6-
},
7-
nodes: [
8-
{
9-
gateway: process.env.NEXT_PUBLIC_ORBIS_NODE_URL || '',
10-
env: process.env.NEXT_PUBLIC_ORBIS_ENV || ''
11-
}
12-
]
13-
})
4+
// const orbisdb = new OrbisDB({
5+
// ceramic: {
6+
// gateway: process.env.NEXT_PUBLIC_CERAMIC_URL || ''
7+
// },
8+
// nodes: [
9+
// {
10+
// gateway: process.env.NEXT_PUBLIC_ORBIS_NODE_URL || '',
11+
// env: process.env.NEXT_PUBLIC_ORBIS_ENV || ''
12+
// }
13+
// ]
14+
// })
1415

15-
const data = {
16-
contexts: {
17-
plurality: process.env.NEXT_PUBLIC_PLURALITY_CONTEXT,
18-
},
19-
models: {
20-
test_model: process.env.NEXT_PUBLIC_TEST_MODEL,
21-
profile_type_model: process.env.NEXT_PUBLIC_PROFILE_TYPE_MODEL
22-
}
23-
}
16+
// const data = {
17+
// contexts: {
18+
// plurality: process.env.NEXT_PUBLIC_PLURALITY_CONTEXT,
19+
// },
20+
// models: {
21+
// test_model: process.env.NEXT_PUBLIC_TEST_MODEL,
22+
// profile_type_model: process.env.NEXT_PUBLIC_PROFILE_TYPE_MODEL
23+
// }
24+
// }
2425

26+
// export async function selectProfileType1(stream_id: string) {
27+
// try {
28+
// let selectStatement = await orbisdb.select().from(data.models.profile_type_model || '')
29+
// .where({
30+
// stream_id: stream_id
31+
// })
32+
// .context(process.env.NEXT_PUBLIC_PLURALITY_CONTEXT || '');
33+
// // const query = selectStatement.build()
34+
// // console.log("Query that will be run", query)
35+
// const result= await selectStatement.run();
36+
// // console.log("Result", result)
37+
// // console.log(result);
38+
// // columns: Array<string>
39+
// // rows: Array<T | Record<string, any>>
40+
// const { columns, rows } = result
41+
// // console.log({ columns, rows });
42+
// return { columns, rows };
43+
// }
44+
// catch (error) {
45+
// console.log("Error", error)
46+
// }
47+
// }
48+
49+
2550
export async function selectProfileType(stream_id: string) {
26-
try {
27-
let selectStatement = await orbisdb.select().from(data.models.profile_type_model || '')
28-
.where({
29-
stream_id: stream_id
30-
})
31-
.context(process.env.NEXT_PUBLIC_PLURALITY_CONTEXT || '');
32-
// const query = selectStatement.build()
33-
// console.log("Query that will be run", query)
34-
const result= await selectStatement.run();
35-
// console.log("Result", result)
36-
// console.log(result);
37-
// columns: Array<string>
38-
// rows: Array<T | Record<string, any>>
39-
const { columns, rows } = result
40-
// console.log({ columns, rows });
41-
return { columns, rows };
42-
}
43-
catch (error) {
44-
console.log("Error", error)
45-
}
46-
}
51+
const apiUrl = `${process.env.NEXT_PUBLIC_DASHBOARD_API}/orbis-map/profile-types/${stream_id}`
52+
const result = await axios.get(apiUrl)
53+
// console.log("Data asd", result, result.data.data)
54+
return {profileTypeData: result.data.data}
55+
}

0 commit comments

Comments
 (0)