Skip to content

Commit

Permalink
Merge pull request #250 from universi-me/feat#246/editar-criar-conteu…
Browse files Browse the repository at this point in the history
…dos-materiais

Feat#246/editar criar conteudos materiais
  • Loading branch information
710lucas authored Nov 15, 2023
2 parents 0534265 + add7682 commit 4f20fe2
Show file tree
Hide file tree
Showing 16 changed files with 783 additions and 54 deletions.
182 changes: 182 additions & 0 deletions public/assets/imgs/create-content-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/imgs/create-content.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/components/ActionButton/ActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { HTMLAttributes } from "react"
import "./ActionButton.less"

export interface ActionButtonProps{
name : string
buttonProps?: HTMLAttributes<HTMLDivElement>;
}

export function ActionButton(props : ActionButtonProps){
const className = ["action-button-container", props.buttonProps?.className]
.filter(c => !!c && c.length > 0)
.join(" ");


return(
<div className="action-button-container">
<div {...props.buttonProps} className={className}>
<i className="bi bi-plus"></i>
<div className="action-button-name">
{props.name}
Expand Down
2 changes: 0 additions & 2 deletions src/components/ProfileInfo/ProfileBio/ProfileBio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export function ProfileBio(props: ProfileBioProps) {
? { backgroundImage: `url(${groupBannerUrl(props.organization)})` }
: { backgroundColor: "var(--primary-color)" }

console.dir({headerBackground});

return (
<div className="profile-bio-component card">

Expand Down
19 changes: 17 additions & 2 deletions src/pages/Group/Group.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useEffect, useState } from "react";
import { Navigate, useLoaderData } from "react-router-dom";

import { GroupContext, GroupIntro, GroupTabRenderer, GroupTabs, fetchGroupPageData, type AvailableTabs, type GroupContextType, type GroupPageLoaderResponse } from "@/pages/Group";
import { GroupContext, GroupIntro, GroupTabRenderer, GroupTabs, fetchGroupPageData, type AvailableTabs, type GroupContextType, type GroupPageLoaderResponse, RefreshGroupOptions } from "@/pages/Group";
import { ProfileBio, ProfileGroups } from "@/components/ProfileInfo";
import { AuthContext } from "@/contexts/Auth";
import "./Group.less";
Expand Down Expand Up @@ -50,9 +50,14 @@ export function GroupPage() {
setCurrentTab(tab);
}

async function refreshGroupData() {
async function refreshGroupData(options?: RefreshGroupOptions) {
const data = await fetchGroupPageData({ groupPath: page.group?.path });
const newContext = makeContext(data);

if (options?.currentContentId) {
newContext.currentContent = newContext.folders.find(c => c.id === options.currentContentId);
}

setContext(newContext);
return newContext;
}
Expand All @@ -77,6 +82,16 @@ export function GroupPage() {
setContext({...this, currentContent: c});
},

editContent: undefined,
setEditContent(c) {
setContext({...this, editContent: c});
},

editMaterial: undefined,
setEditMaterial(c) {
setContext({...this, editMaterial: c});
},

refreshData: refreshGroupData,
};
}
Expand Down
26 changes: 24 additions & 2 deletions src/pages/Group/GroupContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext } from "react";
import { Group } from "@/types/Group";
import { Profile } from "@/types/Profile";
import { Folder } from "@/types/Capacity";
import type { Content, Folder } from "@/types/Capacity";
import { Link } from "@/types/Link";

export type GroupContextType = null | {
Expand All @@ -13,14 +13,36 @@ export type GroupContextType = null | {
currentContent: Folder | undefined;
setCurrentContent(content: Folder | undefined): any;

/**
* The content being edited/created.
*
* If `null`, should handle creation of a content. If has a value, should handle
* content edit. If `undefined`, no content is being edited nor created.
*/
editContent: Folder | null | undefined;
setEditContent(content: Folder | null | undefined): any;

/**
* The material being edited/created.
*
* If `null`, should handle creation of a material. If has a value, should handle
* material edit. If `undefined`, no material is being edited nor created.
*/
editMaterial: Content | null | undefined;
setEditMaterial(material: Content | null | undefined): any;

loggedData: {
isParticipant: boolean;
profile: Profile;
links: Link[];
groups: Group[];
};

refreshData: () => Promise<NonNullable<GroupContextType>>;
refreshData: (options?: RefreshGroupOptions) => Promise<NonNullable<GroupContextType>>;
};

export type RefreshGroupOptions = {
currentContentId?: string;
}

export const GroupContext = createContext<GroupContextType>(null);
Loading

0 comments on commit 4f20fe2

Please sign in to comment.