Skip to content

Commit

Permalink
repushing with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
GiseleN523 committed Aug 24, 2024
1 parent 63eb488 commit c50a581
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
58 changes: 33 additions & 25 deletions client/src/Widgets/ActivityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,26 @@ import { useFetcher } from "react-router-dom";
import { AssignmentStatus } from "../_utils/types";

// this component is separate so that it can have its own states
function ActivityRow({activity, showAssignmentStatus, showPublicStatus, suppressAvatar, showOwnerName, ref}) {
console.log(showPublicStatus)
function ActivityRow({
activity,
showAssignmentStatus,
showPublicStatus,
suppressAvatar,
showOwnerName,
ref,
}) {
console.log(showPublicStatus);

const [rowTitle, setRowTitle] = useState(activity.title);
const fetcher = useFetcher();

// from ActivityEditor.tsx
let lastActivityDataName = useRef(activity.title);
//Update when something else updates the name
if (activity.title != lastActivityDataName.current && rowTitle != activity.title) {
if (
activity.title != lastActivityDataName.current &&
rowTitle != activity.title
) {
setRowTitle(activity.title);
}
lastActivityDataName.current = activity.title;
Expand All @@ -61,17 +71,14 @@ function ActivityRow({activity, showAssignmentStatus, showPublicStatus, suppress
assignmentStatusString + " until " + activity.closeTime;
}

let tooltipLabelString: string =
activity.isFolder
let tooltipLabelString: string = activity.isFolder
? activity.isPublic || activity.isShared
? "Folder / Public"
: "Folder / Private"
: activity.authorRow
? activity.ownerName
: "Activity" +
(activity.assignmentStatus
? " / " + activity.assignmentStatus
: "")
(activity.assignmentStatus ? " / " + activity.assignmentStatus : "");

function saveUpdatedTitle() {
if (rowTitle !== activity.title && activity.id !== undefined) {
Expand All @@ -88,7 +95,7 @@ function ActivityRow({activity, showAssignmentStatus, showPublicStatus, suppress
}

return (
<LinkBox
<LinkBox
as={Tr}
key={(activity.authorRow ? "author" : "activity") + activity.id}
data-test="Activity Link"
Expand All @@ -102,11 +109,7 @@ function ActivityRow({activity, showAssignmentStatus, showPublicStatus, suppress
<Tooltip label={tooltipLabelString}>
<Box m="0" p="0">
{activity.authorRow ? (
<Avatar
size="sm"
name={activity.ownerName}
marginLeft="1em"
/>
<Avatar size="sm" name={activity.ownerName} marginLeft="1em" />
) : (
<Icon
as={
Expand Down Expand Up @@ -173,21 +176,20 @@ function ActivityRow({activity, showAssignmentStatus, showPublicStatus, suppress
) : null}
</HStack>
<Show below="md">
{showAssignmentStatus ? (
<Text>{assignmentStatusString}</Text>
) : null}
{showAssignmentStatus ? <Text>{assignmentStatusString}</Text> : null}
</Show>
</Td>
{showPublicStatus ? (
<Td>{activity.isPublic ? "Public" : "Private"}</Td>
) : null}
<Show above="md">
{showAssignmentStatus ? (
<Td><Text>{assignmentStatusString}</Text></Td>
<Td>
<Text>{assignmentStatusString}</Text>
</Td>
) : null}
</Show>
{(!suppressAvatar && !activity.authorRow) ||
(showOwnerName) ? (
{(!suppressAvatar && !activity.authorRow) || showOwnerName ? (
<Td>
<HStack>
{suppressAvatar || activity.authorRow ? null : (
Expand All @@ -214,9 +216,7 @@ function ActivityRow({activity, showAssignmentStatus, showPublicStatus, suppress
>
<Icon color="black" as={GoKebabVertical} boxSize={6} />
</MenuButton>
<MenuList zIndex="1">
{activity.menuItems}
</MenuList>
<MenuList zIndex="1">{activity.menuItems}</MenuList>
</Menu>
) : null}
</Td>
Expand Down Expand Up @@ -254,7 +254,6 @@ export default forwardRef(function ActivityTable(
},
ref: React.ForwardedRef<HTMLButtonElement>,
) {

return (
<TableContainer overflowX="visible" overflowY="visible">
<Table>
Expand All @@ -271,7 +270,16 @@ export default forwardRef(function ActivityTable(
</Tr>
</Thead>
<Tbody>
{content.map((activity) => <ActivityRow activity={activity} showAssignmentStatus={showAssignmentStatus} showPublicStatus={showPublicStatus} suppressAvatar={suppressAvatar} showOwnerName={showOwnerName} ref={ref} />)}
{content.map((activity) => (
<ActivityRow
activity={activity}
showAssignmentStatus={showAssignmentStatus}
showPublicStatus={showPublicStatus}
suppressAvatar={suppressAvatar}
showOwnerName={showOwnerName}
ref={ref}
/>
))}
</Tbody>
</Table>
</TableContainer>
Expand Down
17 changes: 11 additions & 6 deletions client/src/Widgets/ContentCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useState, useEffect, useRef, forwardRef, ReactElement } from "react";
import React, {
useState,
useEffect,
useRef,
forwardRef,
ReactElement,
} from "react";
import {
Box,
Image,
Expand All @@ -15,7 +21,7 @@ import {
Tooltip,
Editable,
EditablePreview,
EditableInput
EditableInput,
} from "@chakra-ui/react";
import { GoKebabVertical } from "react-icons/go";
import { Link, useFetcher } from "react-router-dom";
Expand All @@ -27,7 +33,8 @@ export async function contentCardActions({ formObj }: { [k: string]: any }) {
//Don't let name be blank
let name = formObj?.cardTitle?.trim();
if (name == "") {
name = "Untitled " + (formObj.isFolder === "true" ? "Folder" : "Activity");
name =
"Untitled " + (formObj.isFolder === "true" ? "Folder" : "Activity");
}
await axios.post(`/api/updateContentName`, {
id: formObj.id,
Expand Down Expand Up @@ -160,9 +167,7 @@ export default forwardRef(function ContentCard(
value={cardTitle}
startWithEditView={autoFocusTitle}
isDisabled={!editableTitle}
onClick={(e) =>
editableTitle ? e.stopPropagation() : null
}
onClick={(e) => (editableTitle ? e.stopPropagation() : null)}
onChange={(txt) => setCardTitle(txt)}
onSubmit={() => saveUpdatedTitle()}
fontSize="sm"
Expand Down

0 comments on commit c50a581

Please sign in to comment.