Skip to content

Commit

Permalink
Merge pull request #1646 from gettakaro/main-promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele authored Oct 13, 2024
2 parents 811ac8a + 385b0e9 commit 6472799
Show file tree
Hide file tree
Showing 5,398 changed files with 41,692 additions and 9,261 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 11 additions & 1 deletion packages/app-api/src/db/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ export class ItemRepo extends ITakaroRepo<ItemsModel, ItemsOutputDTO, ItemCreate
}
async find(filters: ITakaroQuery<ItemsOutputDTO>) {
const { query } = await this.getModel();
const result = await new QueryBuilder<ItemsModel, ItemsOutputDTO>(filters).build(query);

if (!filters.sortBy) {
// Add a sort by length of `code` so that short codes are up front
// This provides much better search results for users. Eg the difference between `resourceWood` vs `awningWoodShapes:woodDebris07`
query.orderByRaw('LENGTH("code") ASC');
}

const qry = new QueryBuilder<ItemsModel, ItemsOutputDTO>(filters).build(query);

const result = await qry;

return {
total: result.total,
results: await Promise.all(result.results.map((item) => new ItemsOutputDTO(item))),
Expand Down
2 changes: 1 addition & 1 deletion packages/app-api/src/workers/ItemsSyncWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function processJob(job: Job<IGameServerQueueData>) {
}
});

await Promise.all(promises);
await Promise.allSettled(promises);
}

return;
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-apiclient/src/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Takaro app-api
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: development - b2ef98cdc64703889f65c70969bee6761cdc070b
* The version of the OpenAPI document: development - 84bd9a7459a12a07d154f128124bdff7295ccdd6
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-apiclient/src/generated/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Takaro app-api
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: development - b2ef98cdc64703889f65c70969bee6761cdc070b
* The version of the OpenAPI document: development - 84bd9a7459a12a07d154f128124bdff7295ccdd6
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-apiclient/src/generated/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Takaro app-api
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: development - b2ef98cdc64703889f65c70969bee6761cdc070b
* The version of the OpenAPI document: development - 84bd9a7459a12a07d154f128124bdff7295ccdd6
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-apiclient/src/generated/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Takaro app-api
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: development - b2ef98cdc64703889f65c70969bee6761cdc070b
* The version of the OpenAPI document: development - 84bd9a7459a12a07d154f128124bdff7295ccdd6
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-apiclient/src/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Takaro app-api
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: development - b2ef98cdc64703889f65c70969bee6761cdc070b
* The version of the OpenAPI document: development - 84bd9a7459a12a07d154f128124bdff7295ccdd6
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const defaultListItems = [
icon: <AiOutlineMenu />,
title: 'Api reference',
description: 'A complete API reference for our libraries',
to: 'https://api.stg.takaro.dev/api.html',
to: 'https://api.takaro.io/api.html',
},
/*
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const ControlledDatePicker: FC<ControlledDatePickerProps> = (props) => {
description,
allowFutureDates = true,
allowPastDates = true,
canClear,
customDateFilter,
} = defaultsApplier(props);

Expand Down Expand Up @@ -91,6 +92,7 @@ export const ControlledDatePicker: FC<ControlledDatePickerProps> = (props) => {
format={format}
placeholder={placeholder}
mode={mode}
canClear={canClear}
/>
)}
{showError && error?.message && <ErrorMessage message={error.message} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, useLayoutEffect, useMemo, useState } from 'react';
import { Button, Popover } from '../../../../components';
import { FC, MouseEvent, useLayoutEffect, useMemo, useState } from 'react';
import { Button, IconButton, Popover } from '../../../../components';
import { DateTime, DateTimeFormatOptions, Settings } from 'luxon';
import { dateFormats, timeFormats } from './formats';
import { GenericInputProps } from '../../InputProps';
Expand All @@ -8,6 +8,7 @@ import { TimePicker } from '../subcomponents/TimePicker';
import { Calendar } from '../subcomponents/Calendar';
import { RelativePicker, timeDirection } from '../subcomponents/RelativePicker';
import { Placement } from '@floating-ui/react';
import { AiOutlineClose as ClearIcon } from 'react-icons/ai';

interface TimePickerOptions {
/// Determines the interval between time options
Expand Down Expand Up @@ -51,6 +52,9 @@ export interface DatePickerProps {

/// Placeholder text for the input
placeholder?: string;

/// Can set field back to undefined
canClear?: boolean;
}

export type GenericDatePickerProps = GenericInputProps<string, HTMLInputElement> & DatePickerProps;
Expand All @@ -71,6 +75,7 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
format = DateTime.DATE_SHORT,
allowPastDates = true,
allowFutureDates = true,
canClear = false,
customDateFilter,
mode,
}) => {
Expand Down Expand Up @@ -148,6 +153,8 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
} as unknown as React.FocusEvent<HTMLInputElement>;
}, []);

console.log('value', value);

useLayoutEffect(() => {
if (onFocus && onBlur) {
if (open) {
Expand All @@ -172,11 +179,23 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
return renderPlaceholder();
};

const handleClear = (e: MouseEvent) => {
e.preventDefault();
e.stopPropagation();
if (onChange) {
console.log('onChange triggered');
onChange(null as any);
}
};

return (
<Popover placement={popOverPlacement} open={open} onOpenChange={setOpen}>
<Popover.Trigger asChild>
<ResultContainer readOnly={readOnly} hasError={hasError} onClick={() => setOpen(!open)}>
{renderResult()}
<span>{renderResult()}</span>
{!readOnly && canClear && value && !open && (
<IconButton size="tiny" icon={<ClearIcon />} ariaLabel="clear" onClick={handleClear} />
)}
</ResultContainer>
</Popover.Trigger>
<Popover.Content>
Expand All @@ -197,6 +216,9 @@ export const GenericDatePicker: FC<GenericDatePickerProps> = ({
setFriendlyName(undefined);
}
if (isDateOnly) {
{
console.log('this is triggered');
}
handleOnChange(date);
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ export const ResultContainer = styled.div<{ readOnly: boolean; hasError: boolean
z-index: ${({ theme }) => theme.zIndex.dropdown};
cursor: ${({ readOnly }) => (readOnly ? 'not-allowed' : 'pointer')};
user-select: none;
span {
color: ${({ theme }) => theme.colors.primary};
}
display: flex;
align-items: center;
justify-content: space-between;
`;

export const ContentContainer = styled.div`
Expand Down
Loading

0 comments on commit 6472799

Please sign in to comment.