diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..ecea360
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,6 @@
+[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
+charset = utf-8
+indent_size = 2
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
diff --git a/.env b/.env
new file mode 100644
index 0000000..b0e8fc8
--- /dev/null
+++ b/.env
@@ -0,0 +1 @@
+VITE_API_URL=http://localhost:8000/api
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8ee54e8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,30 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+.DS_Store
+dist
+dist-ssr
+coverage
+*.local
+
+/cypress/videos/
+/cypress/screenshots/
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
+
+*.tsbuildinfo
diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 0000000..17a23d0
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,7 @@
+
+{
+ "$schema": "https://json.schemastore.org/prettierrc",
+ "semi": false,
+ "singleQuote": true,
+ "printWidth": 100
+}
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..c92168f
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,8 @@
+{
+ "recommendations": [
+ "Vue.volar",
+ "dbaeumer.vscode-eslint",
+ "EditorConfig.EditorConfig",
+ "esbenp.prettier-vscode"
+ ]
+}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..8855944
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,14 @@
+# frontend/Dockerfile
+FROM node:20
+
+WORKDIR /app
+
+COPY package*.json ./
+
+RUN npm install
+
+COPY . .
+
+EXPOSE 5173
+
+CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 0000000..76c70ec
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,19 @@
+import js from '@eslint/js'
+import pluginVue from 'eslint-plugin-vue'
+import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
+
+export default [
+ {
+ name: 'app/files-to-lint',
+ files: ['**/*.{js,mjs,jsx,vue}'],
+ },
+
+ {
+ name: 'app/files-to-ignore',
+ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
+ },
+
+ js.configs.recommended,
+ ...pluginVue.configs['flat/essential'],
+ skipFormatting,
+]
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..b19040a
--- /dev/null
+++ b/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ Vite App
+
+
+
+
+
+
diff --git a/jsconfig.json b/jsconfig.json
new file mode 100644
index 0000000..5a1f2d2
--- /dev/null
+++ b/jsconfig.json
@@ -0,0 +1,8 @@
+{
+ "compilerOptions": {
+ "paths": {
+ "@/*": ["./src/*"]
+ }
+ },
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..d9cb4a9
--- /dev/null
+++ b/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "frontend",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "preview": "vite preview"
+ },
+ "dependencies": {
+ "axios": "^1.3.4",
+ "vue": "^3.3.4",
+ "vue-router": "^4.2.4",
+ "vuex": "^4.1.0"
+ },
+ "devDependencies": {
+ "@vitejs/plugin-vue": "^4.2.3",
+ "@vitejs/plugin-vue-jsx": "^3.0.1",
+ "vite": "^4.4.5",
+ "vite-plugin-vue-devtools": "^1.0.0-rc.5"
+ }
+}
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..df36fcf
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/src/App.vue b/src/App.vue
new file mode 100644
index 0000000..62472fd
--- /dev/null
+++ b/src/App.vue
@@ -0,0 +1,61 @@
+
+
+
+ Todo List |
+ Logout
+
+
+
+
+
+
+
+
diff --git a/src/assets/base.css b/src/assets/base.css
new file mode 100644
index 0000000..8816868
--- /dev/null
+++ b/src/assets/base.css
@@ -0,0 +1,86 @@
+/* color palette from */
+:root {
+ --vt-c-white: #ffffff;
+ --vt-c-white-soft: #f8f8f8;
+ --vt-c-white-mute: #f2f2f2;
+
+ --vt-c-black: #181818;
+ --vt-c-black-soft: #222222;
+ --vt-c-black-mute: #282828;
+
+ --vt-c-indigo: #2c3e50;
+
+ --vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
+ --vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
+ --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
+ --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
+
+ --vt-c-text-light-1: var(--vt-c-indigo);
+ --vt-c-text-light-2: rgba(60, 60, 60, 0.66);
+ --vt-c-text-dark-1: var(--vt-c-white);
+ --vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
+}
+
+/* semantic color variables for this project */
+:root {
+ --color-background: var(--vt-c-white);
+ --color-background-soft: var(--vt-c-white-soft);
+ --color-background-mute: var(--vt-c-white-mute);
+
+ --color-border: var(--vt-c-divider-light-2);
+ --color-border-hover: var(--vt-c-divider-light-1);
+
+ --color-heading: var(--vt-c-text-light-1);
+ --color-text: var(--vt-c-text-light-1);
+
+ --section-gap: 160px;
+}
+
+@media (prefers-color-scheme: dark) {
+ :root {
+ --color-background: var(--vt-c-black);
+ --color-background-soft: var(--vt-c-black-soft);
+ --color-background-mute: var(--vt-c-black-mute);
+
+ --color-border: var(--vt-c-divider-dark-2);
+ --color-border-hover: var(--vt-c-divider-dark-1);
+
+ --color-heading: var(--vt-c-text-dark-1);
+ --color-text: var(--vt-c-text-dark-2);
+ }
+}
+
+*,
+*::before,
+*::after {
+ box-sizing: border-box;
+ margin: 0;
+ font-weight: normal;
+}
+
+body {
+ min-height: 100vh;
+ color: var(--color-text);
+ background: var(--color-background);
+ transition:
+ color 0.5s,
+ background-color 0.5s;
+ line-height: 1.6;
+ font-family:
+ Inter,
+ -apple-system,
+ BlinkMacSystemFont,
+ 'Segoe UI',
+ Roboto,
+ Oxygen,
+ Ubuntu,
+ Cantarell,
+ 'Fira Sans',
+ 'Droid Sans',
+ 'Helvetica Neue',
+ sans-serif;
+ font-size: 15px;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
diff --git a/src/assets/logo.svg b/src/assets/logo.svg
new file mode 100644
index 0000000..7565660
--- /dev/null
+++ b/src/assets/logo.svg
@@ -0,0 +1 @@
+
diff --git a/src/assets/main.css b/src/assets/main.css
new file mode 100644
index 0000000..36fb845
--- /dev/null
+++ b/src/assets/main.css
@@ -0,0 +1,35 @@
+@import './base.css';
+
+#app {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ font-weight: normal;
+}
+
+a,
+.green {
+ text-decoration: none;
+ color: hsla(160, 100%, 37%, 1);
+ transition: 0.4s;
+ padding: 3px;
+}
+
+@media (hover: hover) {
+ a:hover {
+ background-color: hsla(160, 100%, 37%, 0.2);
+ }
+}
+
+@media (min-width: 1024px) {
+ body {
+ display: flex;
+ place-items: center;
+ }
+
+ #app {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ padding: 0 2rem;
+ }
+}
diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue
new file mode 100644
index 0000000..eff59f1
--- /dev/null
+++ b/src/components/HelloWorld.vue
@@ -0,0 +1,44 @@
+
+
+
+
+
{{ msg }}
+
+ You’ve successfully created a project with
+ Vite +
+ Vue 3 .
+
+
+
+
+
diff --git a/src/components/TheWelcome.vue b/src/components/TheWelcome.vue
new file mode 100644
index 0000000..e02c38f
--- /dev/null
+++ b/src/components/TheWelcome.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+ Documentation
+
+ Vue’s
+ official documentation
+ provides you with all information you need to get started.
+
+
+
+
+
+
+ Tooling
+
+ This project is served and bundled with
+ Vite . The
+ recommended IDE setup is
+ VSCode
+ +
+ Volar . If
+ you need to test your components and web pages, check out
+ Vite
+ and
+ Cypress
+ /
+ Playwright .
+
+
+
+ More instructions are available in
+ README.md
.
+
+
+
+
+
+
+ Ecosystem
+
+ Get official tools and libraries for your project:
+ Pinia ,
+ Vue Router ,
+ Vue Test Utils , and
+ Vue Dev Tools . If
+ you need more resources, we suggest paying
+ Awesome Vue
+ a visit.
+
+
+
+
+
+
+ Community
+
+ Got stuck? Ask your question on
+ Vue Land
+ (our official Discord server), or
+ StackOverflow . You should also follow the official
+ @vuejs.org
+ Bluesky account or the
+ @vuejs
+ X account for latest news in the Vue world.
+
+
+
+
+
+
+ Support Vue
+
+ As an independent project, Vue relies on community backing for its sustainability. You can help
+ us by
+ becoming a sponsor .
+
+
diff --git a/src/components/WelcomeItem.vue b/src/components/WelcomeItem.vue
new file mode 100644
index 0000000..ac366d0
--- /dev/null
+++ b/src/components/WelcomeItem.vue
@@ -0,0 +1,86 @@
+
+
+
+
+
diff --git a/src/components/icons/IconCommunity.vue b/src/components/icons/IconCommunity.vue
new file mode 100644
index 0000000..2dc8b05
--- /dev/null
+++ b/src/components/icons/IconCommunity.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/src/components/icons/IconDocumentation.vue b/src/components/icons/IconDocumentation.vue
new file mode 100644
index 0000000..6d4791c
--- /dev/null
+++ b/src/components/icons/IconDocumentation.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/src/components/icons/IconEcosystem.vue b/src/components/icons/IconEcosystem.vue
new file mode 100644
index 0000000..c3a4f07
--- /dev/null
+++ b/src/components/icons/IconEcosystem.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/src/components/icons/IconSupport.vue b/src/components/icons/IconSupport.vue
new file mode 100644
index 0000000..7452834
--- /dev/null
+++ b/src/components/icons/IconSupport.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/src/components/icons/IconTooling.vue b/src/components/icons/IconTooling.vue
new file mode 100644
index 0000000..660598d
--- /dev/null
+++ b/src/components/icons/IconTooling.vue
@@ -0,0 +1,19 @@
+
+
+
+
+
+
diff --git a/src/main.js b/src/main.js
new file mode 100644
index 0000000..768f489
--- /dev/null
+++ b/src/main.js
@@ -0,0 +1,9 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+import router from './router'
+import store from './store'
+
+const app = createApp(App)
+app.use(router)
+app.use(store)
+app.mount('#app')
diff --git a/src/router/index.js b/src/router/index.js
new file mode 100644
index 0000000..0c023cb
--- /dev/null
+++ b/src/router/index.js
@@ -0,0 +1,37 @@
+import { createRouter, createWebHistory } from 'vue-router'
+import TodoList from '../views/TodoList.vue'
+import Login from '../views/Login.vue'
+import store from '../store' // Changed this line to use default import
+
+const routes = [
+ {
+ path: '/',
+ name: 'todos',
+ component: TodoList,
+ meta: { requiresAuth: true }
+ },
+ {
+ path: '/login',
+ name: 'login',
+ component: Login
+ }
+]
+
+const router = createRouter({
+ history: createWebHistory(import.meta.env.BASE_URL),
+ routes
+})
+
+router.beforeEach((to, from, next) => {
+ if (to.matched.some(record => record.meta.requiresAuth)) {
+ if (!store.getters.isAuthenticated) {
+ next('/login')
+ } else {
+ next()
+ }
+ } else {
+ next()
+ }
+})
+
+export default router
diff --git a/src/store/index.js b/src/store/index.js
new file mode 100644
index 0000000..6094894
--- /dev/null
+++ b/src/store/index.js
@@ -0,0 +1,155 @@
+import { createStore } from 'vuex'
+import axios from 'axios'
+
+const API_URL = 'http://localhost:8000/api'
+
+// Add axios interceptors for debugging
+axios.interceptors.request.use(request => {
+ console.log('Starting Request:', request.url, request.headers)
+ return request
+})
+
+axios.interceptors.response.use(
+ response => {
+ console.log('Response:', response.data)
+ return response
+ },
+ error => {
+ console.error('API Error:', error.response?.data || error.message)
+ return Promise.reject(error)
+ }
+)
+
+const store = createStore({
+ state: {
+ token: localStorage.getItem('token') || null,
+ todos: []
+ },
+ mutations: {
+ setToken(state, token) {
+ state.token = token
+ },
+ setTodos(state, todos) {
+ state.todos = todos
+ },
+ addTodo(state, todo) {
+ state.todos.push(todo)
+ },
+ updateTodo(state, updatedTodo) {
+ const index = state.todos.findIndex(todo => todo.id === updatedTodo.id)
+ if (index !== -1) {
+ state.todos.splice(index, 1, updatedTodo)
+ }
+ },
+ removeTodo(state, todoId) {
+ state.todos = state.todos.filter(todo => todo.id !== todoId)
+ }
+ },
+ actions: {
+ async login({ commit }, credentials) {
+ try {
+ const response = await axios.post(`${API_URL}/login/`, credentials)
+ const token = response.data.token
+ localStorage.setItem('token', token)
+ commit('setToken', token)
+ return true
+ } catch (error) {
+ console.error('Login error:', error)
+ return false
+ }
+ },
+ async register({ commit }, credentials) {
+ try {
+ const response = await axios.post(`${API_URL}/register/`, credentials)
+ const token = response.data.token
+ localStorage.setItem('token', token)
+ commit('setToken', token)
+ return true
+ } catch (error) {
+ console.error('Registration error:', error)
+ return false
+ }
+ },
+ logout({ commit }) {
+ localStorage.removeItem('token')
+ commit('setToken', null)
+ commit('setTodos', [])
+ },
+ async fetchTodos({ commit, state }) {
+ try {
+ console.log('Fetching todos with token:', state.token)
+ const response = await axios.get(`${API_URL}/todos/`, {
+ headers: { Authorization: `Bearer ${state.token}` }
+ })
+ commit('setTodos', response.data)
+ } catch (error) {
+ console.error('Error fetching todos:', error)
+ if (error.response?.status === 401) {
+ commit('setToken', null)
+ localStorage.removeItem('token')
+ }
+ throw error
+ }
+ },
+ async addTodo({ commit, state }, title) {
+ try {
+ console.log('Adding todo:', title)
+ const response = await axios.post(
+ `${API_URL}/todos/`,
+ { title },
+ {
+ headers: {
+ Authorization: `Bearer ${state.token}`,
+ 'Content-Type': 'application/json'
+ }
+ }
+ )
+ commit('addTodo', response.data)
+ } catch (error) {
+ console.error('Error adding todo:', error)
+ throw error
+ }
+ },
+ async updateTodo({ commit, state }, todo) {
+ try {
+ const response = await axios.put(
+ `${API_URL}/todos/${todo.id}/`,
+ todo,
+ {
+ headers: {
+ Authorization: `Bearer ${state.token}`,
+ 'Content-Type': 'application/json'
+ }
+ }
+ )
+ commit('updateTodo', response.data)
+ } catch (error) {
+ console.error('Error updating todo:', error)
+ throw error
+ }
+ },
+ async deleteTodo({ commit, state }, todoId) {
+ try {
+ await axios.delete(
+ `${API_URL}/todos/${todoId}/`,
+ {
+ headers: {
+ Authorization: `Bearer ${state.token}`,
+ 'Content-Type': 'application/json'
+ }
+ }
+ )
+ commit('removeTodo', todoId)
+ } catch (error) {
+ console.error('Error deleting todo:', error)
+ throw error
+ }
+ }
+ },
+ getters: {
+ isAuthenticated: state => !!state.token,
+ todos: state => state.todos
+ }
+})
+
+export default store
diff --git a/src/stores/counter.js b/src/stores/counter.js
new file mode 100644
index 0000000..b6757ba
--- /dev/null
+++ b/src/stores/counter.js
@@ -0,0 +1,12 @@
+import { ref, computed } from 'vue'
+import { defineStore } from 'pinia'
+
+export const useCounterStore = defineStore('counter', () => {
+ const count = ref(0)
+ const doubleCount = computed(() => count.value * 2)
+ function increment() {
+ count.value++
+ }
+
+ return { count, doubleCount, increment }
+})
diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue
new file mode 100644
index 0000000..756ad2a
--- /dev/null
+++ b/src/views/AboutView.vue
@@ -0,0 +1,15 @@
+
+
+
This is an about page
+
+
+
+
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
new file mode 100644
index 0000000..6bb706f
--- /dev/null
+++ b/src/views/HomeView.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/src/views/Login.vue b/src/views/Login.vue
new file mode 100644
index 0000000..ec62d03
--- /dev/null
+++ b/src/views/Login.vue
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
diff --git a/src/views/TodoList.vue b/src/views/TodoList.vue
new file mode 100644
index 0000000..0f999ef
--- /dev/null
+++ b/src/views/TodoList.vue
@@ -0,0 +1,232 @@
+
+
+
Todo List
+
+
+
+ {{ error }}
+
+
+
+
+ Add
+
+
+
+
+
+ No todos yet. Add one above!
+
+
+
Logout
+
+
+
+
+
+
+
diff --git a/vite.config.js b/vite.config.js
new file mode 100644
index 0000000..d49d708
--- /dev/null
+++ b/vite.config.js
@@ -0,0 +1,20 @@
+import { fileURLToPath, URL } from 'node:url'
+
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import vueJsx from '@vitejs/plugin-vue-jsx'
+import vueDevTools from 'vite-plugin-vue-devtools'
+
+// https://vite.dev/config/
+export default defineConfig({
+ plugins: [
+ vue(),
+ vueJsx(),
+ vueDevTools(),
+ ],
+ resolve: {
+ alias: {
+ '@': fileURLToPath(new URL('./src', import.meta.url))
+ },
+ },
+})