Skip to content

Commit

Permalink
Merge pull request #316 from dump-hr/fix/choose-booth-page
Browse files Browse the repository at this point in the history
fix chose booth page
  • Loading branch information
bdeak4 authored Apr 28, 2024
2 parents 344b0ba + 83a85e8 commit 8104cf9
Show file tree
Hide file tree
Showing 43 changed files with 1,450 additions and 529 deletions.
8 changes: 7 additions & 1 deletion apps/admin/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
font-size: 16px;
font-weight: 400;
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
}
}

.flex {
display: flex;
gap: 8px;
margin-bottom: 8px;
}
6 changes: 3 additions & 3 deletions apps/admin/src/api/booth/useCreateBooth.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { BoothDto, CreateBoothDto } from '@ddays-app/types';
import { BoothCreateDto, BoothDto } from '@ddays-app/types';
import toast from 'react-hot-toast';
import { useMutation, useQueryClient } from 'react-query';

import { api } from '..';

const createBooth = async (dto: CreateBoothDto): Promise<BoothDto> => {
return await api.post<CreateBoothDto, BoothDto>('/booth', dto);
const createBooth = async (dto: BoothCreateDto): Promise<BoothDto> => {
return await api.post<BoothCreateDto, BoothDto>('/booth', dto);
};

export const useCreateBooth = () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/src/api/booth/useCreateManyBooths.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CreateManyBoothsDto } from '@ddays-app/types';
import { BoothCreateManyDto } from '@ddays-app/types';
import toast from 'react-hot-toast';
import { useMutation, useQueryClient } from 'react-query';

import { api } from '..';

const createManyBooths = async (data: CreateManyBoothsDto) => {
return await api.post<CreateManyBoothsDto, void>('/booth/many', data);
const createManyBooths = async (data: BoothCreateManyDto) => {
return await api.post<BoothCreateManyDto, void>('/booth/many', data);
};

export const useCreateManyBooths = () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/api/booth/useGetBooths.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AdminBoothDto } from '@ddays-app/types';
import { BoothDto } from '@ddays-app/types';
import { useQuery } from 'react-query';

import { api } from '..';

const getBooths = async () => {
return await api.get<never, AdminBoothDto[]>('/booth');
return await api.get<never, BoothDto[]>('/booth');
};

export const useGetBooths = () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/src/api/booth/useModifyBooth.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ModifyBoothDto } from '@ddays-app/types';
import { BoothUpdateDto } from '@ddays-app/types';
import toast from 'react-hot-toast';
import { useMutation, useQueryClient } from 'react-query';

import { api } from '..';

