-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from miles-no/feature/selectPeriods
Create select periods
- Loading branch information
Showing
43 changed files
with
1,230 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
]; |
Oops, something went wrong.