Skip to content

Commit

Permalink
feat(advertisement): add Checkbox to the UI to allow creating an sp…
Browse files Browse the repository at this point in the history
…onsored content
  • Loading branch information
Rafatcb committed Jul 16, 2024
1 parent 054f47c commit 00568b8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pages/interface/components/Content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
BranchName,
Button,
ButtonWithLoader,
Checkbox,
Editor,
Flash,
FormControl,
Expand Down Expand Up @@ -270,6 +271,7 @@ function EditMode({ contentObject, setContentObject, setComponentMode, localStor
title: contentObject?.title || '',
body: contentObject?.body || '',
source_url: contentObject?.source_url || '',
isSponsoredContent: contentObject?.type === 'ad',
});
const [titlePlaceholder, setTitlePlaceholder] = useState('');

Expand Down Expand Up @@ -343,6 +345,7 @@ function EditMode({ contentObject, setContentObject, setComponentMode, localStor
: `/api/v1/contents`;
const requestBody = {
status: 'published',
type: newData.isSponsoredContent ? 'ad' : 'content',
};

if (title || contentObject?.title) {
Expand Down Expand Up @@ -439,7 +442,8 @@ function EditMode({ contentObject, setContentObject, setComponentMode, localStor
(event) => {
setErrorObject(undefined);
setNewData((oldData) => {
const newData = { ...oldData, [event.target?.name || 'body']: event.target?.value ?? event };
const value = event.target?.name === 'isSponsoredContent' ? event.target.checked : event.target?.value ?? event;
const newData = { ...oldData, [event.target?.name || 'body']: value };
localStorage.setItem(localStorageKey, JSON.stringify(newData));
return newData;
});
Expand Down Expand Up @@ -557,6 +561,17 @@ function EditMode({ contentObject, setContentObject, setComponentMode, localStor
</FormControl>
)}

{!contentObject?.id && !contentObject?.parent_id && (
<FormControl>
<Checkbox name="isSponsoredContent" onChange={handleChange} checked={newData.isSponsoredContent} />
<FormControl.Label>Criar como publicação patrocinada.</FormControl.Label>

<FormControl.Caption>
Serão utilizados 100 TabCash para criar a publicação patrocinada.
</FormControl.Caption>
</FormControl>
)}

{!contentObject?.parent_id && (
<Text sx={{ fontSize: 1 }}>Os campos marcados com um asterisco (*) são obrigatórios.</Text>
)}
Expand Down

0 comments on commit 00568b8

Please sign in to comment.