Skip to content

Commit 2bb266d

Browse files
committed
FrontEnd Update
1 parent 96f2685 commit 2bb266d

File tree

17 files changed

+353
-89
lines changed

17 files changed

+353
-89
lines changed

web_app/Source_webapp/src/components/template/UserDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
useAppSelector,
1414
} from '@/store'
1515
import { useEffect, useState } from 'react'
16-
import { apiGetCurUserProfile } from '@/services/UserApi'
16+
import { apiGetMyProfile } from '@/services/UserApi'
1717
import { FaCode } from 'react-icons/fa'
1818
import { useRoleStore } from '@/store/user/userRoleStore'
1919

@@ -41,7 +41,7 @@ const _UserDropdown = ({ className }: CommonProps) => {
4141

4242
useEffect(() => {
4343
async function fetchData() {
44-
const resData = (await apiGetCurUserProfile()) as any
44+
const resData = (await apiGetMyProfile()) as any
4545
setProfileData(resData.data.data)
4646
dispatch(setAvatar(resData.data.data.avatar))
4747
dispatch(setFirstName(resData.data.data.firstName))
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { useWalletStore, WalletType } from '@/store/user/useWalletStore'
2+
import { useAppKit, useAppKitAccount, useDisconnect } from '@reown/appkit/react'
3+
4+
export const useConnectWallet = () => {
5+
const { walletType, setWalletType } = useWalletStore()
6+
const { isConnected } = useAppKitAccount()
7+
const { open } = useAppKit()
8+
const { disconnect } = useDisconnect()
9+
10+
const connectWallet = async (type: WalletType) => {
11+
if (!type) {
12+
throw new Error('Wallet type is invalid.')
13+
}
14+
15+
try {
16+
setWalletType(type)
17+
18+
if (isConnected) {
19+
await disconnect()
20+
}
21+
22+
open()
23+
} catch (error) {
24+
console.error('Failed to connect wallet:', error)
25+
}
26+
}
27+
28+
return { connectWallet, walletType }
29+
}

web_app/Source_webapp/src/services/ContractServices.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ export async function apiGetWalletBalance() {
77
})
88
}
99

10-
export async function apiRequestFaucet() {
10+
export async function apiRequestFaucet(
11+
type: 'identity' | 'ownership',
12+
walletAddress?: string
13+
) {
1114
return ApiService.fetchData({
1215
url: import.meta.env.VITE_URL + 'v1/contract/request-faucet',
1316
method: 'post',
17+
data: {
18+
type: type,
19+
ownerShipWalletAddress: walletAddress,
20+
},
1421
})
1522
}
1623

web_app/Source_webapp/src/services/UserApi.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ApiService from './ApiService'
22

3-
export async function apiGetCurUserProfile<T>() {
3+
export async function apiGetMyProfile<T>() {
44
return ApiService.fetchData<T>({
55
url: import.meta.env.VITE_URL + 'v1/user/get-my-profile',
66
method: 'get',
@@ -18,6 +18,21 @@ export async function apiEditUserProfile<T>(
1818
})
1919
}
2020

21+
export async function apiSetMyIdentityWallet<T>(wallet: string) {
22+
return ApiService.fetchData<T>({
23+
url: `${import.meta.env.VITE_URL}v1/user/set-my-identitity-wallet`,
24+
method: 'post',
25+
data: { wallet },
26+
})
27+
}
28+
export async function apiSetMyOwnerShipWallet<T>(wallet: string) {
29+
return ApiService.fetchData<T>({
30+
url: `${import.meta.env.VITE_URL}v1/user/set-my-ownership-wallet`,
31+
method: 'post',
32+
data: { wallet },
33+
})
34+
}
35+
2136
export async function apiChangePasswordByEmail<T>(
2237
userEmail: string,
2338
newPassword: string

web_app/Source_webapp/src/store/contract/useContractStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { apiGetCurUserProfile } from '@/services/UserApi'
1+
import { apiGetMyProfile } from '@/services/UserApi'
22
import { useAppKitAccount } from '@reown/appkit-core/react'
33
import { useAppKitProvider } from '@reown/appkit/react'
44
import { BrowserProvider, Contract, ethers, JsonRpcProvider } from 'ethers'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { create } from 'zustand'
2+
3+
export type WalletType = 'identity' | 'ownership' | undefined
4+
5+
interface WalletStore {
6+
walletType: WalletType
7+
setWalletType: (type: WalletType) => void
8+
}
9+
10+
export const useWalletStore = create<WalletStore>((set) => ({
11+
walletType: undefined,
12+
setWalletType: (type: WalletType) => set({ walletType: type }),
13+
}))

web_app/Source_webapp/src/store/user/userRoleStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { apiGetCurUserProfile } from '@/services/UserApi'
1+
import { apiGetMyProfile } from '@/services/UserApi'
22
import { create } from 'zustand'
33

44
interface Role {
@@ -32,7 +32,7 @@ export const useRoleStore = create<RoleStore>((set, get) => ({
3232
fetchUserRoles: async () => {
3333
try {
3434
set({ loading: true })
35-
const res = (await apiGetCurUserProfile()) as any
35+
const res = (await apiGetMyProfile()) as any
3636
const roles = res.data.data.roles
3737
set({ useRoles: roles, loading: false })
3838
} catch (error) {

web_app/Source_webapp/src/utils/hooks/useGetCurUserProfile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { apiGetCurUserProfile } from '@/services/UserApi'
1+
import { apiGetMyProfile } from '@/services/UserApi'
22
import { useQuery } from '@tanstack/react-query'
33

44
// Define the main response type
@@ -76,7 +76,7 @@ type RolePermission = {
7676
export function useGetCurUserProfile() {
7777
const { data: curUser, status } = useQuery({
7878
queryKey: ['curUser'],
79-
queryFn: apiGetCurUserProfile<ApiResponse>,
79+
queryFn: apiGetMyProfile<ApiResponse>,
8080
})
8181

8282
return { curUser, status }

web_app/Source_webapp/src/views/account/Settings/components/Address.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from 'react-icons/hi'
1515
import * as Yup from 'yup'
1616
import { useEffect, useState } from 'react'
17-
import { apiEditUserProfile, apiGetCurUserProfile } from '@/services/UserApi'
17+
import { apiEditUserProfile, apiGetMyProfile } from '@/services/UserApi'
1818
import CountrySelector from './CountrySelector'
1919
import { Button } from '@/components/ui'
2020
import { Loading } from '@/components/shared'
@@ -46,7 +46,7 @@ const Address = () => {
4646
useEffect(() => {
4747
async function fetchData() {
4848
setLoading(true)
49-
const resData = (await apiGetCurUserProfile()) as any
49+
const resData = (await apiGetMyProfile()) as any
5050
const datas = resData.data.data
5151
setApiData(datas)
5252
if (datas?.address?.country) {
@@ -103,7 +103,7 @@ const Address = () => {
103103
return (
104104
<Form>
105105
{(loading == false && (
106-
<FormContainer >
106+
<FormContainer>
107107
{/* <FormDesription
108108
className=""
109109
title="Personal"
@@ -221,7 +221,7 @@ const Address = () => {
221221
<div className="flex gap-3 mt-4 justify-end ltr:text-right">
222222
<Button
223223
variant="solid"
224-
size='sm'
224+
size="sm"
225225
loading={isSubmitting}
226226
type="submit"
227227
>
@@ -230,7 +230,7 @@ const Address = () => {
230230
<Button
231231
className="ltr:mr-2 rtl:ml-2"
232232
type="button"
233-
size='sm'
233+
size="sm"
234234
onClick={() => {
235235
resetForm()
236236
setSelectedCountry(null)

web_app/Source_webapp/src/views/account/Settings/components/CompanyDeveloper/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from 'react-icons/hi'
1919
import * as Yup from 'yup'
2020
import { useEffect, useState } from 'react'
21-
import { apiEditUserProfile, apiGetCurUserProfile } from '@/services/UserApi'
21+
import { apiEditUserProfile, apiGetMyProfile } from '@/services/UserApi'
2222
import { Button } from '@/components/ui'
2323
import { Loading } from '@/components/shared'
2424
import { useAppSelector } from '@/store'
@@ -61,7 +61,7 @@ export default function CompanyDeveloperPage() {
6161
async function fetchData() {
6262
setLoading(true)
6363
await fetchUserRoles()
64-
const resData = (await apiGetCurUserProfile()) as any
64+
const resData = (await apiGetMyProfile()) as any
6565
const datas = resData.data.data
6666
setApiData(datas)
6767
if (datas?.company?.country) {
@@ -175,7 +175,9 @@ export default function CompanyDeveloperPage() {
175175
label={
176176
(
177177
<div className="flex items-center">
178-
<span className='mr-1'>Company Name</span>
178+
<span className="mr-1">
179+
Company Name
180+
</span>
179181
<span>(</span>
180182
<p>
181183
{!isDeveloper && 'Not'}{' '}
@@ -315,7 +317,7 @@ export default function CompanyDeveloperPage() {
315317
variant="solid"
316318
loading={isSubmitting}
317319
type="submit"
318-
size='sm'
320+
size="sm"
319321
>
320322
{isSubmitting
321323
? 'Updating'
@@ -325,7 +327,7 @@ export default function CompanyDeveloperPage() {
325327
disabled={isDeveloper}
326328
className="ltr:mr-2 rtl:ml-2"
327329
type="button"
328-
size='sm'
330+
size="sm"
329331
onClick={() => {
330332
resetForm()
331333
setSelectedCountry(null)

0 commit comments

Comments
 (0)