Skip to content

Commit

Permalink
Merge pull request #161 from chingu-x/fix/ideation
Browse files Browse the repository at this point in the history
Fix/ideation
  • Loading branch information
Dan-Y-Ko authored Aug 6, 2024
2 parents 1e9b9ef + 21472c2 commit a515365
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export default async function IdeationComponentWrapper({

return (
<>
<CreateIdeationContainer />
{!projectIdeas.length ? (
<>
<CreateIdeationContainer />
<div className="my-20 flex h-[290px] w-full gap-x-48">
<div className="flex flex-col justify-center">
<h1 className="text-xl font-medium text-base-300">
Expand Down Expand Up @@ -155,7 +155,6 @@ export default async function IdeationComponentWrapper({
isIdeationFinalized={false}
firstChild={
<VoteCard
teamId={teamId}
projectIdeaId={projectIdea.id}
users={projectIdea.projectIdeaVotes}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export default function IdeationForm() {
}

const filteredData: MyObject = {
teamId,
ideationId,
};

Expand Down Expand Up @@ -148,7 +147,6 @@ export default function IdeationForm() {
},
payload: {
params: {
teamId,
ideationId,
},
redirect: { router, route },
Expand Down Expand Up @@ -221,7 +219,6 @@ export default function IdeationForm() {
}

const filteredData = {
teamId,
ideationId,
...modifiedObject,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ interface VoteCardProps {
projectIdeaId: number;
users: ProjectIdeaVotes[];
className?: string;
teamId: number;
}

function VoteCard({ teamId, projectIdeaId, users, className }: VoteCardProps) {
function VoteCard({ projectIdeaId, users, className }: VoteCardProps) {
const [currentUserVoted, setCurrentUserVoted] = useState<null | boolean>(
null,
);
Expand All @@ -52,7 +51,6 @@ function VoteCard({ teamId, projectIdeaId, users, className }: VoteCardProps) {
dispatch(setProjectIdeasLoadingTrue());

const [, error] = await removeIdeationVoteAction({
teamId,
ideationId: projectIdeaId,
});

Expand All @@ -67,7 +65,6 @@ function VoteCard({ teamId, projectIdeaId, users, className }: VoteCardProps) {
} else {
dispatch(setProjectIdeasLoadingTrue());
const [, error] = await addIdeationVoteAction({
teamId,
ideationId: projectIdeaId,
});

Expand Down
20 changes: 9 additions & 11 deletions src/app/(main)/my-voyage/[teamId]/ideation/ideationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ interface IdeationResponse {
interface AddIdeationBody extends IdeationBody {}
interface EditIdeationBody extends Partial<AddIdeationBody> {}

type IdeationWithoutTeamId = Omit<IdeationProps, "teamId">;

export interface AddIdeationProps extends AddIdeationType, IdeationBody {}
export interface EditIdeationProps extends EditIdeationBody, IdeationProps {}
export interface DeleteIdeationProps extends IdeationProps {}
export type EditIdeationProps = EditIdeationBody & IdeationWithoutTeamId;
export type DeleteIdeationProps = IdeationWithoutTeamId;

export interface IdeationVoteProps extends IdeationProps {}
export type IdeationVoteProps = IdeationWithoutTeamId;
export type FetchIdeationsProps = Pick<IdeationProps, "teamId">;

export interface FinalizeIdeationProps extends IdeationProps {}
Expand Down Expand Up @@ -77,7 +79,6 @@ export async function addIdeation({
}

export async function editIdeation({
teamId,
ideationId,
title,
description,
Expand All @@ -87,7 +88,7 @@ export async function editIdeation({

const editIdeationAsync = () =>
PATCH<EditIdeationBody, EditIdeationResponse>(
`api/v1/voyages/teams/${teamId}/ideations/${ideationId}`,
`api/v1/voyages/ideations/${ideationId}`,
token,
"default",
{ title, description, vision },
Expand All @@ -103,13 +104,12 @@ export async function editIdeation({
}

export async function deleteIdeation({
teamId,
ideationId,
}: DeleteIdeationProps): Promise<AsyncActionResponse<DeleteIdeationResponse>> {
const token = getAccessToken();
const deleteIdeationAsync = () =>
DELETE<DeleteIdeationResponse>(
`api/v1/voyages/teams/${teamId}/ideations/${ideationId}`,
`api/v1/voyages/ideations/${ideationId}`,
token,
"default",
);
Expand All @@ -124,14 +124,13 @@ export async function deleteIdeation({
}

export async function addIdeationVote({
teamId,
ideationId,
}: IdeationVoteProps): Promise<AsyncActionResponse<IdeationVoteResponse>> {
const token = getAccessToken();

const addIdeationVoteAsync = () =>
POST<undefined, IdeationVoteResponse>(
`api/v1/voyages/teams/${teamId}/ideations/${ideationId}/ideation-votes`,
`api/v1/voyages/ideations/${ideationId}/ideation-votes`,
token,
"default",
);
Expand All @@ -146,14 +145,13 @@ export async function addIdeationVote({
}

export async function removeIdeationVote({
teamId,
ideationId,
}: IdeationVoteProps): Promise<AsyncActionResponse<IdeationVoteResponse>> {
const token = getAccessToken();

const removeIdeationVoteAsync = () =>
DELETE<IdeationVoteResponse>(
`api/v1/voyages/teams/${teamId}/ideations/${ideationId}/ideation-votes`,
`api/v1/voyages/ideations/${ideationId}/ideation-votes`,
token,
"default",
);
Expand Down

0 comments on commit a515365

Please sign in to comment.