-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from gnmyt/features/multiple-users
👥 Support for multiple users
- Loading branch information
Showing
33 changed files
with
811 additions
and
91 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
client/src/common/components/ActionConfirmDialog/ActionConfirmDialog.jsx
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,35 @@ | ||
import "./styles.sass"; | ||
import { DialogProvider } from "@/common/components/Dialog"; | ||
import Button from "@/common/components/Button/index.js"; | ||
|
||
export const ActionConfirmDialog = ({open, setOpen, onConfirm, onCancel, text}) => { | ||
|
||
const cancel = () => { | ||
setOpen(false); | ||
|
||
if (onCancel) { | ||
onCancel(); | ||
} | ||
} | ||
|
||
const confirm = () => { | ||
setOpen(false); | ||
|
||
if (onConfirm) { | ||
onConfirm(); | ||
} | ||
} | ||
|
||
return ( | ||
<DialogProvider onClose={() => setOpen(false)} open={open}> | ||
<div className="confirm-dialog"> | ||
<h2>Are you sure?</h2> | ||
<p>{text ? text : "This action cannot be undone."}</p> | ||
<div className="btn-area"> | ||
<Button onClick={cancel} type="secondary" text="Cancel" /> | ||
<Button onClick={confirm} type="primary" text="Confirm" /> | ||
</div> | ||
</div> | ||
</DialogProvider> | ||
) | ||
} |
Empty file.
19 changes: 19 additions & 0 deletions
19
client/src/common/components/ActionConfirmDialog/styles.sass
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,19 @@ | ||
.confirm-dialog | ||
display: flex | ||
flex-direction: column | ||
gap: 1rem | ||
width: 20rem | ||
|
||
h2 | ||
margin: 0 | ||
|
||
p | ||
margin: 0 | ||
font-size: 1.1rem | ||
font-weight: 600 | ||
|
||
|
||
.btn-area | ||
display: flex | ||
gap: 1rem | ||
justify-content: flex-end |
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
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
35 changes: 19 additions & 16 deletions
35
client/src/pages/Settings/components/SettingsNavigation/SettingsNavigation.jsx
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 |
---|---|---|
@@ -1,25 +1,28 @@ | ||
import Icon from "@mdi/react"; | ||
import "./styles.sass"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import SettingsItem from "./components/SettingsItem"; | ||
import { useContext } from "react"; | ||
import { UserContext } from "@/common/contexts/UserContext.jsx"; | ||
|
||
export const SettingsNavigation = ({pages}) => { | ||
export const SettingsNavigation = ({ userPages, adminPages }) => { | ||
|
||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const endsWith = (path) => { | ||
return location.pathname.endsWith(path); | ||
} | ||
const { user } = useContext(UserContext); | ||
|
||
return ( | ||
<div className="settings-navigation"> | ||
{pages.map((page, index) => ( | ||
<div key={index} className={"settings-item" + (endsWith(page.title.toLowerCase()) ? " settings-item-active" : "")} | ||
onClick={() => navigate("/settings/" + page.title.toLowerCase())}> | ||
<Icon path={page.icon} /> | ||
<h2>{page.title}</h2> | ||
</div> | ||
))} | ||
<p>USER SETTINGS</p> | ||
|
||
<div className="settings-group"> | ||
{userPages.map((page, index) => ( | ||
<SettingsItem key={index} icon={page.icon} title={page.title} /> | ||
))} | ||
</div> | ||
|
||
{user?.role === "admin" && <p>ADMIN SETTINGS</p>} | ||
{user?.role === "admin" && <div className="settings-group"> | ||
{adminPages.map((page, index) => ( | ||
<SettingsItem key={index} icon={page.icon} title={page.title} /> | ||
))} | ||
</div>} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.