Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirm ship deletion #757

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/app/harbor/shipyard/edit-ship-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { deleteShip, updateShip } from './ship-utils'
import type { Ship } from '@/app/utils/data'
import { useToast } from '@/hooks/use-toast'
import Icon from '@hackclub/icons'
import { useState } from 'react'
import React, { useState } from 'react'
import Modal from '../../../components/ui/modal'

const editMessages = [
'Orpheus hopes you know that she put a lot of effort into recording your changes~',
Expand All @@ -27,6 +28,7 @@ export default function EditShipForm({
setShips: any
}) {
const [deleting, setDeleting] = useState(false)
const [openDeleteModal, setOpenDeleteModal] = useState(false)
const [saving, setSaving] = useState(false)
const allowDeletion = ship.shipStatus === 'staged'

Expand Down Expand Up @@ -194,14 +196,39 @@ export default function EditShipForm({
{allowDeletion && (
<Button
className={`${buttonVariants({ variant: 'destructive' })} ml-auto`}
onClick={handleDelete}
onClick={(e) => {
e.preventDefault()
setOpenDeleteModal(true)
}}
disabled={deleting}
>
{deleting ? <Icon glyph="more" /> : <Icon glyph="forbidden" />}
Delete Ship
</Button>
)}
</div>

<Modal isOpen={openDeleteModal} close={() => setOpenDeleteModal(false)}>
<div className="flex flex-col gap-3">
<p className="text-xl">
Are you sure you want to delete <b>{ship.title}</b>?
</p>
<div className="flex gap-1">
<Button
onClick={() => setOpenDeleteModal(false)}
className={`${buttonVariants({ variant: 'outline' })} flex-grow`}
>
NNONNO WAIT ヽ(O_O )ノ
</Button>
<Button
onClick={handleDelete}
className={`${buttonVariants({ variant: 'destructive' })}`}
>
Yes {'ദ്ദി(。•̀ ,<)~✩‧₊'}
</Button>
</div>
</div>
</Modal>
</form>
)
}
2 changes: 1 addition & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const buttonVariants = cva(
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'bg-[#ffffffaa] text-secondary-foreground border border-input bg-background hover:bg-accent hover:text-accent-foreground',
'!bg-transparent text-white border border-input bg-background hover:bg-accent hover:opacity-80',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
Expand Down
Loading