123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <script>
- import { defineComponent } from 'vue'
- import Sidebar from '@/components/Sidebar.vue'
- import Cookies from 'js-cookie'
- import { useRouter } from 'vue-router'
- import axios from 'axios'
- import { config } from '@/main.js'
- export default defineComponent({
- name: 'UpdateAccountView',
- setup() {
- const router = useRouter()
- // no this here
- if (!Cookies.get('token') || !Cookies.get('token').startsWith('HajeebToken'))
- return router.push('/profile/myself')
- return { router }
- },
- components: { Sidebar },
- methods: {
- async handleSubmit(e) {
- e.preventDefault()
- if (!this.signedIn()) return this.router.push('/login');
- document.getElementById('submit').disabled = true
- const formData = new FormData(e.target);
- const response = await axios.post(`${config.serverURL}/video/upload`, formData, {
- withCredentials: true,
- })
- if(response.data.error) {
- alert(`Upload error: ${response.data.message}`);
- return console.error(response.data);
- }
- if(response.data.id) {
- alert(`Video uploaded successfully!`);
- return this.router.push(`/profile/myself`);
- }
- },
- signedIn() {
- return Cookies.get('token') && Cookies.get('token').startsWith('HajeebToken')
- },
- },
- })
- </script>
- <template>
- <div class="main">
- <Sidebar />
- <div class="update-container">
- <form class="update" id="form" @submit="handleSubmit" enctype="multipart/form-data">
- <img src="/assets/hajeebtok.png" width="300px" alt="HajeebTok logo" />
- <input
- type="file"
- name="picture"
- accept="image/png, image/jpeg, image/jpg, image/webp"
- />
- <input type="text" placeholder="title" name="title" />
- <input type="text" placeholder="description" name="description" />
- <input type="submit" value="update Account" id="submit" />
- </form>
- </div>
- </div>
- </template>
- <style scoped>
- .update-container {
- width: 100vw;
- height: 100vh;
- margin: 0;
- position: absolute;
- display: flex;
- justify-content: center;
- align-items: center;
- top: 0;
- }
- .update {
- background-color: var(--secondary-background-color);
- color: white;
- padding: 10px;
- border-radius: 5px;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-self: center;
- gap: 10px;
- }
- input {
- font-family: 'Knewave', system-ui;
- font-size: 30px;
- border: 2px solid var(--accent-color);
- border-radius: 5px;
- }
- input:focus {
- outline: none;
- }
- </style>
|