Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyled group body #157

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e10773a
test: 💍 basic test for conversation with playwright
A01384318 Nov 22, 2023
5e884cb
Merge remote-tracking branch 'origin/development' into web/testing/pr…
A01384318 Nov 22, 2023
0c1fefc
test: 💍 test for the sidebar
A01384318 Nov 24, 2023
0aaa69e
Merge remote-tracking branch 'origin/development' into web/testing/pr…
A01384318 Nov 24, 2023
b2ef735
test: 💍 test admin dashboard
A01384318 Nov 24, 2023
a7a6f0b
Merge remote-tracking branch 'origin/development' into web/testing/pr…
A01384318 Nov 24, 2023
ca181c2
chore: 🤖 Check whether a user has enough credits for prompts
Nov 27, 2023
6fa2e38
Merge remote-tracking branch 'origin/development' into web/chore/cred…
Nov 27, 2023
eecec68
fix: 🐛 fix test
A01384318 Nov 27, 2023
f7793e7
refactor: 💡 Implement style changes from development
Nov 27, 2023
c973f0a
Merge remote-tracking branch 'origin/development' into web/testing/pr…
A01384318 Nov 27, 2023
148d616
Merge pull request #148 from wizelineacademy/web/chore/credits-limits
Maria-Ontiveros Nov 27, 2023
4d6066b
fix: 🐛 fix test
A01384318 Nov 27, 2023
32da253
Merge remote-tracking branch 'origin/development' into web/testing/pr…
A01384318 Nov 27, 2023
99f1284
chore: 🤖 Disable group editing for the "All Wizeliners" group
emiof Nov 28, 2023
d327ad4
Merge pull request #149 from wizelineacademy/web/chore/frontend/group…
emiof Nov 28, 2023
e108028
chore: 🤖 Redirect user to initial group if group fetching fails
emiof Nov 28, 2023
162574e
Merge pull request #150 from wizelineacademy/web/chore/frontend/group…
emiof Nov 28, 2023
d0ff541
style: 💄 Minor style changes to the user and admin interfaces
emiof Nov 28, 2023
17e5b92
Merge pull request #151 from wizelineacademy/web/chore/frontend/user-…
emiof Nov 28, 2023
c1fdb72
style: 💄 Shorten exceeding user's name in user card
emiof Nov 28, 2023
5d2c9b2
Merge pull request #152 from wizelineacademy/web/chore/frontend/user-…
emiof Nov 28, 2023
f700b10
fix: 🐛 test fix
A01384318 Nov 28, 2023
f64485f
Merge remote-tracking branch 'origin/development' into web/testing/pr…
A01384318 Nov 28, 2023
ed78a88
fix: 🐛 fix tests
A01384318 Nov 28, 2023
8c2b2b7
Merge branch 'development' into web/chore/delete
JackelineConant Nov 28, 2023
11a5f10
Merge pull request #153 from wizelineacademy/web/testing/pruebas
A01384318 Nov 28, 2023
ae274ec
style: 💄 Remove toast notifications during messaging
emiof Nov 28, 2023
297c72c
Merge pull request #154 from wizelineacademy/web/chore/frontend/user-…
emiof Nov 28, 2023
02134ae
chore: 🤖 Implement function to deactivate user's conversations
Nov 28, 2023
5022e93
Merge branch 'web/chore/delete' of https://github.com/wizelineacademy…
Nov 28, 2023
c2011f9
Merge pull request #155 from wizelineacademy/web/chore/delete
Maria-Ontiveros Nov 28, 2023
c8b9093
style: 💄 Wording change in delete conversations modal
Nov 28, 2023
8a60b44
style: 💄 Adapted table height to screen size
davidmartinezhi Nov 28, 2023
4b16eac
style: 💄 Modified space margin and paddings
davidmartinezhi Nov 28, 2023
f6a477d
style: 💄 Adjusted spacing with button to open sidebar and body
davidmartinezhi Nov 28, 2023
2516da6
style: 💄 Styled group header adn body padding
davidmartinezhi Nov 28, 2023
112ff61
Merge pull request #156 from wizelineacademy/web/style/group-table
davidmartinezhi Nov 28, 2023
d961d82
style: 💄 Styled modal
davidmartinezhi Nov 28, 2023
01b464c
Merge pull request #158 from wizelineacademy/web/style/group-table
davidmartinezhi Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ yarn-error.log*

