From 5b90f61b3b3bb374bee8f2433358af2f7fef8c3d Mon Sep 17 00:00:00 2001
From: Shotaro Nakamura <79000684+nakasyou@users.noreply.github.com>
Date: Sun, 1 Oct 2023 14:06:45 +0900
Subject: [PATCH] Update ManageSchools.tsx
---
islands/admin/components/ManageSchools.tsx | 41 +++++++++++++++++++---
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/islands/admin/components/ManageSchools.tsx b/islands/admin/components/ManageSchools.tsx
index 3ddb088..00d2e02 100644
--- a/islands/admin/components/ManageSchools.tsx
+++ b/islands/admin/components/ManageSchools.tsx
@@ -55,10 +55,43 @@ export default (props: Props) => {
{
schoolsData.map(schoolData => {
return
- { schoolData.schoolId } |
- { schoolData.schoolName } |
- |
- |
+ { schoolData.schoolId } |
+ { schoolData.schoolName }
+ | {
+ if (!confirm(`Do you want to edit '${schoolData.schoolName}' name?`)) return
+ const newName: string = prompt('What is new name?')
+ if (!confirm(`I'm going to rename ${newName}, Ok?`)) return
+
+ try {
+ await ky.post('/admin/api', {
+ json: {
+ type: 'rename_school',
+ schoolId: schoolData.schoolId,
+ newName,
+ }
+ })
+ alert('成功')
+ } catch (error) {
+ alert('エラーが発生しました。パスワードが間違っている可能性があります。')
+ alert(error)
+ throw error
+ }
+ }}>✏️ |
+ {
+ try {
+ await ky.post('/admin/api', {
+ json: {
+ type: 'remove_school',
+ password: props.password,
+ id: schoolData.schoolId
+ }
+ }).json()
+ } catch (error) {
+ alert('エラーが発生しました。パスワードが間違っている可能性があります。')
+ alert(error)
+ throw error
+ }
+ }}>🗑️ |
})
}