If no availability set, default to user prefs
This commit is contained in:
parent
a28cb455f1
commit
6aa8df7fcf
1 changed files with 3 additions and 11 deletions
|
@ -148,14 +148,6 @@ export default function Type(props): Type {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WorkingHours {
|
|
||||||
days: number[];
|
|
||||||
startTime: number;
|
|
||||||
length: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Availability = WorkingHours;
|
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
|
@ -212,16 +204,16 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
? providesAvailability.availability
|
? providesAvailability.availability
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const workingHours: WorkingHours[] =
|
const workingHours: [] =
|
||||||
getWorkingHours(eventType) ||
|
getWorkingHours(eventType) ||
|
||||||
getWorkingHours(user) ||
|
getWorkingHours(user) ||
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
days: [0, 1, 2, 3, 4, 5, 6],
|
days: [0, 1, 2, 3, 4, 5, 6],
|
||||||
startTime: user.startTime,
|
startTime: user.startTime,
|
||||||
length: user.endTime,
|
endTime: user.endTime,
|
||||||
},
|
},
|
||||||
].filter((availability: Availability): boolean => typeof availability["days"] !== "undefined");
|
].filter((availability): boolean => typeof availability["days"] !== "undefined");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|
Loading…
Reference in a new issue