Skip to content

Commit

Permalink
Merge pull request #376 from reedu-reengineering-education/fix/mapsto…
Browse files Browse the repository at this point in the history
…ryOptionsDefaultValues

settings modal fix
  • Loading branch information
umut0 authored Mar 5, 2024
2 parents e99dadb + 5eed6af commit b864bd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/Studio/Mapstories/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export default function SettingsModal({
try {
const updatedStory = await updateStory({
...data,
// TODO: update again after zod schema change
visibility: data.visibility === true ? 'PUBLIC' : 'PRIVATE',
visibility: data.visibility,
})
toast({
message: t('settingsModal:changesApplied'),
Expand All @@ -93,7 +92,6 @@ export default function SettingsModal({
}
setModalOpen(false)
} catch (e) {
console.log(e)
return toast({
title: t('studio:somethingWrong'),
message: t('settingsModal:changesNotApplied'),
Expand Down Expand Up @@ -191,7 +189,7 @@ export default function SettingsModal({
<InputLabel>{t('settingsModal:visibility')}</InputLabel>
<Controller
control={control}
defaultValue={false}
defaultValue={story.visibility}
name="visibility"
// {...register('visibility')}
render={({ field: { onChange, value, ref } }) => {
Expand All @@ -202,7 +200,9 @@ export default function SettingsModal({
</span>
<Switch
defaultChecked={story.visibility === 'PUBLIC'}
onCheckedChange={onChange}
onCheckedChange={checked => onChange(
checked ? 'PUBLIC' : 'PRIVATE',
)}
ref={ref}
></Switch>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/validations/mapstory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const updateMapstorySchema = z.object({
description: z.string(),
author: z.string(),
mode: z.enum([StoryMode.NORMAL, StoryMode.TIMELINE]),
visibility: z.any(),
visibility: z.enum(['PRIVATE', 'PUBLIC']),
themeId: z.string().optional(),
lines: z.boolean(),
})

0 comments on commit b864bd0

Please sign in to comment.