File tree Expand file tree Collapse file tree 8 files changed +102
-11
lines changed Expand file tree Collapse file tree 8 files changed +102
-11
lines changed Original file line number Diff line number Diff line change 1
- REACT_APP_API_HOST = http://localhost:5000 /
1
+ REACT_APP_API_HOST = http://localhost:5001 /
2
2
PUBLIC_URL = /
3
3
REACT_APP_GRAPHQL_HOST = https://v2cdn.velog.io/
4
4
REACT_APP_GRAPHQL_HOST_NOCDN = https://v2.velog.io/
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ const AuthSocialButton: React.FC<AuthSocialButtonProps> = ({
62
62
const host =
63
63
process . env . NODE_ENV === 'production'
64
64
? process . env . REACT_APP_API_HOST
65
- : 'http://localhost:5000 /' ;
65
+ : 'http://localhost:5001 /' ;
66
66
67
67
const redirectTo = `${ host } api/v2/auth/social/redirect/${ provider } ?next=${ currentPath } &isIntegrate=${
68
68
isIntegrate ? 1 : 0
Original file line number Diff line number Diff line change
1
+ import React , { useState } from 'react' ;
2
+ import SettingRow from './SettingRow' ;
3
+ import useInput from '../../lib/hooks/useInput' ;
4
+ import SettingInput from './SettingInput' ;
5
+ import styled from 'styled-components' ;
6
+ import Button from '../common/Button' ;
7
+
8
+ export type SettingEmailRowProps = {
9
+ email : string ;
10
+ onUpdateEmail : ( email : string ) => Promise < void > ;
11
+ } ;
12
+
13
+ function SettingEmailRow ( { email, onUpdateEmail } : SettingEmailRowProps ) {
14
+ const [ edit , setEdit ] = useState ( false ) ;
15
+ const [ value , onChange ] = useInput ( email ) ;
16
+
17
+ const onSubmit = async ( e : React . FormEvent ) => {
18
+ e . preventDefault ( ) ;
19
+ await onUpdateEmail ( value ) ;
20
+ setEdit ( false ) ;
21
+ } ;
22
+
23
+ return (
24
+ < SettingRow
25
+ title = "이메일 주소"
26
+ description = "회원 인증 또는 시스템에서 발송하는 이메일을 수신하는 주소입니다."
27
+ editButton = { ! edit }
28
+ onClickEdit = { ( ) => setEdit ( true ) }
29
+ editButtonText = "변경"
30
+ >
31
+ { edit ? (
32
+ < Form onSubmit = { onSubmit } >
33
+ < SettingInput
34
+ value = { value }
35
+ onChange = { onChange }
36
+ placeholder = "이메일"
37
+ />
38
+ < Button > 변경</ Button >
39
+ </ Form >
40
+ ) : (
41
+ email
42
+ ) }
43
+ </ SettingRow >
44
+ ) ;
45
+ }
46
+
47
+ const Form = styled . form `
48
+ display: flex;
49
+ align-items: center;
50
+ input {
51
+ flex: 1;
52
+ margin-right: 1rem;
53
+ }
54
+ ` ;
55
+
56
+ export default SettingEmailRow ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export type SettingRowProps = {
10
10
onClickEdit ?: ( ) => void ;
11
11
editButton ?: boolean ;
12
12
description ?: string ;
13
+ editButtonText ?: string ;
13
14
} ;
14
15
15
16
function SettingRow ( {
@@ -18,6 +19,7 @@ function SettingRow({
18
19
editButton,
19
20
description,
20
21
onClickEdit,
22
+ editButtonText,
21
23
} : SettingRowProps ) {
22
24
return (
23
25
< Row >
@@ -29,7 +31,10 @@ function SettingRow({
29
31
< div className = "contents" > { children } </ div >
30
32
{ editButton && (
31
33
< div className = "edit-wrapper" >
32
- < SettingEditButton onClick = { onClickEdit } />
34
+ < SettingEditButton
35
+ onClick = { onClickEdit }
36
+ customText = { editButtonText }
37
+ />
33
38
</ div >
34
39
) }
35
40
</ div >
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import styled from 'styled-components' ;
3
- import SettingRow from './SettingRow' ;
4
3
import SettingTitleRow from './SettingTitleRow' ;
5
4
import SettingSocialInfoRow from './SettingSocialInfoRow' ;
6
5
import SettingEmailRulesRow from './SettingEmailRulesRow' ;
7
6
import { createFallbackTitle } from '../../lib/utils' ;
8
7
import { ProfileLinks } from '../../lib/graphql/user' ;
9
8
import SettingUnregisterRow from './SettingUnregisterRow' ;
10
9
import media from '../../lib/styles/media' ;
10
+ import SettingEmailRow from './SettingEmailRow' ;
11
11
12
12
export type SettingRowsProps = {
13
13
title : string | null ;
14
14
username : string ;
15
15
email : string ;
16
16
onUpdateTitle : ( title : string ) => Promise < any > ;
17
+ onUpdateEmail : ( email : string ) => Promise < any > ;
17
18
onUpdateSocialInfo : ( profileLinks : ProfileLinks ) => Promise < any > ;
18
19
onUpdateEmailRules : ( params : {
19
20
promotion : boolean ;
@@ -41,6 +42,7 @@ function SettingRows({
41
42
userMeta,
42
43
email,
43
44
onUpdateTitle,
45
+ onUpdateEmail,
44
46
onUpdateSocialInfo,
45
47
onUpdateEmailRules,
46
48
onUnregister,
@@ -52,12 +54,7 @@ function SettingRows({
52
54
onUpdateTitle = { onUpdateTitle }
53
55
/>
54
56
< SettingSocialInfoRow { ...profileLinks } onUpdate = { onUpdateSocialInfo } />
55
- < SettingRow
56
- title = "이메일 주소"
57
- description = "회원 인증 또는 시스템에서 발송하는 이메일을 수신하는 주소입니다."
58
- >
59
- { email }
60
- </ SettingRow >
57
+ < SettingEmailRow email = { email } onUpdateEmail = { onUpdateEmail } />
61
58
{ userMeta && (
62
59
< SettingEmailRulesRow
63
60
notification = { userMeta . email_notification }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import useUserProfile from './hooks/useUserProfile';
7
7
import useUpdateSocialInfo from './hooks/useUpdateSocialInfo' ;
8
8
import useUpdateEmailRules from './hooks/useUpdateEmailRules' ;
9
9
import useUnregister from './hooks/useUnregister' ;
10
+ import useUpdateEmail from './hooks/useUpdateEmail' ;
10
11
11
12
export type SettingRowsContainerProps = { } ;
12
13
@@ -16,6 +17,7 @@ function SettingRowsContainer(props: SettingRowsContainerProps) {
16
17
const user = useSelector ( ( state : RootState ) => state . core . user ) ;
17
18
const updateSocialInfo = useUpdateSocialInfo ( ) ;
18
19
const { update : updateEmailRules } = useUpdateEmailRules ( ) ;
20
+ const { update : updateEmail } = useUpdateEmail ( ) ;
19
21
const unregister = useUnregister ( ) ;
20
22
21
23
const onUpdateEmailRules = useCallback (
@@ -42,6 +44,7 @@ function SettingRowsContainer(props: SettingRowsContainerProps) {
42
44
username = { user . username }
43
45
email = { user . email }
44
46
onUpdateTitle = { updateTitle }
47
+ onUpdateEmail = { updateEmail }
45
48
profileLinks = { profile . profile_links }
46
49
onUpdateSocialInfo = { updateSocialInfo . update }
47
50
onUpdateEmailRules = { onUpdateEmailRules }
Original file line number Diff line number Diff line change
1
+ import { useMutation } from '@apollo/react-hooks' ;
2
+ import gql from 'graphql-tag' ;
3
+ import { useCallback } from 'react' ;
4
+
5
+ const UPDATE_USER_EMAIL = gql `
6
+ mutation UpdateUserEmail($email: String!) {
7
+ update_user_email(email: $email) {
8
+ email
9
+ }
10
+ }
11
+ ` ;
12
+
13
+ export default function useUpdateEmail ( ) {
14
+ const [ updateUserEmail ] = useMutation ( UPDATE_USER_EMAIL ) ;
15
+
16
+ const update = useCallback (
17
+ ( email : string ) => {
18
+ return updateUserEmail ( {
19
+ variables : {
20
+ email,
21
+ } ,
22
+ } ) ;
23
+ } ,
24
+ [ updateUserEmail ] ,
25
+ ) ;
26
+
27
+ return {
28
+ update,
29
+ } ;
30
+ }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ app.use(
17
17
) ;
18
18
19
19
const proxyMiddleware = proxy (
20
- process . env . REACT_APP_API_HOST ?? 'http://localhost:5000 ' ,
20
+ process . env . REACT_APP_API_HOST ?? 'http://localhost:5001 ' ,
21
21
{ } ,
22
22
) ;
23
23
You can’t perform that action at this time.
0 commit comments