Skip to content

Commit

Permalink
Merge pull request #51 from miles-no/feature/selectPeriods
Browse files Browse the repository at this point in the history
Create select periods
  • Loading branch information
wigsnes authored Dec 11, 2023
2 parents 4729698 + 87114ea commit ad48821
Show file tree
Hide file tree
Showing 43 changed files with 1,230 additions and 549 deletions.
4 changes: 4 additions & 0 deletions kabinizer-front-end/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export type { OpenAPIConfig } from './core/OpenAPI';

export type { BookingRequest } from './models/BookingRequest';
export type { CreateBookingRequestDto } from './models/CreateBookingRequestDto';
export type { CreateDrawDto } from './models/CreateDrawDto';
export type { Draw } from './models/Draw';
export type { DrawPeriod } from './models/DrawPeriod';
export type { Period } from './models/Period';

export { BookingRequestService } from './services/BookingRequestService';
export { DrawService } from './services/DrawService';
export { PeriodService } from './services/PeriodService';
5 changes: 2 additions & 3 deletions kabinizer-front-end/api/models/BookingRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
/* eslint-disable */

export type BookingRequest = {
id?: string;
bookingRequestId?: string;
userId?: string;
fromDate?: string;
toDate?: string;
periodId?: string;
};

4 changes: 1 addition & 3 deletions kabinizer-front-end/api/models/CreateBookingRequestDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
/* eslint-disable */

export type CreateBookingRequestDto = {
userId?: string;
fromDate?: string;
toDate?: string;
periodId?: string;
};

15 changes: 15 additions & 0 deletions kabinizer-front-end/api/models/CreateDrawDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { DrawPeriod } from './DrawPeriod';

export type CreateDrawDto = {
deadlineStart?: string;
deadlineEnd?: string;
title?: string | null;
drawPeriods?: Array<DrawPeriod> | null;
isSpecial?: boolean;
};

16 changes: 16 additions & 0 deletions kabinizer-front-end/api/models/Draw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { Period } from './Period';

export type Draw = {
id?: string;
start?: string;
end?: string;
title?: string | null;
periods?: Array<Period> | null;
isSpecial?: boolean;
};

11 changes: 11 additions & 0 deletions kabinizer-front-end/api/models/DrawPeriod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type DrawPeriod = {
start?: string;
end?: string;
title?: string | null;
};

4 changes: 2 additions & 2 deletions kabinizer-front-end/api/models/Period.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
/* eslint-disable */

export type Period = {
id?: string;
periodStart?: string;
periodEnd?: string;
deadlineDate?: string;
isSpecialPeriod?: boolean;
title?: string | null;
drawId?: string;
};

26 changes: 4 additions & 22 deletions kabinizer-front-end/api/services/BookingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,18 @@ export class BookingRequestService {
}

/**
* @param bookingRequestId
* @param requestBody
* @returns boolean Success
* @throws ApiError
*/
public static deleteApiBookingRequest(
bookingRequestId: string,
requestBody: Array<string>,
): CancelablePromise<boolean> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/api/BookingRequest',
query: {
'bookingRequestId': bookingRequestId,
},
});
}

/**
* @param userId
* @returns BookingRequest Success
* @throws ApiError
*/
public static getApiBookingRequestUser(
userId: string,
): CancelablePromise<Array<BookingRequest>> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/BookingRequest/user/{userId}',
path: {
'userId': userId,
},
body: requestBody,
mediaType: 'application/json',
});
}

Expand Down
41 changes: 41 additions & 0 deletions kabinizer-front-end/api/services/DrawService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { CreateDrawDto } from '../models/CreateDrawDto';
import type { Draw } from '../models/Draw';

import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';

export class DrawService {

/**
* @returns Draw Success
* @throws ApiError
*/
public static getApiDraw(): CancelablePromise<Array<Draw>> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/Draw',
});
}

