-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 28 additions & 9 deletions
37
frontend/src/queries/Property Manager/useGetPropertyManagerByPropertyManagerID.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
import { supabase } from "../../supabase"; | ||
import {useEffect, useState} from "react"; | ||
|
||
const useGetPropertyManagerByPropertyManagerID = () =>{ | ||
const fetchPropertyManager = async (account_id) => { | ||
const { data, error } = await supabase | ||
.from("PROPERTY MANAGER") | ||
.select("*") | ||
.eq("property_manager_id", account_id); | ||
const useGetPropertyManagerByPropertyManagerID = (pm_id) =>{ | ||
const [propertyManager, setPropertyManager] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
return {data, error} | ||
}; | ||
return fetchPropertyManager | ||
useEffect(() => { | ||
const fetchPropertyManager = async () => { | ||
if (pm_id) { | ||
setLoading(true); | ||
const { data, error } = await supabase | ||
.from("PROPERTY MANAGER") | ||
.select("*") | ||
.eq("property_manager_id", pm_id); | ||
|
||
if (error) { | ||
setLoading(false); | ||
setPropertyManager([]); | ||
} else { | ||
setLoading(false); | ||
setPropertyManager(data || []); | ||
} | ||
} else { | ||
setLoading(false); | ||
setPropertyManager([]); | ||
} | ||
} | ||
fetchPropertyManager(); | ||
}, [pm_id]); | ||
return {propertyManager, loading}; | ||
}; | ||
|
||
export default useGetPropertyManagerByPropertyManagerID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 30 additions & 11 deletions
41
frontend/src/queries/Renter Comment/useGetRenterCommentsWithPMInfoByRenterID.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
import { supabase } from "../../supabase"; | ||
import {useEffect, useState} from "react"; | ||
|
||
const useGetRenterCommentsWithPMInfoByRenterID = () =>{ | ||
const fetchComments = async (renter_id) => { | ||
const { data, error } = await supabase | ||
.from("RENTER COMMENT") | ||
.select( | ||
'*, "PROPERTY MANAGER"(*)' | ||
) | ||
.eq("renter_id", renter_id); | ||
const useGetRenterCommentsWithPMInfoByRenterID = (renter_id) =>{ | ||
const [comments, setComments] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
return {data, error} | ||
}; | ||
return fetchComments | ||
useEffect(() => { | ||
const fetchComments = async () => { | ||
if (renter_id) { | ||
setLoading(true); | ||
const { data, error } = await supabase | ||
.from("RENTER-COMMENT") | ||
.select( | ||
'*, "PROPERTY MANAGER"(*)' | ||
) | ||
.eq("renter_id", renter_id); | ||
|
||
if (error) { | ||
setLoading(false); | ||
setComments([]); | ||
} else { | ||
setLoading(false); | ||
setComments(data || []); | ||
} | ||
} else { | ||
setLoading(false); | ||
setComments([]); | ||
} | ||
} | ||
fetchComments() | ||
}, [renter_id]); | ||
return {comments, loading}; | ||
}; | ||
|
||
export default useGetRenterCommentsWithPMInfoByRenterID; |