generated from Code-4-Community/frontend-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first draft * save button and sub form * working but need to reskin * formatting * centered the div boss * add template testing, route url slash * Update maps.json conflict * curly bracket
- Loading branch information
1 parent
8c7383b
commit 9f879f5
Showing
30 changed files
with
215 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { Input, Button, Typography, message } from 'antd'; | ||
import { SaveTwoTone } from '@ant-design/icons'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { site } from '../../constants'; | ||
import { n } from '../../utils/stringFormat'; | ||
import { AddTemplateRequest } from '../forms/ducks/types'; | ||
import ProtectedApiClient from '../../api/protectedApiClient'; | ||
import { LIGHT_GREEN } from '../../utils/colors'; | ||
import DOMPurify from 'isomorphic-dompurify'; | ||
|
||
const SaveMenuContainer = styled.div` | ||
display: flex; | ||
max-width: 400px; | ||
height: 40px; | ||
gap: 2px; | ||
align-self: end; | ||
`; | ||
|
||
const SaveButton = styled(Button)` | ||
width: 40px; | ||
height: 40px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
&:hover { | ||
background-color: #e7ffc7; | ||
} | ||
`; | ||
|
||
const NameInput = styled(Input)` | ||
height: 40px; | ||
`; | ||
|
||
const LargeSaveTwoTone = styled(SaveTwoTone)` | ||
font-size: 20px; | ||
`; | ||
|
||
interface SaveMenuProps { | ||
templateBody: string; | ||
} | ||
|
||
const SaveMenu: React.FC<SaveMenuProps> = ({ templateBody }) => { | ||
const { t } = useTranslation(n(site, ['forms']), { | ||
keyPrefix: 'volunteer_emailer', | ||
nsMode: 'fallback', | ||
}); | ||
|
||
const [templateName, setTemplateName] = useState(``); | ||
|
||
const onClickSave = (name: string, template: string) => { | ||
if (name.length === 0) { | ||
message.error(t('name_required')); | ||
return; | ||
} | ||
template = DOMPurify.sanitize(template); | ||
const addTemplateRequest: AddTemplateRequest = { | ||
name, | ||
template, | ||
}; | ||
ProtectedApiClient.addTemplate(addTemplateRequest) | ||
.then(() => { | ||
message.success(t('save_success')); | ||
}) | ||
.catch((err) => | ||
message.error(t('response_error', { error: err.response.data })), | ||
); | ||
}; | ||
return ( | ||
<SaveMenuContainer> | ||
<NameInput | ||
defaultValue={templateName} | ||
value={templateName} | ||
onChange={(e) => setTemplateName(e.target.value)} | ||
placeholder={t('name_template')} | ||
/> | ||
<SaveButton onClick={() => onClickSave(templateName, templateBody)}> | ||
<LargeSaveTwoTone twoToneColor={LIGHT_GREEN} /> | ||
</SaveButton> | ||
</SaveMenuContainer> | ||
); | ||
}; | ||
|
||
export default SaveMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ | |
"privateStreet": "Private streets that volunteers shouldn't enter!" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ | |
"standard": "Estándar", | ||
"super_admin": "Superadministrador" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
"nov": "Noviembre", | ||
"dec": "Diciembre" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
"settings": "Ajustes", | ||
"reports": "Informes" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"questionDirections": { | ||
"questions": "¿Todavía tienes preguntas?", | ||
"directions": [ | ||
"Visita nuestra página de preguntas frecuentes en <faqLink>FAQ</faqLink> para ver si tu pregunta está respondida.", | ||
"Visita nuestra página de preguntas frecuentes en <faqLink>FAQ</faqLink> para ver si tu pregunta está respondida.", | ||
"Si no, contáctanos en <contactUsLink>[email protected]</contactUsLink>." | ||
] | ||
} | ||
|
@@ -23,18 +23,18 @@ | |
"adoptionDirections": { | ||
"header": "Cómo Adoptar un Árbol", | ||
"body": [ | ||
"Haz clic en 'Registrarse' en la esquina superior derecha para crear una cuenta.", | ||
"Una vez que hayas iniciado sesión, ingresa tu dirección en la barra de búsqueda del mapa para encontrar árboles adoptables cerca de ti.", | ||
"Haz clic en el ícono del árbol que te gustaría adoptar, ya sea el triángulo azul para un árbol recién plantado o el círculo verde para un árbol más antiguo.", | ||
"Haz clic en 'Más información'.", | ||
"Haz clic en el botón 'Adoptar' en la siguiente pantalla para adoptar ese árbol. Se agregará a la lista 'Mis Árboles' para que puedas encontrar fácilmente tu árbol y registrar tus actividades de cuidado.", | ||
"Haz clic en 'Registrarse' en la esquina superior derecha para crear una cuenta.", | ||
"Una vez que hayas iniciado sesión, ingresa tu dirección en la barra de búsqueda del mapa para encontrar árboles adoptables cerca de ti.", | ||
"Haz clic en el ícono del árbol que te gustaría adoptar, ya sea el triángulo azul para un árbol recién plantado o el círculo verde para un árbol más antiguo.", | ||
"Haz clic en 'Más información'.", | ||
"Haz clic en el botón 'Adoptar' en la siguiente pantalla para adoptar ese árbol. Se agregará a la lista 'Mis Árboles' para que puedas encontrar fácilmente tu árbol y registrar tus actividades de cuidado.", | ||
"Registra cada actividad haciendo clic en 'Mis Árboles', encuentra el árbol que adoptaste y envía la actividad de cuidado en la página de ese árbol. ¡Es fácil!" | ||
] | ||
}, | ||
}, | ||
"navMenu": { | ||
"myTrees": "Mis Árboles", | ||
"admins": "Administradores", | ||
"accountSettings": "Configuración de la Cuenta", | ||
"logOut": "Cerrar Sesión" | ||
} | ||
} | ||
} |
Oops, something went wrong.