This repository has been archived by the owner on Aug 23, 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.
refactor: user edit and edit password
- Loading branch information
1 parent
5e7c7b1
commit ef99866
Showing
8 changed files
with
898 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IonContent, IonPage } from "@ionic/react"; | ||
import { useParams } from "react-router-dom"; | ||
|
||
export function OperatorUserEditPassword() { | ||
const { id } = useParams<{ id: string }>(); | ||
|
||
return ( | ||
<IonPage> | ||
<IonContent className="complain-form-laporan ion-padding" fullscreen> | ||
<div className="pt-12"> | ||
<h1 className="font-bold text-left text-xl">TrashTrack</h1> | ||
<p className="text-xs text-left text-slate-600">Edit User Password</p> | ||
</div> | ||
<div className="flex flex-col pt-8 gap-4"></div> | ||
</IonContent> | ||
</IonPage> | ||
); | ||
} | ||
|
||
export default OperatorUserEditPassword; |
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,33 @@ | ||
import { IonContent, IonPage } from "@ionic/react"; | ||
import { useParams } from "react-router-dom"; | ||
import { useGetUserQuery, IUserQuery } from "../../../queries/get-user-query"; | ||
import { UserEditForm } from "@trashtrack/ui"; | ||
import { useGetUsersQuery } from "../../../queries/get-users-query"; | ||
|
||
export function OperatorUserEdit() { | ||
const { user_id } = useParams<{ user_id: string }>(); | ||
const { refetch } = useGetUsersQuery(); | ||
|
||
const { data, isLoading, isError } = useGetUserQuery(user_id); | ||
|
||
return ( | ||
<IonPage> | ||
<IonContent className="complain-form-laporan ion-padding" fullscreen> | ||
<div className="pt-12"> | ||
<h1 className="font-bold text-left text-xl">TrashTrack</h1> | ||
<p className="text-xs text-left text-slate-600">Edit User</p> | ||
</div> | ||
<div className="flex flex-col pt-8 gap-4"> | ||
{isError && <p>Error fetching user</p>} | ||
{isLoading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<UserEditForm id={user_id} refetch={refetch} user={data.data as IUserQuery} /> | ||
)} | ||
</div> | ||
</IonContent> | ||
</IonPage> | ||
); | ||
} | ||
|
||
export default OperatorUserEdit; |
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,25 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { API_URL } from "@trashtrack/utils"; | ||
|
||
enum Role { | ||
operator = "operator", | ||
admin = "admin", | ||
} | ||
|
||
export interface IUserQuery { | ||
id: number; | ||
name: string; | ||
username: string; | ||
password: string; | ||
phoneNumber: string; | ||
role: Role; | ||
active: boolean; | ||
description: string; | ||
} | ||
|
||
export const useGetUserQuery = (id: string | undefined) => { | ||
return useQuery({ | ||
queryKey: ["getUserQ"], | ||
queryFn: () => fetch(API_URL + `/user/id/${id}`).then((res) => res.json()), | ||
}); | ||
}; |
Oops, something went wrong.