feat: add group recipe sharing and translation
This commit is contained in:
+8
-4
@@ -8,6 +8,7 @@ const detail = document.querySelector('#recipe-detail');
|
||||
const toast = document.querySelector('#toast');
|
||||
const scrollToTop = document.querySelector('#scroll-to-top');
|
||||
let currentRecipe = null;
|
||||
let currentUser = null;
|
||||
let toastTimer;
|
||||
|
||||
bindScrollToTop(scrollToTop);
|
||||
@@ -166,6 +167,7 @@ function renderRecipeEditor(recipe) {
|
||||
function renderRecipe(recipe) {
|
||||
document.title = `${recipe.title} · Our Recipe Atlas`;
|
||||
const image = recipe.imagePath ? `/media/${recipe.imagePath}` : null;
|
||||
const canEdit = recipe.ownerGoogleSub === currentUser.googleSub;
|
||||
detail.innerHTML = `
|
||||
<a class="back-link" href="/">← Recipe Library</a>
|
||||
<article class="recipe-detail">
|
||||
@@ -177,7 +179,7 @@ function renderRecipe(recipe) {
|
||||
${recipe.summary ? `<p>${escapeHtml(recipe.summary)}</p>` : ''}
|
||||
${recipe.servings ? `<p class="servings">분량 · ${escapeHtml(recipe.servings)}</p>` : ''}
|
||||
<div class="detail-actions">
|
||||
<button id="edit-recipe" class="button button-primary" type="button">레시피 수정</button>
|
||||
${canEdit ? '<button id="edit-recipe" class="button button-primary" type="button">레시피 수정</button>' : ''}
|
||||
<a class="button button-secondary" href="${escapeHtml(recipe.source.url)}" target="_blank" rel="noreferrer">원본 보기 ↗</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -205,12 +207,13 @@ function renderRecipe(recipe) {
|
||||
</div>
|
||||
<footer class="detail-footer">
|
||||
<div>${recipe.tags.map((tag) => `<span class="tag">#${escapeHtml(tag)}</span>`).join('')}</div>
|
||||
<button id="delete-recipe" class="button button-danger" type="button">레시피 삭제</button>
|
||||
${canEdit ? '<button id="delete-recipe" class="button button-danger" type="button">레시피 삭제</button>' : ''}
|
||||
</footer>
|
||||
</article>`;
|
||||
|
||||
document.querySelector('#edit-recipe').addEventListener('click', () => renderRecipeEditor(recipe));
|
||||
if (!canEdit) return;
|
||||
|
||||
document.querySelector('#edit-recipe').addEventListener('click', () => renderRecipeEditor(recipe));
|
||||
document.querySelector('#delete-recipe').addEventListener('click', async () => {
|
||||
if (!window.confirm(`'${recipe.title}' 레시피를 삭제할까요?`)) return;
|
||||
try {
|
||||
@@ -223,7 +226,8 @@ function renderRecipe(recipe) {
|
||||
}
|
||||
|
||||
bindLogout();
|
||||
appBar.setUser(await loadSession());
|
||||
currentUser = await loadSession();
|
||||
appBar.setUser(currentUser);
|
||||
|
||||
try {
|
||||
const recipeId = decodeURIComponent(window.location.pathname.split('/').filter(Boolean).pop());
|
||||
|
||||
Reference in New Issue
Block a user