Skip to content

Commit

Permalink
Merge pull request #116 from FindNUS/release/1.4.1
Browse files Browse the repository at this point in the history
Release/1.4.1
  • Loading branch information
jinxuan-owyong authored Sep 30, 2022
2 parents b713d08 + d38126e commit 48d0040
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.4.0",
"version": "1.4.1",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
Expand Down
6 changes: 1 addition & 5 deletions src/features/preview_items/PeekContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from "react";
import { useAppSelector } from "../../hooks";
import PreviewFilter from "./PreviewFilter";
import PreviewItems from "./PreviewItems";
import { selectPreviewLoading } from "./previewItemsSlice";

const PeekContainer: React.FC = function () {
const loading = useAppSelector(selectPreviewLoading);

return (
<div className="search-container">
{!loading && <PreviewFilter isPeek={true} />}
<PreviewFilter isPeek={true} />
<PreviewItems isPeek={true} />
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions src/features/preview_items/PreviewFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useAppDispatch, useAppSelector } from "../../hooks";
import getDateInputValue from "../../utils/getDateInputValue";
import {
resetPreview,
resetPreviewPagination,
selectPreviewCategory,
selectPreviewDate,
selectPreviewItemsPerPage,
Expand All @@ -38,10 +39,12 @@ const PreviewFilter: React.FC<PreviewFilterProps> = function (
const handleCategoryChange = (ev: React.FormEvent) => {
const { value } = ev.target as HTMLSelectElement;
dispatch(setPreviewCategory(value));
dispatch(resetPreviewPagination());
};
const handleItemsPerPageChange = (ev: React.FormEvent) => {
const { value } = ev.target as HTMLSelectElement;
dispatch(setPreviewItemsPerPage(+value));
dispatch(resetPreviewPagination());
};

const handleResetFilter = () => {
Expand All @@ -51,11 +54,13 @@ const PreviewFilter: React.FC<PreviewFilterProps> = function (
const handleStartDateChange = (ev: React.FormEvent) => {
const { value } = ev.target as HTMLInputElement;
dispatch(setPreviewDateStart(value));
dispatch(resetPreviewPagination());
};

const handleEndDateChange = (ev: React.FormEvent) => {
const { value } = ev.target as HTMLInputElement;
dispatch(setPreviewDateEnd(value));
dispatch(resetPreviewPagination());
};

// reset previous filters
Expand Down
8 changes: 2 additions & 6 deletions src/features/preview_items/previewItemsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,16 @@ export const previewItemsSlice = createSlice({
state.isLastPage = action.payload;
},
setPreviewCategory(state, action: PayloadAction<string>) {
if (action.payload === DROPDOWN_DEFAULT_KEY) {
state.isValidFilter = false;
return;
}

state.category = action.payload;
state.isValidFilter = true;
state.isValidFilter = action.payload !== DROPDOWN_DEFAULT_KEY;
},
setPreviewItemsPerPage(state, action: PayloadAction<number>) {
state.itemsPerPage = action.payload;
},
resetPreviewPagination(state) {
state.isLastPage = initialPreviewItemsState.isLastPage;
state.offset = initialPreviewItemsState.offset;
state.pageNumber = initialPreviewItemsState.pageNumber;
},
setPreviewDateStart(state, action: PayloadAction<string>) {
const currentEnd = new Date(state.dateRange.end);
Expand Down

0 comments on commit 48d0040

Please sign in to comment.