movie-night-web/app/components/forms/create-list-form.vue

52 lines
1,015 B
Vue
Raw Normal View History

2026-02-16 19:12:00 -06:00
<script lang="ts" setup>
2026-02-24 00:30:07 -06:00
const emit = defineEmits(['refreshLists']);
const refreshLists = () => emit('refreshLists');
const listName = ref("");
2026-02-16 19:12:00 -06:00
2026-02-24 00:30:07 -06:00
const createList = () => {
$api('/api/movielists', {
body: {
name: listName.value,
},
method: "POST"
}).then(() => {
listName.value = "";
refreshLists();
}).catch((error) => {
if (error.response?.status === 401) {
useAuth().logout();
}
alert(error.message)
});
}
2026-02-16 19:12:00 -06:00
</script>
<template>
2026-02-24 00:30:07 -06:00
<form @submit.prevent="createList">
2026-02-16 19:12:00 -06:00
<label for="list_name">Add List</label>
<div>
2026-02-24 00:30:07 -06:00
<input v-model="listName"
name="list_name"
2026-02-16 19:12:00 -06:00
placeholder="List Name"
type="text">
<button>Add</button>
</div>
</form>
</template>
<style scoped>
button {
background-color: #4caf50;
color: white;
padding: .5rem 1rem;
border: none;
border-radius: 0 4px 4px 0;
}
input {
padding: .5rem;
border: 1px solid #ccc;
border-right: none;
border-radius: 4px 0 0 4px;
}
</style>