-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
18 changed files
with
987 additions
and
858 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
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
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { queryClient } from "../main"; | ||
|
||
export function removePages(queryKey: string[]) { | ||
queryClient.setQueriesData<{ pages: unknown[][]; pageParams: number[] }>( | ||
{ queryKey: queryKey }, | ||
(data) => { | ||
if (!data) return; | ||
|
||
return { | ||
pages: data.pages.slice(0, 1), | ||
pageParams: data.pageParams.slice(0, 1), | ||
}; | ||
} | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react"; | ||
import { useIntersection } from "@mantine/hooks"; | ||
|
||
export const useInfiniteScroll = ( | ||
onIntersect: () => void, | ||
threshold?: number | ||
) => { | ||
const lastElementRef = React.useRef(null); | ||
const { ref, entry } = useIntersection({ | ||
root: lastElementRef.current, | ||
threshold: threshold || 1.0, | ||
}); | ||
|
||
React.useEffect(() => { | ||
if (entry && entry.isIntersecting) { | ||
onIntersect(); | ||
} | ||
}, [entry]); | ||
|
||
return { ref }; | ||
}; |
79 changes: 79 additions & 0 deletions
79
web/src/layers/mdt/components/Profiles/components/PartialProfile.tsx
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react"; | ||
import { Text, Image } from "@mantine/core"; | ||
import { useProfilesStore } from "../../../../../stores"; | ||
import { DEBUG_PROFILE } from "../../../../../stores/profilesStore"; | ||
import { PartialProfileData, Profile } from "../../../../../typings"; | ||
import { fetchNui } from "../../../../../utils/fetchNui"; | ||
import locales from "../../../../../locales"; | ||
import dayjs from "dayjs"; | ||
|
||
interface Props { | ||
profile: PartialProfileData; | ||
} | ||
|
||
const PartialProfile: React.ForwardRefRenderFunction< | ||
HTMLDivElement | null, | ||
Props | ||
> = ({ profile }, ref) => { | ||
const { setIsProfileWanted, setSelectedProfile } = useProfilesStore(); | ||
|
||
const handleProfileClick = async (profile: PartialProfileData) => { | ||
setSelectedProfile(null); | ||
setIsProfileWanted(false); | ||
const resp = await fetchNui<Profile>("getProfile", profile.citizenid, { | ||
data: { | ||
...DEBUG_PROFILE, | ||
firstName: profile.firstname, | ||
lastName: profile.lastname, | ||
citizenid: profile.citizenid, | ||
}, | ||
}); | ||
|
||
const isProfileWanted = await fetchNui<boolean>( | ||
"isProfileWanted", | ||
profile.citizenid, | ||
{ | ||
data: false, | ||
} | ||
); | ||
|
||
setSelectedProfile(resp); | ||
setIsProfileWanted(isProfileWanted); | ||
}; | ||
|
||
return ( | ||
<div | ||
className='profile-card' | ||
onClick={() => handleProfileClick(profile)} | ||
ref={ref} | ||
> | ||
<Image | ||
width={65} | ||
height={65} | ||
src={ | ||
profile.image ?? | ||
"https://cdn.vectorstock.com/i/preview-1x/97/68/account-avatar-dark-mode-glyph-ui-icon-vector-44429768.jpg" | ||
} | ||
radius={"lg"} | ||
alt='With default placeholder' | ||
withPlaceholder | ||
/> | ||
|
||
<div> | ||
<Text weight={600} style={{ fontSize: 13, color: "white" }}> | ||
{profile.firstname} {profile.lastname} | ||
</Text> | ||
|
||
<Text style={{ fontSize: 12, color: "white" }}> | ||
{locales.dob}: {dayjs(profile.dob).format("DD/MM/YYYY")} | ||
</Text> | ||
|
||
<Text style={{ fontSize: 12, color: "white" }}> | ||
{locales.citizen_id}: {profile.citizenid} | ||
</Text> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default React.memo(React.forwardRef(PartialProfile)); |
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
Oops, something went wrong.