/**
* @param requestBody
* @returns any Success
* @throws ApiError
*/
public static postApiDraw(
requestBody: CreateDrawDto,
): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'POST',
url: '/api/Draw',
body: requestBody,
mediaType: 'application/json',
});
}

}
Binary file modified kabinizer-front-end/bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion kabinizer-front-end/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand All @@ -9,6 +9,10 @@
href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap"
rel="stylesheet"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kabinizer</title>
</head>
Expand Down
66 changes: 66 additions & 0 deletions kabinizer-front-end/mock/draws.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
interface Period {
id: string;
periodStart: string;
periodEnd: string;
title: string;
drawId: string;
}

interface Draw {
id: string;
start: string;
end: string;
title: string;
periods: Period[];
isSpecial: boolean;
}

function generateDraws(numDraws: number): Draw[] {
const draws: Draw[] = [];

for (let i = 0; i < numDraws; i++) {
const id = Math.random().toString(36).substring(7);
const start = new Date().toISOString();
const end = new Date().toISOString();
const title = Math.random() < 0.5 ? "" : "Holiday";
const isSpecial = Math.random() < 0.5;

const periods: Period[] = [];
let periodStart = start;
let periodEnd = new Date(
new Date(start).getTime() + 7 * 24 * 60 * 60 * 1000,
).toISOString();

while (new Date(periodEnd) <= new Date(end)) {
const periodId = Math.random().toString(36).substring(7);
const periodTitle = `Period ${periods.length + 1}`;
periods.push({
id: periodId,
periodStart,
periodEnd,
title: periodTitle,
drawId: id,
});

periodStart = periodEnd;
periodEnd = new Date(
new Date(periodEnd).getTime() + 7 * 24 * 60 * 60 * 1000,
).toISOString();
}

draws.push({
id,
start,
end,
title,
periods,
isSpecial,
});
}

return draws;
}

const draws = generateDraws(10);

console.log(draws);
122 changes: 122 additions & 0 deletions kabinizer-front-end/mock/draws2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { Draw } from "../api";

export const draws: Draw[] = [
{
id: "1",
start: "2024-01-01",
end: "2024-01-14",
title: "",
periods: [
{
id: "11",
periodStart: "2024-01-01",
periodEnd: "2024-01-07",
title: "",
drawId: "1",
},
{
id: "12",
periodStart: "2024-01-08",
periodEnd: "2024-01-14",
title: "",
drawId: "1",
},
{
id: "13",
periodStart: "2024-01-15",
periodEnd: "2024-01-21",
title: "",
drawId: "1",
},
{
id: "14",
periodStart: "2024-01-22",
periodEnd: "2024-01-28",
title: "",
drawId: "1",
},
{
id: "15",
periodStart: "2024-01-29",
periodEnd: "2024-02-04",
title: "",
drawId: "1",
},
{
id: "16",
periodStart: "2024-02-05",
periodEnd: "2024-02-11",
title: "",
drawId: "1",
},
{
id: "17",
periodStart: "2024-02-12",
periodEnd: "2024-02-18",
title: "",
drawId: "1",
},
{
id: "18",
periodStart: "2024-02-19",
periodEnd: "2024-02-25",
title: "",
drawId: "1",
},
],
isSpecial: false,
},
{
id: "2",
start: "2024-01-29",
end: "2024-01-21",
title: "Easter",
periods: [
{
id: "21",
periodStart: "2024-02-26",
periodEnd: "2024-02-29",
title: "Part 1",
drawId: "2",
},
{
id: "22",
periodStart: "2024-03-1",
periodEnd: "2024-03-03",
title: "Part 2",
drawId: "2",
},
],
isSpecial: true,
},
{
id: "3",
start: "2024-01-22",
end: "2024-02-04",
title: "",
periods: [
{
id: "31",
periodStart: "2024-03-04",
periodEnd: "2024-03-10",
title: "",
drawId: "3",
},
{
id: "32",
periodStart: "2024-03-11",
periodEnd: "2024-03-17",
title: "",
drawId: "3",
},
{
id: "33",
periodStart: "2024-03-18",
periodEnd: "2024-03-24",
title: "",
drawId: "3",
},
],
isSpecial: false,
},
];
Loading

0 comments on commit ad48821

Please sign in to comment.