init commit,
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
export const useCamera = () => {
|
||||
const takePhoto = async () => {
|
||||
const options = {
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Camera,
|
||||
quality: 100,
|
||||
};
|
||||
const cameraPhoto = await Camera.getPhoto(options);
|
||||
return Capacitor.convertFileSrc(cameraPhoto.webPath);
|
||||
};
|
||||
|
||||
return {
|
||||
takePhoto,
|
||||
};
|
||||
};
|
@@ -0,0 +1,20 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
function useFriendStatus(friendID) {
|
||||
const [isOnline, setIsOnline] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
function handleStatusChange(status) {
|
||||
setIsOnline(status.isOnline);
|
||||
}
|
||||
|
||||
ChatAPI.subscribeToFriendStatus(friendID, handleStatusChange);
|
||||
return () => {
|
||||
ChatAPI.unsubscribeFromFriendStatus(friendID, handleStatusChange);
|
||||
};
|
||||
});
|
||||
|
||||
return isOnline;
|
||||
}
|
||||
|
||||
export default useFriendStatus;
|
@@ -0,0 +1,18 @@
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
export const useGallery = () => {
|
||||
const prompt = async () => {
|
||||
const options = {
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Prompt,
|
||||
quality: 100,
|
||||
};
|
||||
const cameraPhoto = await Camera.getPhoto(options);
|
||||
return Capacitor.convertFileSrc(cameraPhoto.webPath);
|
||||
};
|
||||
|
||||
return {
|
||||
prompt,
|
||||
};
|
||||
};
|
@@ -0,0 +1,20 @@
|
||||
// REQ0041/home_discover_event_tab
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useGetPartyEventDetail = ({ party_event_id }) => {
|
||||
const [party_event_detail, setPartyEventDetail] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase.from('view_party_event_summaries').select('*').filter('id', '=', party_event_id);
|
||||
setPartyEventDetail(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, [party_event_id]);
|
||||
|
||||
return [party_event_detail];
|
||||
};
|
@@ -0,0 +1,26 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useGetPartyEventOrder = ({ event_id }) => {
|
||||
const [party_event_order, setPartyEventOrder] = useState(null);
|
||||
|
||||
async function getPartyEventOrder() {
|
||||
let { data } = await supabase.from('party_event_orders').select(`
|
||||
id, profiles(id, full_name, gender, remarks)
|
||||
`);
|
||||
// status == 2 , paid
|
||||
|
||||
// tidy up
|
||||
|
||||
// .filter('party_event_id', 'in', `("${event_id}")`);
|
||||
// setPartyEventOrder(data);
|
||||
// console.log({data})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEventOrder();
|
||||
}, []);
|
||||
|
||||
return [party_event_order];
|
||||
};
|
@@ -0,0 +1,20 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useGetProfileById = ({ id }) => {
|
||||
const [party_event_order, setPartyEventOrder] = useState(null);
|
||||
|
||||
async function getPartyEventOrder() {
|
||||
let { data } = await supabase
|
||||
.from('profiles')
|
||||
.select('*')
|
||||
.filter('id', 'in', `("33a1f462-7085-4655-b42e-a0f1e8395f6c")`);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEventOrder();
|
||||
}, []);
|
||||
|
||||
return [party_event_order];
|
||||
};
|
@@ -0,0 +1,25 @@
|
||||
// REQ0044/near_by_page
|
||||
// what to do:
|
||||
// list users near by except current user
|
||||
|
||||
import { useContext, useEffect, useState } from 'react';
|
||||
|
||||
import { AppContext } from '../data/AppContext';
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useGetUserProfileById = ({ user_id }) => {
|
||||
const { profile } = useContext(AppContext);
|
||||
const [other_user_profiles, setOtherUserProfiles] = useState([]);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase.from('profiles').select('*').filter('user_id', 'in', `(${user_id})`).limit(1);
|
||||
|
||||
setOtherUserProfiles(data[0]);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [other_user_profiles];
|
||||
};
|
@@ -0,0 +1,25 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useJoinTest = () => {
|
||||
const [test_data, setTestData] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
const { data, error } = await supabase.from('countries').select(`
|
||||
id,
|
||||
name,
|
||||
cities ( id, name )
|
||||
`);
|
||||
|
||||
console.log({ data });
|
||||
|
||||
setTestData(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [test_data];
|
||||
};
|
@@ -0,0 +1,26 @@
|
||||
// REQ0044/near_by_page
|
||||
// what to do:
|
||||
// list users near by except current user
|
||||
|
||||
import { useContext, useEffect, useState } from 'react';
|
||||
|
||||
import { AppContext } from '../data/AppContext';
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useListOtherUserProfiles = () => {
|
||||
const { profile } = useContext(AppContext);
|
||||
const [other_user_profiles, setOtherUserProfiles] = useState([]);
|
||||
const user_id = '1';
|
||||
|
||||
async function getPartyEvents() {
|
||||
console.log({ profile });
|
||||
let { data } = await supabase.from('profiles').select('*').not('user_id', 'in', `(${user_id})`).limit(10);
|
||||
setOtherUserProfiles(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [other_user_profiles];
|
||||
};
|
@@ -0,0 +1,19 @@
|
||||
// REQ0041/home_discover_event_tab
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useListPartyEventOrderSummary = ({ user_id }) => {
|
||||
const [party_event_summaries, setPartyEventSummaries] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase.from('view_party_event_orders_summary').select('*').filter('user_id', 'eq', '1');
|
||||
setPartyEventSummaries(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [party_event_summaries];
|
||||
};
|
@@ -0,0 +1,19 @@
|
||||
// REQ0041/home_discover_event_tab
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useListPartyEventOrders = ({ user_id }) => {
|
||||
const [party_event_summaries, setPartyEventSummaries] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase.from('view_party_event_orders').select('*').filter('user_id', 'eq', '1');
|
||||
setPartyEventSummaries(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [party_event_summaries];
|
||||
};
|
@@ -0,0 +1,21 @@
|
||||
// REQ0041/home_discover_event_tab
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useListPartyEventSummaries = () => {
|
||||
const [party_event_summaries, setPartyEventSummaries] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase.from('view_party_event_summaries').select('*');
|
||||
setPartyEventSummaries(data);
|
||||
console.log({ party_event_summaries });
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [party_event_summaries];
|
||||
};
|
@@ -0,0 +1,21 @@
|
||||
// REQ0041/home_discover_event_tab
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useListPartyEvents = () => {
|
||||
const [party_event_summaries, setPartyEventSummaries] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase.from('view_party_event_summaries').select('*');
|
||||
setPartyEventSummaries(data);
|
||||
console.log({ data });
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, []);
|
||||
|
||||
return [party_event_summaries];
|
||||
};
|
@@ -0,0 +1,24 @@
|
||||
// REQ0041/home_discover_event_tab
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { supabase } from '../supabaseClient';
|
||||
|
||||
export const useViewPartyEventParticipants = ({ party_event_id, limit }) => {
|
||||
const [participants, setParticipants] = useState(null);
|
||||
|
||||
async function getPartyEvents() {
|
||||
let { data } = await supabase
|
||||
.from('view_party_event_participants')
|
||||
.select('*')
|
||||
.filter('id', '=', party_event_id)
|
||||
.limit(limit);
|
||||
|
||||
setParticipants(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getPartyEvents();
|
||||
}, [party_event_id]);
|
||||
|
||||
return [participants];
|
||||
};
|
Reference in New Issue
Block a user