ContactView.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <script>
  2. import Sidebar from '@/components/Sidebar.vue'
  3. import { defineComponent } from 'vue'
  4. import axios from 'axios'
  5. import { config } from '@/main.js'
  6. import Cookies from "js-cookie";
  7. export default defineComponent({
  8. name: 'ContactView',
  9. components: {Sidebar},
  10. methods: {
  11. async handleSubmit(e) {
  12. e.preventDefault();
  13. console.log("submit");
  14. document.getElementById("submit").disabled = true;
  15. const formData = new FormData(e.target);
  16. const textarea = document.getElementById("textarea");
  17. let response = await axios.post(config.serverURL + "/contact", {
  18. name: formData.get("name"),
  19. email: formData.get("email"),
  20. message: textarea.value
  21. }, {
  22. withCredentials: true
  23. })
  24. if(response.data.error) { // Login unsuccessful
  25. document.getElementById("submit").disabled = false;
  26. alert(`Contact error: ${response.data.message}`);
  27. return this.router.go();
  28. }
  29. // Login successful
  30. alert(response.data.message);
  31. return this.router.push("/");
  32. }
  33. }
  34. });
  35. </script>
  36. <template>
  37. <div class="main">
  38. <Sidebar />
  39. <div class="contact-container">
  40. <form class="contact" @submit="handleSubmit">
  41. <p>contact form. you can contact the hajeebtok team here. the hajeebtok team will contact you back. we hope. we hope the hajeebtok team will contact you back in at least 15 days.</p>
  42. <input type="text" placeholder="Name" name="name" />
  43. <input type="email" placeholder="Email" name="email" />
  44. <textarea id="textarea"></textarea>
  45. <input type="submit" class="india-button" value="submit" id="submit" />
  46. </form>
  47. </div>
  48. </div>
  49. </template>
  50. <style scoped>
  51. .contact-container {
  52. width: 100vw;
  53. height: 100vh;
  54. margin: 0;
  55. position: absolute;
  56. display: flex;
  57. justify-content: center;
  58. align-items: center;
  59. top: 0;
  60. }
  61. .contact {
  62. background-color: var(--secondary-background-color);
  63. color: white;
  64. padding: 10px;
  65. border-radius: 5px;
  66. width: 600px;
  67. min-width: 400px;
  68. display: flex;
  69. flex-direction: column;
  70. align-items: center;
  71. justify-self: center;
  72. gap: 10px;
  73. }
  74. input {
  75. font-family: "Knewave", system-ui;
  76. font-size: 30px;
  77. border: 2px solid var(--accent-color);
  78. border-radius: 5px;
  79. }
  80. textarea {
  81. border: 2px solid var(--accent-color);
  82. border-radius: 5px;
  83. width: 600px;
  84. min-width: 400px;
  85. }
  86. textarea:focus {
  87. outline: none;
  88. }
  89. input:focus {
  90. outline: none;
  91. }
  92. .india-button {
  93. display: flex;
  94. align-items: center;
  95. gap: 10px;
  96. padding: 10px 10px;
  97. background: none;
  98. color: var(--accent-color);
  99. font-family: 'Pinyon Script', cursive;
  100. font-size: 30px;
  101. border-style: solid;
  102. border-width: 10px 20px;
  103. border-image-source: url('/assets/indiaButton.png');
  104. border-image-slice: 0 80 fill;
  105. border-image-repeat: stretch;
  106. border-image-outset: 0;
  107. border-image-width: 10px 40px;
  108. border-radius: 40px;
  109. background-clip: padding-box;
  110. }
  111. .india-button:disabled {
  112. border-image-source: url('/assets/indiaButtonDisabled.png');
  113. color: black;
  114. }
  115. .india-button:hover {
  116. animation-name: interaction;
  117. animation-duration: 0.5s;
  118. animation-iteration-count: infinite;
  119. cursor: pointer;
  120. }
  121. @keyframes interaction {
  122. 0% {
  123. transform: scale(1);
  124. }
  125. 50% {
  126. transform: scale(1.2);
  127. }
  128. 100% {
  129. transform: scale(1);
  130. }
  131. }
  132. </style>