From f6c0bb66fe5e0f2278cfd8d4981719432e513845 Mon Sep 17 00:00:00 2001 From: takecchi Date: Sun, 10 Dec 2023 14:57:48 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E5=90=8D=E3=81=A8=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=B4=B9=E4=BB=8B=E6=96=87=E3=82=92=E7=B7=A8=E9=9B=86?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layouts/ProfileSettingModal.tsx | 99 ++++++++++++++++--- 1 file changed, 85 insertions(+), 14 deletions(-) diff --git a/src/app/(menu)/(public)/[username]/_components/layouts/ProfileSettingModal.tsx b/src/app/(menu)/(public)/[username]/_components/layouts/ProfileSettingModal.tsx index adff1c126..1aecd5fff 100644 --- a/src/app/(menu)/(public)/[username]/_components/layouts/ProfileSettingModal.tsx +++ b/src/app/(menu)/(public)/[username]/_components/layouts/ProfileSettingModal.tsx @@ -1,6 +1,12 @@ 'use client'; -import { Box, Dialog as MuiDialog, Slider, styled } from '@mui/material'; +import { + Box, + Dialog as MuiDialog, + Slider, + styled, + TextField, +} from '@mui/material'; import { ChangeEvent, useCallback, useState } from 'react'; import { AddAPhoto, @@ -92,6 +98,17 @@ const HFlex = styled(Flex)` flex-direction: row; `; +const VFlex = styled(Flex)` + flex-direction: column; +`; + +/** + * アイコンを編集するモーダル + * @param src + * @param onClose + * @param onComplete + * @constructor + */ function ProfileImageCrop({ src, onClose, @@ -104,17 +121,21 @@ function ProfileImageCrop({ const [crop, setCrop] = useState({ x: 0, y: 0 }); const [zoom, setZoom] = useState(1); const [croppedAreaPixels, setCroppedAreaPixels] = useState(); + const [isProcessing, setIsProcessing] = useState(false); - const handleSave = useCallback(async () => { + // 適用処理 + const handleApply = useCallback(async () => { if (!croppedAreaPixels || !src) return; - + setIsProcessing(true); try { const croppedImage = await getCroppedImg(src, croppedAreaPixels, 400); onComplete(croppedImage); } catch (e) { console.error(e); + } finally { + setIsProcessing(false); } - }, [croppedAreaPixels]); + }, [croppedAreaPixels, onComplete, src]); return ( @@ -127,13 +148,13 @@ function ProfileImageCrop({
{ - // FIXME 可能ならここは非同期で投げっぱなしではなく、ちゃんと処理を待機させたい - void handleSave(); + void handleApply(); }} > - 保存 + 適用 @@ -175,12 +196,27 @@ function ProfileImageCrop({ ); } -export default function ProfileSettingModal({ open: init }: { open: boolean }) { - const [open, setOpen] = useState(init); +/** + * プロフィールを編集するモーダル + * @param init + * @constructor + */ +export default function ProfileSettingModal({ + open: initOpen, + src: initSrc, + displayName: initDisplayName, + bio: initBio, +}: { + open: boolean; + src?: string; + displayName: string; + bio: string; +}) { + const [open, setOpen] = useState(initOpen); + const [src, setSrc] = useState(initSrc); + const [displayName, setDisplayName] = useState(initDisplayName); + const [bio, setBio] = useState(initBio); - const [src, setSrc] = useState( - 'https://media.develop.cuculus.jp/profile_images/d691e7ec-5622-42a1-92c6-1f89bff87acd.png', - ); const [iconSrc, setIconSrc] = useState(undefined); function handleClose() { @@ -218,12 +254,21 @@ export default function ProfileSettingModal({ open: init }: { open: boolean }) { プロフィールを編集 +
+ { + // TODO 保存処理 + }} + > + 保存 +
- {/* TODO アイコン */} + + { + setDisplayName(event.target.value); + }} + /> + { + setBio(event.target.value); + }} + /> +