first push
This commit is contained in:
124
src/stores/EventsStore.js
Normal file
124
src/stores/EventsStore.js
Normal file
@@ -0,0 +1,124 @@
|
||||
import {defineStore} from 'pinia';
|
||||
import moment from 'moment-timezone';
|
||||
import axios from 'axios';
|
||||
|
||||
moment.tz.setDefault('America/Chicago')
|
||||
|
||||
// const headers = {
|
||||
// "Access-Control-Allow-Origin": "*",
|
||||
// }
|
||||
const apikey = import.meta.env.VITE_API_KEY;
|
||||
const apiUrl = import.meta.env.PROD
|
||||
? "https://api.digisnaxx.com"
|
||||
: "http://localhost:8000";
|
||||
|
||||
export const useEventsStore = defineStore('Events', {
|
||||
state: () => {
|
||||
return {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"Authorization": `${apikey}`,
|
||||
},
|
||||
events: [],
|
||||
promo: [],
|
||||
errors: [],
|
||||
search_term: '',
|
||||
the_day: "",
|
||||
new_msg: "",
|
||||
today: "",
|
||||
shortcode: "",
|
||||
};
|
||||
},
|
||||
|
||||
actions: {
|
||||
// setCalendar(cal) {
|
||||
// this.shortcode = cal;
|
||||
// console.log("CAL: ", this.shortcode);
|
||||
// return this.shortcode;
|
||||
// },
|
||||
|
||||
async fetchPromo() {
|
||||
// const results = await fetch(`${apiUrl}/socials/promo/`, {headers: this.headers});
|
||||
const results = await fetch(`${apiUrl}/socials/links/`, {headers: this.headers});
|
||||
const data = await results.json();
|
||||
this.promo = data;
|
||||
},
|
||||
|
||||
async fetchEvents(cal) {
|
||||
this.shortcode = cal;
|
||||
const results = await fetch(`${apiUrl}/events/events/?calendar__shortcode=${this.shortcode}`, {headers: this.headers});
|
||||
const data = await results.json();
|
||||
const events_list = data.slice(0,126);
|
||||
const index = 6;
|
||||
const value = {};
|
||||
const newArr = [];
|
||||
for (let i = 0; i < events_list.length; i++) {
|
||||
if (i === index) {
|
||||
newArr.push(value);
|
||||
}
|
||||
newArr.push(events_list[i]);
|
||||
};
|
||||
this.events = newArr;
|
||||
this.the_day = "";
|
||||
if(this.events.length() == 0){
|
||||
this.fetchEvents(cal)
|
||||
}
|
||||
},
|
||||
|
||||
async get_today(){
|
||||
var currentDate = moment().format('MMMM Do, YYYY | h:mm a');
|
||||
this.today = currentDate;
|
||||
},
|
||||
|
||||
searchEvents(){
|
||||
console.log("Running Search");
|
||||
let api_url = `${apiUrl}/events/events/`;
|
||||
if(this.search_term!==''||this.search_term!==null) {
|
||||
api_url = `${apiUrl}/events/events/?search=${this.search_term}&calendar__shortcode=${this.shortcode}`;
|
||||
this.new_msg = "Click Search again to view all events."
|
||||
}
|
||||
axios.get(api_url, {headers: this.headers})
|
||||
.then(response => {
|
||||
this.events = response.data
|
||||
if(api_url==`${apiUrl}/events/events/?search=`){
|
||||
this.new_msg = ""
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
this.errors.push(e)
|
||||
})
|
||||
},
|
||||
|
||||
getEventByDate(which_day) {
|
||||
let today = moment().format("YYYY-MM-DD");
|
||||
let the_date = moment().add(which_day, 'd').format("YYYY-MM-DD");
|
||||
this.the_day = the_date;
|
||||
let api_url = `${apiUrl}/events/events/`;
|
||||
if(the_date!==''||the_date!==null) {
|
||||
api_url = `${apiUrl}/events/events/?show_day=${the_date}&calendar__shortcode=${this.shortcode}`;
|
||||
}
|
||||
axios.get(api_url, {headers: this.headers})
|
||||
.then(response => {
|
||||
this.events = response.data
|
||||
})
|
||||
.catch(e => {
|
||||
this.errors.push(e)
|
||||
})
|
||||
},
|
||||
|
||||
async getEventsByType(event_type){
|
||||
let api_url = `${apiUrl}/events/events/`;
|
||||
if(this.the_day!=='' && (event_type!==''||event_type!==null)) {
|
||||
api_url = `${apiUrl}/events/events/?event_type=${event_type}&show_day=${this.the_day}&calendar__shortcode=${this.shortcode}`;
|
||||
} else if(this.the_day=='' && (event_type!==''||event_type!==null)) {
|
||||
api_url = `${apiUrl}/events/events/?event_type=${event_type}&calendar__shortcode=${this.shortcode}`;
|
||||
}
|
||||
console.log(api_url)
|
||||
const result = await fetch(api_url, {headers: this.headers});
|
||||
const data = await result.json();
|
||||
this.events = data;
|
||||
this.fetchPromo()
|
||||
return this.events;
|
||||
}
|
||||
}
|
||||
});
|
||||
27
src/stores/MainStore.vue
Normal file
27
src/stores/MainStore.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<script>
|
||||
import { defineStore } from 'pinia'
|
||||
import {ref, computed} from 'vue'
|
||||
|
||||
// the first argument is a unique id of the store across your application
|
||||
|
||||
export const mainStore = defineStore('store', () => {
|
||||
const isOpen = ref(false)
|
||||
const modal = ref(false)
|
||||
const promo_display = []
|
||||
|
||||
function changeGallery(isopen, n, val, promo) {
|
||||
modal.value = val
|
||||
if (n == 0) {
|
||||
isOpen.value = !isopen
|
||||
}
|
||||
if (!(promo === null)) {
|
||||
promo_display.push(promo);
|
||||
if (promo_display.length > 1) {
|
||||
promo_display.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { isOpen, modal, changeGallery, promo_display}
|
||||
})
|
||||
</script>
|
||||
68
src/stores/MenuStore.js
Normal file
68
src/stores/MenuStore.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import {defineStore} from 'pinia';
|
||||
import moment from 'moment-timezone';
|
||||
import {ref, computed} from 'vue';
|
||||
|
||||
const apikey = import.meta.env.VITE_API_KEY;
|
||||
const apiUrl = import.meta.env.PROD
|
||||
? "https://api.digisnaxx.com"
|
||||
: "http://localhost:8000";
|
||||
|
||||
export const useMenuStore = defineStore('MenuOptions', {
|
||||
state: () => {
|
||||
return {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"Authorization": `${apikey}`,
|
||||
},
|
||||
showMenu: false,
|
||||
isHidden: true,
|
||||
today: ref(""),
|
||||
new_msg: "",
|
||||
social_links: [],
|
||||
social_images: [],
|
||||
blog_posts: [],
|
||||
snaxx: [],
|
||||
};
|
||||
},
|
||||
|
||||
actions: {
|
||||
async get_today(){
|
||||
this.today = moment().tz("America/Chicago");
|
||||
},
|
||||
|
||||
close_menu(name){
|
||||
this.showMenu = !this.showMenu;
|
||||
this.get_today();
|
||||
},
|
||||
|
||||
async fetchSocialLinkList() {
|
||||
const results = await fetch(`${apiUrl}/socials/list-links`, {headers: this.headers});
|
||||
const data = await results.json();
|
||||
this.social_links = data;
|
||||
},
|
||||
|
||||
async fetchSocialLinks() {
|
||||
const results = await fetch(`${apiUrl}/socials/links`, {headers: this.headers});
|
||||
const data = await results.json();
|
||||
this.social_links = data;
|
||||
},
|
||||
|
||||
async fetchSocialImages() {
|
||||
const results = await fetch(`${apiUrl}/socials/images`, {headers: this.headers});
|
||||
const data = await results.json();
|
||||
this.social_images = data;
|
||||
},
|
||||
|
||||
async fetchBlogPosts() {
|
||||
const results = await fetch('https://canin.dreamfreely.org/ghost/api/content/posts/?key=ef0447585c290da508e6684916&filter=tag%3A-digisnaxx');
|
||||
const data = await results.json();
|
||||
this.blog_posts = data.posts;
|
||||
},
|
||||
|
||||
async fetchDigiSnaxx() {
|
||||
const results = await fetch('https://canin.dreamfreely.org/ghost/api/content/posts/?key=ef0447585c290da508e6684916&filter=tag%3Adigisnaxx');
|
||||
const data = await results.json();
|
||||
this.snaxx = data.posts;
|
||||
},
|
||||
}
|
||||
});
|
||||
3
src/stores/api.http
Normal file
3
src/stores/api.http
Normal file
@@ -0,0 +1,3 @@
|
||||
GET http://localhost:8000/events/events/?calendar__shortcode=msp HTTP/1.1
|
||||
content-type: application/json
|
||||
Authorization: Api-Key etxKiSpu.56Bgqtxxq9IGF3rPXHhluUtlckk5n0LG
|
||||
Reference in New Issue
Block a user