const updateBooth = async (dto: ModifyBoothDto & { id: number }) => {
const updateBooth = async (dto: BoothUpdateDto & { id: number }) => {
return await api.patch(`/booth/${dto.id}`, dto);
};

export const useModifyBooth = () => {
export const useUpdateBooth = () => {
const queryClient = useQueryClient();

return useMutation(updateBooth, {
Expand Down
16 changes: 6 additions & 10 deletions apps/admin/src/forms/BoothForm.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import {
AdminBoothDto,
CompanyCategory,
ModifyBoothForm,
} from '@ddays-app/types';
import { BoothDto, BoothUpdateDto, CompanyCategory } from '@ddays-app/types';
import { classValidatorResolver } from '@hookform/resolvers/class-validator';
import { useForm } from 'react-hook-form';

import { useCreateBooth } from '../api/booth/useCreateBooth';
import { useModifyBooth } from '../api/booth/useModifyBooth';
import { useUpdateBooth } from '../api/booth/useModifyBooth';
import { useCompanyGetAllPublic } from '../api/company/useCompanyGetAllPublic';
import { Button } from '../components/Button';
import { InputHandler } from '../components/InputHandler';
import { Question, QuestionType } from '../types/question';

export interface BoothFormProps {
booth?: AdminBoothDto;
booth?: BoothDto;
onSuccess?: () => void;
}

export const BoothForm: React.FC<BoothFormProps> = ({ booth, onSuccess }) => {
const { data: companies } = useCompanyGetAllPublic();

const createBooth = useCreateBooth();
const updateBooth = useModifyBooth();
const updateBooth = useUpdateBooth();

const questions: Question[] = [
{
Expand All @@ -49,8 +45,8 @@ export const BoothForm: React.FC<BoothFormProps> = ({ booth, onSuccess }) => {
},
];

const form = useForm<ModifyBoothForm>({
resolver: classValidatorResolver(ModifyBoothForm),
const form = useForm<BoothUpdateDto>({
resolver: classValidatorResolver(BoothUpdateDto),
});

return (
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/src/forms/ManyBoothsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompanyCategory, CreateManyBoothsDto } from '@ddays-app/types';
import { BoothCreateManyDto, CompanyCategory } from '@ddays-app/types';
import { classValidatorResolver } from '@hookform/resolvers/class-validator';
import { useForm } from 'react-hook-form';

Expand All @@ -24,8 +24,8 @@ export const ManyBoothsForm = ({ onSuccess }: { onSuccess?: () => void }) => {
},
];

const form = useForm<CreateManyBoothsDto>({
resolver: classValidatorResolver(CreateManyBoothsDto),
const form = useForm<BoothCreateManyDto>({
resolver: classValidatorResolver(BoothCreateManyDto),
});

return (
Expand Down
18 changes: 10 additions & 8 deletions apps/admin/src/pages/BoothPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AdminBoothDto } from '@ddays-app/types';
import { BoothDto } from '@ddays-app/types';
import { useState } from 'react';

import { useGetBooths } from '../api/booth/useGetBooths';
Expand All @@ -11,7 +11,7 @@ import { ManyBoothsForm } from '../forms/ManyBoothsForm';

export const BoothPage = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [boothToEdit, setBoothToEdit] = useState<AdminBoothDto>();
const [boothToEdit, setBoothToEdit] = useState<BoothDto>();

const companies = useGetBooths();
const [isManyModalOpen, setIsManyModalOpen] = useState(false);
Expand Down Expand Up @@ -51,13 +51,15 @@ export const BoothPage = () => {
/>
</Modal>

<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
<div className='flex'>
<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>

<Button variant='primary' onClick={() => setIsManyModalOpen(true)}>
New (many)
</Button>
<Button variant='primary' onClick={() => setIsManyModalOpen(true)}>
New (many)
</Button>
</div>

<Table
data={companies.data}
Expand Down
8 changes: 5 additions & 3 deletions apps/admin/src/pages/CompanyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export const CompanyPage = () => {
/>
</Modal>

<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
<div className='flex'>
<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
</div>

<Table
data={companies.data}
Expand Down
8 changes: 5 additions & 3 deletions apps/admin/src/pages/EventPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ const EventPage = () => {
/>
</Modal>

<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
<div className='flex'>
<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
</div>

<Table
data={events.data}
Expand Down
8 changes: 5 additions & 3 deletions apps/admin/src/pages/InterestPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export const InterestPage = () => {
/>
</Modal>

<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
<div className='flex'>
<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
</div>

<Table
data={interests.data}
Expand Down
8 changes: 5 additions & 3 deletions apps/admin/src/pages/SpeakerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ const SpeakerPage = () => {
)}
</Modal>

<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
<div className='flex'>
<Button variant='primary' onClick={() => setIsModalOpen(true)}>
New
</Button>
</div>

<Table
data={speakers.data}
Expand Down
14 changes: 14 additions & 0 deletions apps/api/db/migrations/0009_old_lady_ursula.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ALTER TABLE "booth_location" RENAME TO "booth";--> statement-breakpoint
ALTER TABLE "company" DROP CONSTRAINT "company_booth_location_id_booth_location_id_fk";
--> statement-breakpoint
ALTER TABLE "booth" DROP CONSTRAINT "booth_location_company_id_company_id_fk";
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "booth" ADD CONSTRAINT "booth_company_id_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "company"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "company" DROP COLUMN IF EXISTS "booth_location_id";--> statement-breakpoint
ALTER TABLE "booth" ADD CONSTRAINT "booth_name_unique" UNIQUE("name");--> statement-breakpoint
ALTER TABLE "booth" ADD CONSTRAINT "booth_company_id_unique" UNIQUE("company_id");
Loading

0 comments on commit 8104cf9

Please sign in to comment.