This commit is contained in:
@@ -44,7 +44,7 @@ export default () => {
|
|||||||
if (data.valid)
|
if (data.valid)
|
||||||
setUser (toCamel (data.user, { deep: true }))
|
setUser (toCamel (data.user, { deep: true }))
|
||||||
else
|
else
|
||||||
createUser ()
|
await createUser ()
|
||||||
}) ()
|
}) ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -143,10 +143,14 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
|||||||
<MyLink to="/posts" title="広場" />
|
<MyLink to="/posts" title="広場" />
|
||||||
<MyLink to="/tags" title="タグ" />
|
<MyLink to="/tags" title="タグ" />
|
||||||
<MyLink to="/wiki/ヘルプ:ホーム" base="/wiki" title="Wiki" />
|
<MyLink to="/wiki/ヘルプ:ホーム" base="/wiki" title="Wiki" />
|
||||||
<MyLink to="/users" title="ニジラー" />
|
<MyLink to="/users/settings" base="/users" title="ニジラー" />
|
||||||
</div>
|
</div>
|
||||||
<div className="ml-auto pr-4">
|
<div className="ml-auto pr-4">
|
||||||
<Button onClick={() => navigate ('/users/settings')}>{user?.name || '名もなきニジラー'}</Button>
|
{user && (
|
||||||
|
<Button onClick={() => navigate ('/users/settings')}
|
||||||
|
className="bg-gray-600">
|
||||||
|
{user.name || '名もなきニジラー'}
|
||||||
|
</Button>)}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
{(() => {
|
{(() => {
|
||||||
@@ -166,14 +170,15 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
|||||||
case Menu.Tag:
|
case Menu.Tag:
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<input type="text"
|
{/* TODO: リリース後にやる */}
|
||||||
|
{/* <input type="text"
|
||||||
className={inputBox}
|
className={inputBox}
|
||||||
placeholder="タグ検索"
|
placeholder="タグ検索"
|
||||||
value={tagSearch}
|
value={tagSearch}
|
||||||
onChange={whenTagSearchChanged}
|
onChange={whenTagSearchChanged}
|
||||||
onFocus={() => setSuggestionsVsbl (true)}
|
onFocus={() => setSuggestionsVsbl (true)}
|
||||||
onBlur={() => setSuggestionsVsbl (false)}
|
onBlur={() => setSuggestionsVsbl (false)}
|
||||||
onKeyDown={handleKeyDown} />
|
onKeyDown={handleKeyDown} /> */}
|
||||||
<Link to="/tags" className={subClass}>タグ</Link>
|
<Link to="/tags" className={subClass}>タグ</Link>
|
||||||
<Link to="/tags/aliases" className={subClass}>別名タグ</Link>
|
<Link to="/tags/aliases" className={subClass}>別名タグ</Link>
|
||||||
<Link to="/tags/implications" className={subClass}>上位タグ</Link>
|
<Link to="/tags/implications" className={subClass}>上位タグ</Link>
|
||||||
@@ -183,14 +188,15 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
|||||||
case Menu.Wiki:
|
case Menu.Wiki:
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<input type="text"
|
{/* TODO: リリース後にやる */}
|
||||||
|
{/* <input type="text"
|
||||||
className={inputBox}
|
className={inputBox}
|
||||||
placeholder="Wiki 検索"
|
placeholder="Wiki 検索"
|
||||||
value={wikiSearch}
|
value={wikiSearch}
|
||||||
onChange={whenWikiSearchChanged}
|
onChange={whenWikiSearchChanged}
|
||||||
onFocus={() => setSuggestionsVsbl (true)}
|
onFocus={() => setSuggestionsVsbl (true)}
|
||||||
onBlur={() => setSuggestionsVsbl (false)}
|
onBlur={() => setSuggestionsVsbl (false)}
|
||||||
onKeyDown={handleKeyDown} />
|
onKeyDown={handleKeyDown} /> */}
|
||||||
<Link to="/wiki" className={subClass}>検索</Link>
|
<Link to="/wiki" className={subClass}>検索</Link>
|
||||||
<Link to="/wiki/new" className={subClass}>新規</Link>
|
<Link to="/wiki/new" className={subClass}>新規</Link>
|
||||||
<Link to="/wiki/changes" className={subClass}>全体履歴</Link>
|
<Link to="/wiki/changes" className={subClass}>全体履歴</Link>
|
||||||
@@ -206,16 +212,18 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
|||||||
case Menu.User:
|
case Menu.User:
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
<input type="text"
|
{/* TODO: リリース後にやる */}
|
||||||
|
{/* <input type="text"
|
||||||
className={inputBox}
|
className={inputBox}
|
||||||
placeholder="ニジラー検索"
|
placeholder="ニジラー検索"
|
||||||
value={userSearch}
|
value={userSearch}
|
||||||
onChange={whenUserSearchChanged}
|
onChange={whenUserSearchChanged}
|
||||||
onFocus={() => setSuggestionsVsbl (true)}
|
onFocus={() => setSuggestionsVsbl (true)}
|
||||||
onBlur={() => setSuggestionsVsbl (false)}
|
onBlur={() => setSuggestionsVsbl (false)}
|
||||||
onKeyDown={handleKeyDown} />
|
onKeyDown={handleKeyDown} /> */}
|
||||||
<Link to="/users" className={subClass}>一覧</Link>
|
{/* <Link to="/users" className={subClass}>一覧</Link>
|
||||||
{user && <Link to={`/users/${ user.id }`} className={subClass}>お前</Link>}
|
{user && <Link to={`/users/${ user.id }`} className={subClass}>お前</Link>} */}
|
||||||
|
{user && <Link to="/users/settings" className={subClass}>設定</Link>}
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
||||||
}) ()}
|
}) ()}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type Props = { visible: boolean
|
|||||||
|
|
||||||
export default ({ visible, onVisibleChange, user, setUser }: Props) => {
|
export default ({ visible, onVisibleChange, user, setUser }: Props) => {
|
||||||
const handleChange = async () => {
|
const handleChange = async () => {
|
||||||
if (!(confirm ('引継ぎコードを再発行しますか?')))
|
if (!(confirm ('引継ぎコードを再発行しますか?\n再発行するとほかのブラウザからはログアウトされます.')))
|
||||||
return
|
return
|
||||||
|
|
||||||
const { data } = await axios.post (`${ API_BASE_URL }/users/code/renew`, { }, { headers: {
|
const { data } = await axios.post (`${ API_BASE_URL }/users/code/renew`, { }, { headers: {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import toCamel from 'camelcase-keys'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { Helmet } from 'react-helmet-async'
|
import { Helmet } from 'react-helmet-async'
|
||||||
|
|
||||||
@@ -7,8 +9,9 @@ import PageTitle from '@/components/common/PageTitle'
|
|||||||
import MainArea from '@/components/layout/MainArea'
|
import MainArea from '@/components/layout/MainArea'
|
||||||
import InheritDialogue from '@/components/users/InheritDialogue'
|
import InheritDialogue from '@/components/users/InheritDialogue'
|
||||||
import UserCodeDialogue from '@/components/users/UserCodeDialogue'
|
import UserCodeDialogue from '@/components/users/UserCodeDialogue'
|
||||||
import { API_BASE_URL, SITE_TITLE } from '@/config'
|
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { toast } from '@/components/ui/use-toast'
|
||||||
|
import { API_BASE_URL, SITE_TITLE } from '@/config'
|
||||||
|
|
||||||
import type { User } from '@/types'
|
import type { User } from '@/types'
|
||||||
|
|
||||||
@@ -22,14 +25,18 @@ export default ({ user, setUser }: Props) => {
|
|||||||
const [inheritVsbl, setInheritVsbl] = useState (false)
|
const [inheritVsbl, setInheritVsbl] = useState (false)
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
const formData = new FormData ()
|
if (!(user))
|
||||||
|
return
|
||||||
|
|
||||||
|
const formData = new FormData
|
||||||
formData.append ('name', name)
|
formData.append ('name', name)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await axios.post (`${ API_BASE_URL }/users`, formData, { headers: {
|
const { data } = await axios.put (`${ API_BASE_URL }/users/${ user.id }`, formData, {
|
||||||
'Content-Type': 'multipart/form-data',
|
headers: { 'Content-Type': 'multipart/form-data',
|
||||||
'X-Transfer-Code': localStorage.getItem ('user_code') || '' } })
|
'X-Transfer-Code': localStorage.getItem ('user_code') || '' } })
|
||||||
|
setUser (user => ({ ...user, ...data }))
|
||||||
toast ({ title: '設定を更新しました.' })
|
toast ({ title: '設定を更新しました.' })
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
Reference in New Issue
Block a user