Skip to content

Commit 6ecab40

Browse files
authored
Merge pull request #62 from coderKrysio/master
adding connections done successfully
2 parents 5a6d415 + 6ea9070 commit 6ecab40

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

app/card/[id]/page.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export default function Card({params}: any) {
2222
contactNo: "",
2323
socials: [],
2424
})
25+
26+
const handleAddBtn = () => {
27+
AccountAPI.getAccount()
28+
.then((res: any) => {
29+
AccountAPI.addingCard(res.$id, params.id)
30+
router.push(`/profile/${res.$id}`)
31+
})
32+
}
2533

2634
useEffect(()=>{
2735
AccountAPI.getCardUser(params.id)
@@ -77,6 +85,7 @@ export default function Card({params}: any) {
7785

7886
<button
7987
className='w-fit border-2 font-semibold border-[#17242a] rounded-md px-9 py-3 m-auto mb-3 mt-5 hover:bg-[#ffd803] hover:border-transparent'
88+
onClick={handleAddBtn}
8089
>Add</button>
8190
</div>
8291
</div>

lib/accountapi.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ export const AccountAPI = {
191191
)
192192
},
193193

194+
addingCard: async (userId: any, cardId: any) => {
195+
return await database.listDocuments(DATABASE_ID, CARD_COLLECTION_ID,
196+
[
197+
Query.equal("userId", [userId])
198+
]
199+
).then((res: any) => {
200+
database.updateDocument(DATABASE_ID, CARD_COLLECTION_ID, res.documents[0].$id,{
201+
card1: cardId,
202+
})
203+
.then(() => { console.log("updated cards")
204+
}).catch((err: any) => console.log(err))
205+
}).catch((err: any) => console.log(err))
206+
},
207+
194208
userInitials: async(userName: any) => {
195209
return avatars.getInitials(userName).href
196210
},

0 commit comments

Comments
 (0)