Skip to content

Commit 708840c

Browse files
committed
feat: add localExpireAt state to AccessSettingsCard for dynamic expiration date handling
1 parent c53da2d commit 708840c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/shared/ui/forms/users/forms-components/access-settings-card.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const AccessSettingsCard = <T extends CreateUserCommand.Request | UpdateU
3333
const { cardVariants, motionWrapper, form, internalSquads, externalSquads } = props
3434

3535
const [searchQuery, setSearchQuery] = useState('')
36+
const [localExpireAt, setLocalExpireAt] = useState<Date | undefined>(undefined)
3637

3738
const MotionWrapper = motionWrapper
3839

@@ -46,6 +47,10 @@ export const AccessSettingsCard = <T extends CreateUserCommand.Request | UpdateU
4647
)
4748
}, [internalSquads, searchQuery])
4849

50+
form.watch('expireAt', (value) => {
51+
setLocalExpireAt(value.value)
52+
})
53+
4954
return (
5055
<MotionWrapper variants={cardVariants}>
5156
<Fieldset
@@ -129,15 +134,21 @@ export const AccessSettingsCard = <T extends CreateUserCommand.Request | UpdateU
129134
}}
130135
presets={[
131136
{
132-
value: dayjs().add(1, 'month').format('YYYY-MM-DD HH:mm:ss'),
137+
value: dayjs(localExpireAt)
138+
.add(1, 'month')
139+
.format('YYYY-MM-DD HH:mm:ss'),
133140
label: t('create-user-modal.widget.1-month')
134141
},
135142
{
136-
value: dayjs().add(3, 'months').format('YYYY-MM-DD HH:mm:ss'),
143+
value: dayjs(localExpireAt)
144+
.add(3, 'months')
145+
.format('YYYY-MM-DD HH:mm:ss'),
137146
label: t('create-user-modal.widget.3-months')
138147
},
139148
{
140-
value: dayjs().add(1, 'year').format('YYYY-MM-DD HH:mm:ss'),
149+
value: dayjs(localExpireAt)
150+
.add(1, 'year')
151+
.format('YYYY-MM-DD HH:mm:ss'),
141152
label: t('create-user-modal.widget.1-year')
142153
},
143154
{

0 commit comments

Comments
 (0)