mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
bug: edit form user info
This commit is contained in:
5
framework/vendure/schema.d.ts
vendored
5
framework/vendure/schema.d.ts
vendored
@@ -317,6 +317,9 @@ export type Address = Node & {
|
|||||||
customFields?: Maybe<Scalars['JSON']>
|
customFields?: Maybe<Scalars['JSON']>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type Asset = Node & {
|
export type Asset = Node & {
|
||||||
__typename?: 'Asset'
|
__typename?: 'Asset'
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
@@ -3167,7 +3170,7 @@ export type ActiveCustomerQuery = { __typename?: 'Query' } & {
|
|||||||
activeCustomer?: Maybe<
|
activeCustomer?: Maybe<
|
||||||
{ __typename?: 'Customer' } & Pick<
|
{ __typename?: 'Customer' } & Pick<
|
||||||
Customer,
|
Customer,
|
||||||
'id' | 'firstName' | 'lastName' | 'emailAddress'
|
'id' | 'firstName' | 'lastName' | 'emailAddress' | 'addresses'
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
|
15
framework/vendure/utils/queries/user-info-query.ts
Normal file
15
framework/vendure/utils/queries/user-info-query.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export const userInfoQuery = /* GraphQL */ `
|
||||||
|
query activeCustomer{
|
||||||
|
activeCustomer{
|
||||||
|
emailAddress
|
||||||
|
addresses{
|
||||||
|
name:fullName
|
||||||
|
address:streetLine1
|
||||||
|
city
|
||||||
|
state:province
|
||||||
|
postalCode
|
||||||
|
phoneNumber
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
3
next-env.d.ts
vendored
3
next-env.d.ts
vendored
@@ -1,6 +1,3 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/types/global" />
|
/// <reference types="next/types/global" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
|
||||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
|
||||||
|
12
src/components/hooks/user/useUserInfo.tsx
Normal file
12
src/components/hooks/user/useUserInfo.tsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { ActiveCustomerQuery } from '@framework/schema'
|
||||||
|
import { userInfoQuery } from '@framework/utils/queries/user-info-query'
|
||||||
|
import gglFetcher from 'src/utils/gglFetcher'
|
||||||
|
import useSWR from 'swr'
|
||||||
|
|
||||||
|
const useUserInfo = () => {
|
||||||
|
const { data } = useSWR<ActiveCustomerQuery>([userInfoQuery], gglFetcher)
|
||||||
|
|
||||||
|
return { userInfo: data?.activeCustomer}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useUserInfo
|
@@ -12,7 +12,9 @@ import EditInfoModal from './components/EditInfoModal/EditInfoModal'
|
|||||||
import { PRODUCT_CART_DATA_TEST } from 'src/utils/demo-data';
|
import { PRODUCT_CART_DATA_TEST } from 'src/utils/demo-data';
|
||||||
import { ACCOUNT_TAB, QUERY_KEY } from "src/utils/constanst.utils"
|
import { ACCOUNT_TAB, QUERY_KEY } from "src/utils/constanst.utils"
|
||||||
import { useRouter } from "next/router"
|
import { useRouter } from "next/router"
|
||||||
|
import { useActiveCustomer } from 'src/components/hooks/auth'
|
||||||
|
import useUserInfo from "src/components/hooks/user/useUserInfo"
|
||||||
|
import { AccountProps } from "./components/AccountInfomation/AccountInfomation"
|
||||||
const waiting = [
|
const waiting = [
|
||||||
{
|
{
|
||||||
id: "NO 123456",
|
id: "NO 123456",
|
||||||
@@ -53,9 +55,10 @@ const delivered = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
let account = {
|
let account = {
|
||||||
name: "vu duong",
|
firstName: "Nhân",
|
||||||
|
lastName: "Trần",
|
||||||
email: "vuduong@gmail.com",
|
email: "vuduong@gmail.com",
|
||||||
address: "234 Dien Bien Phu Bis, Dakao ward",
|
address: "235 Dien Bien Phu Bis, Dakao ward",
|
||||||
state: "District 1",
|
state: "District 1",
|
||||||
city: "HCMC",
|
city: "HCMC",
|
||||||
postalCode: "700000",
|
postalCode: "700000",
|
||||||
@@ -80,6 +83,20 @@ const getTabIndex = (tab?: string): number => {
|
|||||||
|
|
||||||
const AccountPage = ({ defaultActiveContent="orders" } : AccountPageProps) => {
|
const AccountPage = ({ defaultActiveContent="orders" } : AccountPageProps) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
const {userInfo} = useUserInfo();
|
||||||
|
|
||||||
|
// const email = userInfo?.emailAddress;
|
||||||
|
// const [info] = userInfo?.addresses || [];
|
||||||
|
|
||||||
|
// const accountInfo = {...info,userInfo?.emailAddress};
|
||||||
|
|
||||||
|
// const clone:AccountProps = Object.create(accountInfo);
|
||||||
|
// Object.assign(clone, accountInfo);
|
||||||
|
|
||||||
|
|
||||||
|
console.log();
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState(defaultActiveContent==="info" ? 0 : defaultActiveContent==="orders" ? 1 : 2)
|
const [activeTab, setActiveTab] = useState(defaultActiveContent==="info" ? 0 : defaultActiveContent==="orders" ? 1 : 2)
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
|
|
||||||
|
@@ -7,14 +7,14 @@ import avatar from '../../assets/avatar.png'
|
|||||||
import { ButtonCommon } from 'src/components/common'
|
import { ButtonCommon } from 'src/components/common'
|
||||||
import { useActiveCustomer } from 'src/components/hooks/auth'
|
import { useActiveCustomer } from 'src/components/hooks/auth'
|
||||||
|
|
||||||
interface AccountProps {
|
export interface AccountProps {
|
||||||
name: string
|
name?: string
|
||||||
email: string
|
email?: string
|
||||||
address: string
|
address?: string
|
||||||
state: string
|
state?: string
|
||||||
city: string
|
city?: string
|
||||||
postalCode: string
|
postalCode?: string
|
||||||
phoneNumber: string
|
phoneNumber?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AccountInfomationProps {
|
interface AccountInfomationProps {
|
||||||
|
@@ -4,7 +4,7 @@ import s from './EditInfoModal.module.scss'
|
|||||||
import { ModalCommon, Inputcommon, SelectCommon, ButtonCommon } from '../../../../../common'
|
import { ModalCommon, Inputcommon, SelectCommon, ButtonCommon } from '../../../../../common'
|
||||||
|
|
||||||
interface EditInfoModalProps {
|
interface EditInfoModalProps {
|
||||||
accountInfo: {name: string, email: string, address: string, state: string, city: string, postalCode: string, phoneNumber: string};
|
accountInfo: {firstName: string,lastName: string, email: string, address: string, state: string, city: string, postalCode: string, phoneNumber: string};
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
closeModal: () => void;
|
closeModal: () => void;
|
||||||
}
|
}
|
||||||
@@ -25,12 +25,11 @@ const EditInfoModal = ({ accountInfo, visible = false, closeModal }: EditInfoMod
|
|||||||
<ModalCommon onClose={closeModal} visible={visible} title="Edit Infomation">
|
<ModalCommon onClose={closeModal} visible={visible} title="Edit Infomation">
|
||||||
<section className={s.editInfoModal}>
|
<section className={s.editInfoModal}>
|
||||||
<div className={s.input}>
|
<div className={s.input}>
|
||||||
<Inputcommon placeholder="Name" value={accountInfo.name} type="text" />
|
<Inputcommon placeholder="Name" value={accountInfo.firstName} type="text" />
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={s.inputDisable}>
|
|
||||||
<Inputcommon placeholder="Email" value={accountInfo.email} type="email" />
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className={s.input}>
|
||||||
|
<Inputcommon placeholder="Name" value={accountInfo.lastName} type="text" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className={s.input}>
|
<div className={s.input}>
|
||||||
<Inputcommon placeholder="Address" value={accountInfo.address} type="text" />
|
<Inputcommon placeholder="Address" value={accountInfo.address} type="text" />
|
||||||
|
Reference in New Issue
Block a user