Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/menu template api integration #4

Merged
merged 11 commits into from
Feb 24, 2023
19 changes: 12 additions & 7 deletions src/api/services/MenuItemService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ export default class MenuItemService {
order
meta
parentId
children {
id
label
order
meta
parentId
}
template
templateFormat
menu {
id
name
meta
templateFormat
items {
id
label
order
meta
parentId
template
templateFormat
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/api/services/MenuService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ export default class MenuService {
id
name
meta
template
templateFormat
items {
id
label
order
meta
parentId
template
templateFormat
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/components/App/AppRoutes/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@ import NotFound from '../../../pages/NotFound';
import Layout from '../../Layout';

export const AppRoutes = () => {
const { initialized } = useKeycloak();
const { initialized, keycloak } = useKeycloak();

React.useEffect(() => {
if (!initialized || !keycloak) return;
if (!keycloak.authenticated) {
keycloak.onTokenExpired = undefined;
}
keycloak.onTokenExpired = () => {
keycloak.updateToken(5);
};
// Force refresh token
keycloak.updateToken(-1);
return () => {
if (keycloak) keycloak.onTokenExpired = undefined;
};
}, [initialized, keycloak, keycloak?.authenticated]);

const renderRoutes = () => {
if (!initialized) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeViewer/CodeViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CodeViewer = ({ code, language, lineNumbers = true }: Props) => {
}, [code]);
return (
<Box className="CodeViewer" sx={{ width: '100%', display: 'flex' }}>
<pre className={`${lineNumbers ? 'line-numbers' : ''} w-full flex-1`}>
<pre className={`${lineNumbers ? 'line-numbers' : ''} w-full flex-1`} style={{ margin: 0 }}>
<code className={`language-${language}`}>{code}</code>
</pre>
</Box>
Expand Down
11 changes: 11 additions & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"fields": {
"name": "Name",
"items": "Items",
"template": "Template",
"meta": {
"title_one": "Metadata",
"title_other": "Metadata",
Expand Down Expand Up @@ -201,6 +202,10 @@
"menuItem": {
"title_one": "Menu Item",
"title_other": "Menu Items",
"of": "Menu Item's $t(menu.fields.{{field}})",
"fields": {
"template": "Template"
},
"editTemplate": {
"title": "Edit Template",
"templateFormat": {
Expand Down Expand Up @@ -237,6 +242,12 @@
"result": {
"title": "Result",
"description": "This is the result of the template you defined:"
},
"actions": {
"title": "Actions",
"save": "Save Template",
"discard": "Discard Changes",
"useDefault": "Use Default Template"
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/i18n/locales/pt-BR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"fields": {
"name": "Nome",
"items": "Itens",
"template": "Template",
"meta": {
"title_one": "Metadado",
"title_other": "Metadados",
Expand Down Expand Up @@ -201,6 +202,10 @@
"menuItem": {
"title_one": "Item de Menu",
"title_other": "Itens de Menu",
"of": "$t(menu.fields.{{field}}) do Item de Menu",
"fields": {
"template": "Template"
},
"editTemplate": {
"title": "Editar Template",
"templateFormat": {
Expand Down Expand Up @@ -237,6 +242,12 @@
"result": {
"title": "Resultado",
"description": "Esse é o resultado do template que você definiu:"
},
"actions": {
"title": "Ações",
"save": "Salvar Template",
"discard": "Descartar Alterações",
"useDefault": "Usar Template Padrão"
}
}
}
Expand Down
Loading