mirror of
https://github.com/urosran/cally.git
synced 2025-07-16 18:16:17 +00:00
- Sorted the users when adding todo
This commit is contained in:
@ -25,6 +25,7 @@ import CalendarIcon from "@/assets/svgs/CalendarIcon";
|
|||||||
import ClockOIcon from "@/assets/svgs/ClockOIcon";
|
import ClockOIcon from "@/assets/svgs/ClockOIcon";
|
||||||
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||||
import RepeatFreq from "./RepeatFreq";
|
import RepeatFreq from "./RepeatFreq";
|
||||||
|
import {useAuthContext} from "@/contexts/AuthContext";
|
||||||
|
|
||||||
interface IAddChoreDialog {
|
interface IAddChoreDialog {
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
@ -44,6 +45,7 @@ const defaultTodo = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||||
|
const {user} = useAuthContext()
|
||||||
const {addToDo, updateToDo} = useToDosContext();
|
const {addToDo, updateToDo} = useToDosContext();
|
||||||
const [todo, setTodo] = useState<IToDo>(
|
const [todo, setTodo] = useState<IToDo>(
|
||||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||||
@ -57,6 +59,11 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
const titleRef = useRef<TextFieldRef>(null)
|
const titleRef = useRef<TextFieldRef>(null)
|
||||||
|
|
||||||
const {data: members} = useGetFamilyMembers();
|
const {data: members} = useGetFamilyMembers();
|
||||||
|
let sortedMembers = members?.sort((a, b) => {
|
||||||
|
if (a.uid === user?.uid) return -1;
|
||||||
|
if (b.uid === user?.uid) return 1;
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setTodo(defaultTodo);
|
setTodo(defaultTodo);
|
||||||
@ -272,7 +279,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{members?.map((member) => (
|
{sortedMembers?.map((member) => (
|
||||||
<Picker.Item
|
<Picker.Item
|
||||||
key={member.uid}
|
key={member.uid}
|
||||||
label={member?.firstName + " " + member?.lastName}
|
label={member?.firstName + " " + member?.lastName}
|
||||||
|
Reference in New Issue
Block a user