Add isActive field to challenge chains and update localization; implement functionality to toggle chain status in the UI, enhancing task management and user experience.
This commit is contained in:
@@ -42,11 +42,13 @@ export const ChainFormPage: React.FC = () => {
|
||||
const [name, setName] = useState('')
|
||||
const [selectedTasks, setSelectedTasks] = useState<ChallengeTask[]>([])
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const [isActive, setIsActive] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
if (chain) {
|
||||
setName(chain.name)
|
||||
setSelectedTasks(chain.tasks)
|
||||
setIsActive(chain.isActive !== false)
|
||||
}
|
||||
}, [chain])
|
||||
|
||||
@@ -80,6 +82,7 @@ export const ChainFormPage: React.FC = () => {
|
||||
data: {
|
||||
name: name.trim(),
|
||||
taskIds: taskIds,
|
||||
isActive,
|
||||
},
|
||||
}).unwrap()
|
||||
toaster.create({
|
||||
@@ -91,6 +94,7 @@ export const ChainFormPage: React.FC = () => {
|
||||
await createChain({
|
||||
name: name.trim(),
|
||||
taskIds: taskIds,
|
||||
isActive,
|
||||
}).unwrap()
|
||||
toaster.create({
|
||||
title: t('challenge.admin.common.success'),
|
||||
@@ -191,6 +195,25 @@ export const ChainFormPage: React.FC = () => {
|
||||
/>
|
||||
</Field.Root>
|
||||
|
||||
{/* Active flag */}
|
||||
<Field.Root>
|
||||
<HStack justify="space-between" align="flex-start">
|
||||
<HStack gap={2}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={isActive}
|
||||
onChange={(e) => setIsActive(e.target.checked)}
|
||||
disabled={isLoading}
|
||||
style={{ cursor: isLoading ? 'not-allowed' : 'pointer' }}
|
||||
/>
|
||||
<Text>{t('challenge.admin.chains.field.isActive')}</Text>
|
||||
</HStack>
|
||||
<Text fontSize="sm" color="gray.500" maxW="md">
|
||||
{t('challenge.admin.chains.field.isActive.helper')}
|
||||
</Text>
|
||||
</HStack>
|
||||
</Field.Root>
|
||||
|
||||
{/* Selected Tasks */}
|
||||
<Box>
|
||||
<Text fontWeight="bold" mb={3}>
|
||||
|
||||
Reference in New Issue
Block a user