categories,18popup,clear.TextEditorSwap,GameCardHover #177

Merged
freakoverse merged 64 commits from staging into master 2024-12-24 19:44:30 +00:00
2 changed files with 43 additions and 1 deletions
Showing only changes of commit 5877912cea - Show all commits

View File

@ -31,6 +31,7 @@ import { LoadingSpinner } from './LoadingSpinner'
import { NDKEvent } from '@nostr-dev-kit/ndk' import { NDKEvent } from '@nostr-dev-kit/ndk'
import { OriginalAuthor } from './OriginalAuthor' import { OriginalAuthor } from './OriginalAuthor'
import { CategoryAutocomplete } from './CategoryAutocomplete' import { CategoryAutocomplete } from './CategoryAutocomplete'
import { AlertPopup } from './AlertPopup'
interface FormErrors { interface FormErrors {
game?: string game?: string
@ -176,6 +177,27 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
[] []
) )
const [showConfirmPopup, setShowConfirmPopup] = useState<boolean>(false)
const handleReset = () => {
setShowConfirmPopup(true)
}
const handleResetConfirm = (confirm: boolean) => {
setShowConfirmPopup(false)
// Cancel if not confirmed
if (!confirm) return
// Editing
if (existingModData) {
// Reset fields to the original existing data
setFormState(initializeFormState(existingModData))
return
}
// New - set form state to the initial (clear form state)
setFormState(initializeFormState())
}
const handlePublish = async () => { const handlePublish = async () => {
setIsPublishing(true) setIsPublishing(true)
@ -563,6 +585,14 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
)} )}
</div> </div>
<div className='IBMSMSMBS_WriteAction'> <div className='IBMSMSMBS_WriteAction'>
<button
className='btn btnMain'
type='button'
onClick={handleReset}
disabled={isPublishing}
>
{existingModData ? 'Reset' : 'Clear fields'}
</button>
<button <button
className='btn btnMain' className='btn btnMain'
type='button' type='button'
@ -572,6 +602,18 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
Publish Publish
</button> </button>
</div> </div>
{showConfirmPopup && (
<AlertPopup
handleConfirm={handleResetConfirm}
handleClose={() => setShowConfirmPopup(false)}
header={'Are you sure?'}
label={
existingModData
? `Are you sure you want to clear all changes?`
: `Are you sure you want to clear all field data?`
}
/>
)}
</> </>
) )
} }

View File

@ -11,5 +11,5 @@
flex-direction: row; flex-direction: row;
justify-content: end; justify-content: end;
align-items: center; align-items: center;
gap: 25px;
} }