Skip to content

Commit

Permalink
Update ManageSchools.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
nakasyou authored Oct 1, 2023
1 parent 2bdc500 commit 5b90f61
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions islands/admin/components/ManageSchools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,43 @@ export default (props: Props) => {
{
schoolsData.map(schoolData => {
return <tr>
<th>{ schoolData.schoolId }</th>
<th>{ schoolData.schoolName }</th>
<th></th>
<th></th>
<td>{ schoolData.schoolId }</td>
<th>{ schoolData.schoolName }</td>
<td onClick={async () => {
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
}
}}>✏️</td>
<td onClick={async () => {
try {
await ky.post('/admin/api', {
json: {
type: 'remove_school',
password: props.password,
id: schoolData.schoolId
}
}).json()
} catch (error) {
alert('エラーが発生しました。パスワードが間違っている可能性があります。')
alert(error)
throw error
}
}}>🗑️</td>
</tr>
})
}
Expand Down

0 comments on commit 5b90f61

Please sign in to comment.