Skip to content

Commit

Permalink
feat: letterboxd data in edit tab
Browse files Browse the repository at this point in the history
  • Loading branch information
AQUASINE committed Apr 12, 2024
1 parent 023cc5a commit b9aa521
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "movie-tier-list",
"version": "1.1.10",
"version": "1.1.11",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 2 additions & 0 deletions src/SidebarComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ body {
width: 400px;
overflow: auto;
max-height: 100vh;
z-index: 1000;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
.addbutton {
Expand Down
18 changes: 17 additions & 1 deletion src/components/EditEntryTab.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import {mapState} from "vuex";
import {BASE_URL} from '../store/modules/letterboxd';
export default {
name: "EditEntryTab",
Expand All @@ -13,17 +14,29 @@ export default {
saveEntry() {
this.$store.dispatch('updateEntry', this.entry)
},
fetchLetterboxdData() {
if (!this.entry?.letterboxdId) {
return;
}
fetch(`${BASE_URL}/api/film/${this.entry.letterboxdId}`)
.then(response => response.json())
.then(data => {
this.letterboxdData = data;
})
}
},
data() {
return {
entry: null
entry: null,
letterboxdData: null
}
},
watch: {
selectedEntry: {
immediate: true,
handler(val) {
this.entry = JSON.parse(JSON.stringify(val));
this.fetchLetterboxdData();
}
}
}
Expand All @@ -50,6 +63,9 @@ export default {
<div v-else class="flex-1 mt-3">
Click on an entry to edit.
</div>
<div>
{{ letterboxdData }}
</div>
<button class="w-full addbutton pa-3 mt-2" @click="saveEntry" :class="{disable: !formValid}">Save</button>
</div>
</template>
Expand Down
13 changes: 13 additions & 0 deletions src/server/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ app.get('/api/search', async (req, res) => {
}
});

app.get('/api/film/:id', async (req, res) => {
console.log('GET /api/film/:id')
try {
const response = await axios.get(
`https://api.letterboxd.com/api/v0/film/${req.params.id}`
);
res.json(response.data);
} catch (error) {
console.error(error);
res.status(500).send('Internal Server Error');
}
});

app.get('/image_proxy', async (req, res) => {
if (!req.query.url) {
res.status(400).send('Bad Request');
Expand Down

0 comments on commit b9aa521

Please sign in to comment.