forked from BinaryStudioAcademy/bsa-2023-towhub
-
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.
th-168: Add trucks table (BinaryStudioAcademy#232)
* th-168: * business controller * th-168: + get methods to backend for find all trucks by businessId * th-168: + truck slice * th-168: * migrate generate * th-168: + styles for trucks table * th-168: + add trucks form * th-168: + notifications and sorted table * th-168: * linting * th-168: * linting * th-168: * linting * th-168: * comments * th-168: * endpoint * th-168: * swager * th-168: * resolve comments * th-168: * linting * th-168: * linting * th-168: * comments * th-168: * actions * th-168: * columns * th-168: * error handle in action and slice * th-168: * comments * th-168: * actions and other comennts * th-168: * linting * th-168: + sort by year * th-168: * style * th-168: * comments * th-168: * another comments * th-168: * comments * th-168: * comments
- Loading branch information
1 parent
f15a295
commit 35193b2
Showing
80 changed files
with
802 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ export { | |
HttpCode, | ||
HttpMessage, | ||
ServerErrorType, | ||
SortMethod, | ||
} from 'shared/build/index.js'; |
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,7 @@ | ||
import { type PaginationParameters } from '../types/types.js'; | ||
|
||
const countOffsetByQuery = ({ page, size }: PaginationParameters): number => { | ||
return page * size; | ||
}; | ||
|
||
export { countOffsetByQuery }; |
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,32 @@ | ||
import { | ||
type AnyColumn, | ||
type SQL, | ||
type SQLWrapper, | ||
asc, | ||
desc, | ||
} from 'drizzle-orm'; | ||
|
||
import { SortMethod } from '../enums/enums.js'; | ||
import { type SortMethodValue } from '../types/types.js'; | ||
|
||
type ColumnToSorted = SQLWrapper | AnyColumn; | ||
|
||
const getSortedBy = ( | ||
sortedMethod: SortMethodValue | null, | ||
requiredColumnToSorted: ColumnToSorted, | ||
optionalColumnToSorted: ColumnToSorted, | ||
): SQL[] => { | ||
const sortedBy = [desc(requiredColumnToSorted)]; | ||
|
||
if (sortedMethod === SortMethod.ASC) { | ||
sortedBy.unshift(asc(optionalColumnToSorted)); | ||
} | ||
|
||
if (sortedMethod === SortMethod.DESC) { | ||
sortedBy.unshift(desc(optionalColumnToSorted)); | ||
} | ||
|
||
return sortedBy; | ||
}; | ||
|
||
export { getSortedBy }; |
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,2 @@ | ||
export { countOffsetByQuery } from './count-offset-by-query.helper.js'; | ||
export { getSortedBy } from './get-sorted-by.helper.js'; |
9 changes: 9 additions & 0 deletions
9
backend/src/libs/packages/database/generated-schema/0012_add_businessId_to_trucks.sql
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,9 @@ | ||
ALTER TABLE "trucks" | ||
ADD COLUMN "business_id" integer NOT NULL; | ||
|
||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "trucks" ADD CONSTRAINT "trucks_business_id_business_details_id_fk" FOREIGN KEY ("business_id") REFERENCES "business_details"("id") ON DELETE no action ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export { type DriverHaveAccessToTruck } from './driver-have-acces-to-truck.type.js'; | ||
export { type TruckDatabaseModel } from './truck-entity-type/truck-database-model.type.js'; | ||
export { type TruckEntity } from 'shared/build/index.js'; | ||
export { | ||
type TruckAddRequestDto, | ||
type TruckEntity, | ||
type TruckGetAllResponseDto, | ||
} from 'shared/build/index.js'; |
File renamed without changes.
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
Oops, something went wrong.