Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
feat(app): operator tabs
Browse files Browse the repository at this point in the history
affected: #9 #10
fix: #11 #12
  • Loading branch information
yehezkieldio committed Feb 11, 2024
1 parent 8581179 commit f9454ea
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 5 deletions.
36 changes: 36 additions & 0 deletions apps/app/src/components/operator-tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Redirect, Route } from "react-router-dom";
import { IonRouterOutlet, IonTabs, IonTabBar, IonTabButton, IonLabel } from "@ionic/react";
import { Icons } from "@trashtrack/ui";

import OperatorDashboard from "../pages/operator/dashboard";
import OperatorTrashbinDisplay from "../pages/operator/trash-bin/display";
import OperatorUserDisplay from "../pages/operator/user/display";

const OperatorTabs: React.FC = () => {
return (
<IonTabs>
<IonRouterOutlet animated={false} mode="ios">
<Route path="/operator/tabs/dashboard" render={() => <OperatorDashboard />} exact={true} />
<Route path="/operator/tabs/trash-bin" render={() => <OperatorTrashbinDisplay />} exact={true} />
<Route path="/operator/tabs/user" render={() => <OperatorUserDisplay />} exact={true} />
<Route path="/operator/tabs" render={() => <Redirect to="/operator/tabs/dashboard" />} exact={true} />
</IonRouterOutlet>
<IonTabBar slot="bottom" mode="ios" translucent className="pb-4">
<IonTabButton tab="tab1" href="/operator/tabs/dashboard">
<Icons.dashboard strokeWidth={1} className="pt-2 w-[32px] h-[30px]" />
<IonLabel className="pt-2">Dashboard</IonLabel>
</IonTabButton>
<IonTabButton tab="tab2" href="/operator/tabs/trash-bin">
<Icons.trash strokeWidth={1} className="pt-2 w-[32px] h-[30px]" />
<IonLabel className="pt-2">Trashbin</IonLabel>
</IonTabButton>
<IonTabButton tab="tab3" href="/operator/tabs/user">
<Icons.user strokeWidth={1} className="pt-2 w-[32px] h-[30px]" />
<IonLabel className="pt-2">User</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
);
};

export default OperatorTabs;
7 changes: 5 additions & 2 deletions apps/app/src/components/operator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import { IonPage, IonRouterOutlet } from "@ionic/react";
import { Redirect, Route } from "react-router-dom";

import OperatorFormLogin from "../pages/operator/form/login";
import OperatorDashboard from "../pages/operator/dashboard";
import OperatorIndex from "../pages/operator";
import OperatorTabs from "./operator-tabs";

const Operator: React.FC = () => {
return (
<IonPage>
<IonRouterOutlet id="main" animated={false} mode="ios">
<Route path="/operator/index" render={() => <OperatorIndex />} exact={true} />
<Route path="/operator/dashboard" render={() => <OperatorDashboard />} exact={true} />
<Route path="/operator/form/login" render={() => <OperatorFormLogin />} exact={true} />

<Route path="/operator/tabs">
<OperatorTabs />
</Route>

<Route path="/operator" render={() => <Redirect to="/operator/index" />} exact={true} />
</IonRouterOutlet>
</IonPage>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/pages/operator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function OperatorIndex() {

useEffect(() => {
if (operator.operator) {
history.push("/operator/dashboard");
history.push("/operator/tabs/dashboard");
} else {
history.push("/operator/form/login");
}
Expand Down
31 changes: 31 additions & 0 deletions apps/app/src/pages/operator/trash-bin/display.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { IonContent, IonPage } from "@ionic/react";
import { Card, CardContent, Button, OperatorContext } from "@trashtrack/ui";
import { useContext } from "react";
import { useHistory } from "react-router-dom";

export function OperatorTrashbinDisplay() {
const history = useHistory();
const operator = useContext(OperatorContext);

return (
<IonPage>
<IonContent className="operator-trashbin-display ion-padding" fullscreen>
<div className="pt-12">
<h1 className="font-bold text-left text-xl">TrashTrack</h1>
</div>
<div className="flex flex-col pt-8 gap-4">
<h1 className="font-bold text-lg">Dashboard Trash-bin, {operator.operator}</h1>
<Card className="flex flex-col mt-8">
<CardContent className="pt-6">
<Button className="font-bold text-xs w-full" onClick={() => history.replace("/tabs/home")}>
Kembali
</Button>
</CardContent>
</Card>
</div>
</IonContent>
</IonPage>
);
}

export default OperatorTrashbinDisplay;
31 changes: 31 additions & 0 deletions apps/app/src/pages/operator/user/display.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { IonContent, IonPage } from "@ionic/react";
import { Card, CardContent, Button, OperatorContext } from "@trashtrack/ui";
import { useContext } from "react";
import { useHistory } from "react-router-dom";

export function OperatorUserDisplay() {
const history = useHistory();
const operator = useContext(OperatorContext);

return (
<IonPage>
<IonContent className="operator-user-display ion-padding" fullscreen>
<div className="pt-12">
<h1 className="font-bold text-left text-xl">TrashTrack</h1>
</div>
<div className="flex flex-col pt-8 gap-4">
<h1 className="font-bold text-lg">Dashboard User, {operator.operator}</h1>
<Card className="flex flex-col mt-8">
<CardContent className="pt-6">
<Button className="font-bold text-xs w-full" onClick={() => history.replace("/tabs/home")}>
Kembali
</Button>
</CardContent>
</Card>
</div>
</IonContent>
</IonPage>
);
}

export default OperatorUserDisplay;
14 changes: 13 additions & 1 deletion libs/components/src/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Home, ClipboardEdit, UserPlus, Settings2, type Icon as LucideIcon } from "lucide-react";
import {
Home,
ClipboardEdit,
UserPlus,
Settings2,
UserCog,
type Icon as LucideIcon,
LayoutDashboard,
Trash,
} from "lucide-react";

export type Icon = LucideIcon;

Expand All @@ -7,4 +16,7 @@ export const Icons = {
settings: Settings2,
complain: ClipboardEdit,
login: UserPlus,
dashboard: LayoutDashboard,
user: UserCog,
trash: Trash,
};
2 changes: 1 addition & 1 deletion libs/components/src/operator/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function LoginForm() {
onSuccess: (data) => {
if (data.data === true) {
setOperator(form.getValues("username"));
history.push("/operator/dashboard");
history.push("/operator/tabs/dashboard");
} else {
setIsOpen(true);
}
Expand Down

0 comments on commit f9454ea

Please sign in to comment.