🐛(app-impress) fix all the resources were public

All the resources were public.
We now update correctly depend the user's choice.
We add a test.
This commit is contained in:
Anthony LC
2024-04-18 13:21:08 +02:00
committed by Anthony LC
parent 64cc2a9f2b
commit 82463be8ec
4 changed files with 37 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ export const CardCreatePad = () => {
},
});
const [padName, setPadName] = useState('');
const [padPublic, setPadPublic] = useState(false);
const { colorsTokens } = useCunninghamTheme();
return (
@@ -52,14 +53,18 @@ export const CardCreatePad = () => {
label={t('Pad name')}
{...{ error, isError, isPending, setPadName }}
/>
<Switch label={t('Is it public ?')} labelSide="right" />
<Switch
label={t('Is it public ?')}
labelSide="right"
onChange={() => setPadPublic(!padPublic)}
/>
</Box>
<Box $justify="space-between" $direction="row" $align="center">
<StyledLink href="/">
<Button color="secondary">{t('Cancel')}</Button>
</StyledLink>
<Button
onClick={() => createPad({ title: padName, is_public: true })}
onClick={() => createPad({ title: padName, is_public: padPublic })}
disabled={!padName}
>
{t('Create the pad')}

View File

@@ -25,6 +25,7 @@ export const CardCreateTemplate = () => {
},
});
const [templateName, setTemplateName] = useState('');
const [templatePublic, setTemplatePublic] = useState(false);
const { colorsTokens } = useCunninghamTheme();
return (
@@ -52,7 +53,11 @@ export const CardCreateTemplate = () => {
label={t('Template name')}
{...{ error, isError, isPending, setTemplateName }}
/>
<Switch label={t('Is it public ?')} labelSide="right" />
<Switch
label={t('Is it public ?')}
labelSide="right"
onChange={() => setTemplatePublic(!templatePublic)}
/>
</Box>
<Box $justify="space-between" $direction="row" $align="center">
<StyledLink href="/">
@@ -60,7 +65,7 @@ export const CardCreateTemplate = () => {
</StyledLink>
<Button
onClick={() =>
createTemplate({ title: templateName, is_public: true })
createTemplate({ title: templateName, is_public: templatePublic })
}
disabled={!templateName}
>