This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
jakub.sedlacek2
committed
Oct 29, 2023
1 parent
ecf30b6
commit 6780963
Showing
11 changed files
with
165 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"use client"; | ||
import { Field, IMemberResponse } from "app/api/member/member.type"; | ||
import { calculateAge, safeUrl } from "helpers/profileFieldHelpers"; | ||
import Content from "library/atoms/Content"; | ||
import UserCard from "library/molecules/cards/UserCard"; | ||
import { createContext, useContext, useState } from "react"; | ||
|
||
type DatingSiteState = { | ||
gender: string | null; | ||
useMyPreferences: boolean; | ||
data: IMemberResponse[]; | ||
}; | ||
|
||
type Props = { state: DatingSiteState; setState: (state: DatingSiteState) => void }; | ||
|
||
const DatingSiteContext = createContext<Props>({} as Props); | ||
|
||
const DatingSiteContainer = (props: { members: IMemberResponse[] }) => { | ||
const [state, setState] = useState<DatingSiteState>({ | ||
gender: null, | ||
useMyPreferences: true, | ||
data: props.members, | ||
}); | ||
|
||
return ( | ||
<DatingSiteContext.Provider value={{ state, setState }}> | ||
<Content title="Seznamka"> | ||
<DatingSiteFilter></DatingSiteFilter> | ||
<h4>Našli jsme pro tebe</h4> | ||
<DatingSiteResult></DatingSiteResult> | ||
</Content> | ||
</DatingSiteContext.Provider> | ||
); | ||
}; | ||
|
||
const getFieldValue = (fields: Field[], name: string) => { | ||
return fields.find(e => e.name === name)?.value.raw ?? '---'; | ||
} | ||
|
||
const DatingSiteResult = () => { | ||
const { state, setState } = useContext<Props>(DatingSiteContext); | ||
|
||
return ( | ||
<div> | ||
{state.data.map(e => { | ||
|
||
if(!e.xprofile) { | ||
return <></>; | ||
} | ||
|
||
const fields = Object.values(e.xprofile.groups).flatMap(v => Object.values(v.fields)); | ||
const birthdate = getFieldValue(fields, 'Věk'); | ||
return (<UserCard | ||
age={birthdate !== '' ? calculateAge(new Date(birthdate)) : 0} | ||
name={e.name} | ||
cardType="default" | ||
gender={getFieldValue(fields, 'Pohlaví')} | ||
location={`${getFieldValue(fields, 'Město')}, ${getFieldValue(fields, 'Kraj')}`} | ||
userIsActive={false} | ||
status={getFieldValue(fields, 'Status')} | ||
photo={safeUrl(e.avatar_urls?.full ?? '')} | ||
></UserCard>); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
const DatingSiteFilter = () => { | ||
return <div></div>; | ||
}; | ||
|
||
export default DatingSiteContainer; |
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,22 @@ | ||
import { getServerSession } from "next-auth"; | ||
import { getMembers } from "../api/member/member"; | ||
import DatingSiteContainer from "./components/DatingSiteContainer"; | ||
import { authOptions } from "app/api/auth/[...nextauth]/route"; | ||
import { redirect } from "next/navigation"; | ||
|
||
const DatingSitePage = async () => { | ||
|
||
const session = await getServerSession(authOptions) | ||
|
||
if(!session) { | ||
redirect("/"); | ||
} | ||
|
||
const members = await getMembers({}, { | ||
type: "random", | ||
}); | ||
|
||
return (<DatingSiteContainer members={members ?? []}></DatingSiteContainer>); | ||
} | ||
|
||
export default DatingSitePage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { HeartSvg } from "library/icons/symbols"; | ||
|
||
const ProfileStatus = (props: {status: string}) => { | ||
return (<div className="flex gap-2 items-center"> | ||
{props.status === "seznamuji se" && ( | ||
<span className="text-magenta-40"> | ||
<HeartSvg width={20} /> | ||
</span> | ||
)} | ||
<p>{props.status}</p> | ||
</div>); | ||
} | ||
|
||
export default ProfileStatus; |
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