mirror of
https://github.com/urosran/cally.git
synced 2025-07-16 01:56:16 +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 ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||
import RepeatFreq from "./RepeatFreq";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
|
||||
interface IAddChoreDialog {
|
||||
isVisible: boolean;
|
||||
@ -44,6 +45,7 @@ const defaultTodo = {
|
||||
};
|
||||
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const {user} = useAuthContext()
|
||||
const {addToDo, updateToDo} = useToDosContext();
|
||||
const [todo, setTodo] = useState<IToDo>(
|
||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||
@ -57,6 +59,11 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const titleRef = useRef<TextFieldRef>(null)
|
||||
|
||||
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 = () => {
|
||||
setTodo(defaultTodo);
|
||||
@ -272,7 +279,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
/>
|
||||
)}
|
||||
>
|
||||
{members?.map((member) => (
|
||||
{sortedMembers?.map((member) => (
|
||||
<Picker.Item
|
||||
key={member.uid}
|
||||
label={member?.firstName + " " + member?.lastName}
|
||||
|
Reference in New Issue
Block a user