# vercel
.vercel
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
2 changes: 1 addition & 1 deletion apps/web/app/(root)/admin/group/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import GroupBody from "@/components/admin/groupBody/organisms/group-body";

export default function GroupPage(): JSX.Element {
export default function GroupPage(): JSX.Element {
return (
<div>
<GroupBody />
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/(root)/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default async function AdminRootLayout({children}: {children: React.React
redirect("/api/auth/login");
}

const allUsersGroupId = 1
const initialGroups: Group[] = sortGroups((await getAllGroups()).data || [], allUsersGroupId)
const allWizelinersGroupId = 1
const initialGroups: Group[] = sortGroups((await getAllGroups()).data || [], allWizelinersGroupId)

return (
<PrismaUserContextProvider initialPrismaUser={prismaUser}>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/api/ai/openai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export async function POST(
return new StreamingTextResponse(stream, { status: 200 });
} catch (error: any) {
// If an error occurs, log it to the console and send a message to the user
// console.error(error);
console.log(error.message)
console.error(error);
return new NextResponse(`Error: ${error.message}`, { status: 500 });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import NewGroupMenu from "./edit-group-menu";

interface EditGroupMenuModalProps {
isNew: boolean;
allowElimination: boolean;
initialGroup: Group;
isOpen: boolean;
onGroupSave: (savedGroup: Group) => void;
onGroupDeletion?: (deletedGroup: Group) => void;
onModalClose: () => void;
}

export default function EditGroupMenuModal({isNew, initialGroup, isOpen, onGroupSave, onGroupDeletion, onModalClose}: EditGroupMenuModalProps): JSX.Element {
export default function EditGroupMenuModal({isNew, allowElimination, initialGroup, isOpen, onGroupSave, onGroupDeletion, onModalClose}: EditGroupMenuModalProps): JSX.Element {
const [group, setGroup] = useState<Group>(initialGroup)
const [isLoading, setIsLoading] = useState<boolean>(false)
const [confirmDeleteModalIsOpen, setConfirmDeleteModalIsOpen] = useState<boolean>(false)
Expand All @@ -41,7 +42,7 @@ export default function EditGroupMenuModal({isNew, initialGroup, isOpen, onGroup
}

const handleDeleteButtonPress: (e: any) => void = (_) => {
if (onGroupDeletion && !isNew){
if (onGroupDeletion && !isNew && allowElimination){
onModalClose()
setConfirmDeleteModalIsOpen(true)
}
Expand Down Expand Up @@ -142,7 +143,7 @@ export default function EditGroupMenuModal({isNew, initialGroup, isOpen, onGroup
<div className="flex flex-row justify-between items-center w-full">
<p>{isNew ? "New group" : "Edit group"}</p>

{!isNew ?
{!isNew && allowElimination ?
<Button color="danger" isIconOnly onPress={handleDeleteButtonPress}>
<AiFillDelete/>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface GroupHeaderProps {
export function GroupHeader({
groupData,
onGroupsSettingsPress,
setUpdatedUsers
setUpdatedUsers,
}: GroupHeaderProps): JSX.Element {
const [creditsModalIsOpen, setCreditsModalIsOpen] = useState<boolean>(false)
const [descriptionModalIsOpen, setDescriptionModalIsOpen] = useState<boolean>(false)
Expand All @@ -44,12 +44,13 @@ export function GroupHeader({
}

return (
<div className="flex flex-wrap items-start justify-between my-2 sm:ml-10 mt-0 pt-0">
<div className="flex flex-wrap items-start justify-between mb-2 mt-2 pt-0">
{/* Adjust the order of items for XS screens */}
<div className="w-full sm:w-1/2 order-2 sm:order-1 text-start">
<div className="w-full sm:w-1/2 order-2 sm:order-1 text-start sm:mt-10">
<button className="flex flex-row justify-center items-center gap-3" onClick={handleGroupNameClick} type="button">

<h3 className="text-3xl font-bold">{groupData.name}</h3>
<LuInfo size="0.8rem"/>
<LuInfo size="1rem"/>
</button>

{/* Placeholder for credits information below the group name */}
Expand Down
61 changes: 35 additions & 26 deletions apps/web/components/admin/groupBody/molecules/group-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface GroupTableProps {
setUpdatedUsers: any;
idGroup: number;
users: User[];
allowMembersEditing: boolean;
}

//columns
Expand Down Expand Up @@ -70,6 +71,7 @@ export default function GroupTable({
setUpdatedUsers,
users,
idGroup,
allowMembersEditing
}: GroupTableProps): JSX.Element {
const { isOpen, onOpen, onOpenChange } = useDisclosure();

Expand Down Expand Up @@ -158,7 +160,8 @@ export default function GroupTable({

if (hasSearchFilter) {
filteredUsers = filteredUsers.filter((user) =>
user.name.toLowerCase().includes(filterValue.toLowerCase())
user.name.toLowerCase().includes(filterValue.toLowerCase()) ||
user.email.toLowerCase().includes(filterValue.toLowerCase())
);
}
if (
Expand Down Expand Up @@ -321,6 +324,29 @@ export default function GroupTable({
}, []);

const topContent = useMemo(() => {
const membersEditingButton: JSX.Element = selectedKeys instanceof Set && selectedKeys.size > 0 ? (
<Button
color="danger"
endContent={<FaMinus />}
onClick={() => {
void removeUsersFromGroup();
}}
size="sm"
>
Remove Users
</Button>
) : (
<Button
className="text-white"
color="success"
endContent={<AiOutlinePlus />}
onClick={onOpen}
size="sm"
>
Add Users
</Button>
)

return (
<div className="flex flex-col gap-4">
<div className="flex justify-between gap-3 items-center">
Expand Down Expand Up @@ -387,28 +413,11 @@ export default function GroupTable({
))}
</DropdownMenu>
</Dropdown>
{selectedKeys instanceof Set && selectedKeys.size > 0 ? (
<Button
color="danger"
endContent={<FaMinus />}
onClick={() => {
void removeUsersFromGroup();
}}
size="sm"
>
Remove Users
</Button>
) : (
<Button
className="text-white"
color="success"
endContent={<AiOutlinePlus />}
onClick={onOpen}
size="sm"
>
Add Users
</Button>
)}

{/*If the editing of the group's members is possible, show corresponding button*/}
{allowMembersEditing ?
membersEditingButton
: null}
</div>
</div>
<div className="flex justify-between items-center">
Expand Down Expand Up @@ -494,13 +503,13 @@ export default function GroupTable({
},
}}
classNames={{
wrapper: "max-h-[382px] shadow-none p-4",
wrapper: "shadow-none p-4 overflow-y-scroll h-[calc(100vh-20rem)]",
}}
isHeaderSticky
onSelectionChange={setSelectedKeys as any}
onSortChange={setSortDescriptor as any}
selectedKeys={selectedKeys}
selectionMode="multiple"
selectionMode={allowMembersEditing ? "multiple" : "single"}
sortDescriptor={sortDescriptor}
topContent={topContent}
topContentPlacement="outside"
Expand All @@ -516,7 +525,7 @@ export default function GroupTable({
</TableColumn>
)}
</TableHeader>
<TableBody emptyContent="No users found" items={sortedItems}>
<TableBody className="h-full" emptyContent="No users found" items={sortedItems}>
{(item) => (
<TableRow key={item.id}>
{(columnKey) => (
Expand Down
16 changes: 10 additions & 6 deletions apps/web/components/admin/groupBody/organisms/group-body.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
// Import necessary hooks and utilities from React and Next.js
import { useContext, useEffect, useState } from "react";
import { useParams } from "next/navigation";
import { useParams , useRouter } from "next/navigation";
import type { Group } from "@prisma/client";
import { Spinner } from "@nextui-org/react";
import { toast } from "sonner";
Expand All @@ -20,13 +20,14 @@ export default function GroupBody(): JSX.Element {
const sidebarGroupsContext = useContext<GroupsContextShape | null>(
GroupsContext
);
const [editGroupModalIsOpen, setEditGroupModalIsOpen] =
useState<boolean>(false);
const [editGroupModalIsOpen, setEditGroupModalIsOpen] = useState<boolean>(false);
const router = useRouter();
const params = useParams();
const idGroup = Number(params.id);
const allowGroupEditing: boolean = idGroup !== 1 // 1: the id of the 'All Wizeliners' group.

// State for storing group data
const [groupData, setGroupData] = useState<GroupData | null>(null);
const [groupData, setGroupData] = useState<GroupData | null>(placeHolderGroupData());

// State for tracking loading status
const [loading, setLoading] = useState<boolean>(true);
Expand Down Expand Up @@ -80,9 +81,10 @@ export default function GroupBody(): JSX.Element {
setGroupData(data);
console.log(data);
} catch (err: any) {
router.push("/admin/group/1") // Redirect to 'All Wizeliners' if group's data can't be fetched.
// setError(err.message);
console.log(err);
toast.error("Failed getting group data");
toast.error(`Failed in fetching the data of group ${idGroup}.`);
} finally {
setLoading(false);
}
Expand All @@ -106,7 +108,7 @@ export default function GroupBody(): JSX.Element {
// if (error) return <div>Error: {error}</div>;

return (
<div className="p-5 h-full">
<div className="p-5 h-full mt-0 pt-3">
{/* Group Header */}
<GroupHeader
groupData={groupData ?? placeHolderGroupData()}
Expand All @@ -115,12 +117,14 @@ export default function GroupBody(): JSX.Element {
/>
{/* Group Table */}
<GroupTable
allowMembersEditing={allowGroupEditing}
idGroup={idGroup}
setUpdatedUsers={setUpdatedUsers}
users={groupData?.users ?? []}
/>

<EditGroupMenuModal
allowElimination={allowGroupEditing}
initialGroup={{ ...groupData, users: undefined } as Group}
isNew={false}
isOpen={editGroupModalIsOpen}
Expand Down
8 changes: 6 additions & 2 deletions apps/web/components/admin/groupSidebar/atoms/group-card.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Card, CardBody, Tooltip } from "@nextui-org/react";
import type { Group } from "@prisma/client";
import { MdOutlineGroup, MdOutlineGroups } from "react-icons/md"

interface GroupCardProps {
isAllUsersGroup: boolean;
group: Group;
isSelected: boolean;
onPress: () => void;
}

export default function GroupCard({
isAllUsersGroup,
group,
isSelected,
onPress,
Expand All @@ -34,13 +37,14 @@ export default function GroupCard({
<button className="w-full" onClick={handleCardPress} type="button">
<Tooltip content={cardTooltipContent} delay={1000} placement="right">
<Card
className={`flex flex-row items-center h-11 py-2 pl-2 pr-0 border-none rounded-md shadow-none hover:bg-white hover:bg-opacity-20 ${cardBackgroundColor}`}
className={`flex flex-row items-center h-11 py-2 pl-2 pr-0 border-none rounded-md shadow-none hover:bg-white hover:bg-opacity-20 ${cardBackgroundColor}`}
fullWidth
radius="none"
shadow="none"
>
<CardBody>
<div className="flex flex-row justify-start items-center w-full overflow-scroll scrollbar-hide">
<div className="flex flex-row justify-start items-center gap-2 w-full overflow-scroll scrollbar-hide">
{isAllUsersGroup ? <MdOutlineGroups color="white"/> : <MdOutlineGroup color="white"/> }
<p className="text-xs text-white whitespace-nowrap">{group.name}</p>
</div>
</CardBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export default function GroupList({groups, selectedGroup, onGroupPress}: GroupLi
<div className="flex flex-col space-y-2 w-full scrollbar-hide">
{groups.map((group, index) => (
<>
<GroupCard group={group} isSelected={selectedGroup === group.id} key={group.id} onPress={() => {onGroupPress(group.id)}}/>
<GroupCard
group={group}
isAllUsersGroup={index === 0}
isSelected={selectedGroup === group.id}
key={group.id} onPress={() => {onGroupPress(group.id)}}
/>

{index === 0 ?
<Divider className="m-1 my-0 dark"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default function GroupSidebar(): JSX.Element {
<div
className={`${
sidebarIsVisible ? "hidden" : "block"
} w-2 absolute -right-6 z-50 top-5 md:top-2`}
} w-2 absolute -right-6 z-50 top-2 md:top-2`}
>
{!sidebarIsVisible ? sidebarVisibilityButton : null}
</div>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/components/shared/molecules/confirm-delete-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export default function ConfirmDeleteModal({isOpen, modalText, onModalClose}: Co
<ModalContent>
{(onClose) => (
<ModalBody>
<p className="text-lg p-2 text-center">
Are you sure you want to delete this {modalText}?<br/>This action is irreversible.
<p className="text-md p-2 text-center">
Delete {modalText}?<br/>This action is irreversible.
</p>
<div className="flex flex-row w-full justify-center gap-8 pb-2">
<Button color="danger" onPress={onClose}>Cancel</Button>
<Button color="primary" onPress={handleConfirm}>Confirm</Button>
<Button color="danger" variant="light" onPress={onClose}>Cancel</Button>
<Button color="danger" onPress={handleConfirm}>Confirm</Button>
</div>
</ModalBody>
)}
Expand Down
Loading
Loading