Skip to content

Commit

Permalink
Project details fix issue: Labels comes as string
Browse files Browse the repository at this point in the history
  • Loading branch information
nico0689crc committed Feb 1, 2024
1 parent 0e94e7b commit f67181e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/src/app/dashboard/(regular_user)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Props = {

const Layout = ({ children } : Props) => {
return (
<Stack alignItems='center' justifyContent='center'>
<Stack alignItems='center' justifyContent='center' height='100%'>
{children}
</Stack>
)
Expand Down
11 changes: 6 additions & 5 deletions client/src/hooks/useKanban.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import useSWR from 'swr';
import axiosInstance, { fetcher, endpoints } from '@/utils/axios';
import { KanbanProjectType, KanbanProjectsResponseCollectionType } from '@/types';
import { KanbanProjectType, KanbanProjectsResponseCollectionType, KanbanProjectsResponseIndividualType } from '@/types';
import { ProjectStateType } from '@/sections/dashboard/kanban/kanban-project/context/types';

type swrResponseType = {
Expand Down Expand Up @@ -43,17 +43,18 @@ export async function postProject(data : ProjectStateType) {
}

export function useGetKanbanProjectByUUID(projectUUID: string) {
const { data, isLoading, error, isValidating } = useSWR(`${endpoints.projects}/${projectUUID}`, fetcher, options);
const { data, isLoading, error, isValidating } = useSWR(`${endpoints.projects}/${projectUUID}`, fetcher, options);
const project: ProjectStateType = data?.data?.attributes;

const memoizedValue = useMemo(
() => ({
project: {
...project,
sections: project?.sections?.map(section => ({
sections: project?.sections?.map((section:any) => ({
...section,
tasks: section.tasks.map(task => ({
...task
tasks: section.tasks.map((task: any) => ({
...task,
labels: Object.values(JSON.parse(task.labels))
}))
}))
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/layouts/dashboard/DashboardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const DashboardLayout = ({children}: Props) => {
<LogoutButton />
</Stack>
<Container maxWidth='xl' sx={{ flexGrow: 1 }}>
<Box pt={5} pb={{ xs: 15, md: 8 }}>
<Box pt={5} pb={{ xs: 15, md: 8 }} height='100%'>
{children}
</Box>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const KanbanSection = ({ section, index } : { section : SectionType, index: numb
<KanbanSectionCard {...provided.dragHandleProps}>
{!deleteSectionToggle.value && !editSectionToggle.value && (
<Stack direction='column' height='100%'>
<Stack direction='row' alignItems='center' spacing={3}>
<Stack direction='row' alignItems='center' justifyContent='space-between' spacing={3}>
<Typography
sx={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
variant='subtitle1'
Expand Down
5 changes: 3 additions & 2 deletions server/src/services/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { faker } = require("@faker-js/faker")
const expressValidatorResult = require('../utils/expressValidatorResult');
const ErrorHandler = require("../utils/errorHandler");
const ResponseParser = require("../utils/responseParser");
const section = require('../models/section');

const getProjects = async (req, res, next) => {
ErrorHandler(async () => {
Expand Down Expand Up @@ -91,16 +90,18 @@ const postProject = async (req, res, next) => {
uuid: faker.string.uuid(),
tasks: section.tasks.map(task => ({
...task,
labels: task.labels.join('|')
labels: JSON.stringify(Object.assign({}, task.labels))
}))
}))
}, {
include: [{
model: Section,
as: 'sections',
attributes: Section.getFieldsToSelect(),
include: [{
model: Task,
as: 'tasks',
attributes: Task.getFieldsToSelect()
}]
}]
});
Expand Down
2 changes: 1 addition & 1 deletion server/src/utils/responseParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ResponseParser {
this.pageSize = request?.query?.page?.size ?? null;
this.response = {};
}

getSelectedAttributes = document => {
const attributes = {};

Expand Down

0 comments on commit f67181e

Please sign in to comment.