Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
Expand Down
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": "@sttm/web",
"version": "1.18.5",
"version": "1.18.6",
"description": "Sevadaars are currently working hard to build a newer version of SikhiToTheMax website using modern web technologies.",
"main": "index.js",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions server/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ export default ({ url, bodyClass, title, description, language }) => marinate`
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="STTM">
<link rel="apple-touch-icon" href="/assets/images/sundar-gutka-flat-icon.png">
<link rel="apple-touch-icon" href="/assets/images/logo-192x192.png">

<!-- Windows Tile -->
<meta name="msapplication-config" content="ieconfig.xml">
<meta name="application-name" content="STTM">

<link rel="android-touch-icon" href="/assets/images/sundar-gutka-flat-icon.png">
<link rel="android-touch-icon" href="/assets/images/logo-192x192.png">
${stylesheetsHTML}

<script type="application/ld+json">
Expand Down
1 change: 1 addition & 0 deletions src/js/components/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Autocomplete extends Component {
<ul
className={`search-result ${isHome ? 'search-result-home' : ''}`}
id="suggestions"
aria-label="Search Suggestions"
ref={this.wrapperRef}
onKeyDown={this.onKeyDown} >
{filteredSuggestions.map((suggestion, index) => {
Expand Down
60 changes: 30 additions & 30 deletions src/js/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ class Header extends React.PureComponent {

onFormSubmit =
({ handleSubmit, autoDetectGurmukhi, ...data }) =>
(e) => {
e.preventDefault();
e.stopPropagation();
handleSubmit();
// Remove the last space in from the searched query.
const isNotAngSearch = SEARCH_TYPES[data.type] !== SEARCH_TYPES.ANG;
if (isNotAngSearch) {
data.query = data.query.trim();
}
(e) => {
e.preventDefault();
e.stopPropagation();
handleSubmit();
// Remove the last space in from the searched query.
const isNotAngSearch = SEARCH_TYPES[data.type] !== SEARCH_TYPES.ANG;
if (isNotAngSearch) {
data.query = data.query.trim();
}

const searchParams = { ...data, autoDetectGurmukhi };
if (data.type === SEARCH_TYPES.AUTO_DETECT && autoDetectGurmukhi) {
searchParams.isGurmukhi = true;
}
const searchParams = { ...data, autoDetectGurmukhi };
if (data.type === SEARCH_TYPES.AUTO_DETECT && autoDetectGurmukhi) {
searchParams.isGurmukhi = true;
}

this.handleFormSubmit(searchParams);
};
this.handleFormSubmit(searchParams);
};

handleFormSubmit = (data) => {
this.props.history.push(toSearchURL(data));
Expand Down Expand Up @@ -146,10 +146,10 @@ class Header extends React.PureComponent {
type: defaultType = isAng ? SEARCH_TYPES.ANG.toString() : null,
writer: defaultWriter = DEFAULT_SEARCH_WRITER,
autoDetectGurmukhi:
defaultAutoDetectGurmukhi = getBooleanFromLocalStorage(
LOCAL_STORAGE_KEY_FOR_AUTO_DETECT_GURMUKHI,
false
),
defaultAutoDetectGurmukhi = getBooleanFromLocalStorage(
LOCAL_STORAGE_KEY_FOR_AUTO_DETECT_GURMUKHI,
false
),
} = getQueryParams(location.search);

const isAskGurbaniBotSearchType =
Expand Down Expand Up @@ -195,22 +195,21 @@ class Header extends React.PureComponent {
}
defaultSource={
isAskGurbaniBotSearchType
? localStorage.getItem(LOCAL_STORAGE_KEY_FOR_SEARCH_SOURCE) ||
DEFAULT_SEARCH_SOURCE
? DEFAULT_SEARCH_SOURCE
: defaultSource
}
defaultType={
isAskGurbaniBotSearchType
? getNumberFromLocalStorage(
LOCAL_STORAGE_KEY_FOR_SEARCH_TYPE,
DEFAULT_SEARCH_TYPE
)
LOCAL_STORAGE_KEY_FOR_SEARCH_TYPE,
DEFAULT_SEARCH_TYPE
)
: Number(defaultType)
}
defaultWriter={
isAskGurbaniBotSearchType
? localStorage.getItem(LOCAL_STORAGE_KEY_FOR_SEARCH_WRITER) ||
DEFAULT_SEARCH_WRITER
DEFAULT_SEARCH_WRITER
: Number(defaultWriter)
}
defaultAutoDetectGurmukhi={defaultAutoDetectGurmukhi}
Expand Down Expand Up @@ -457,7 +456,7 @@ class Header extends React.PureComponent {
writer,
isGurmukhi:
parseInt(type) ===
SEARCH_TYPES.AUTO_DETECT &&
SEARCH_TYPES.AUTO_DETECT &&
autoDetectGurmukhi,
}}
value={query}
Expand All @@ -483,6 +482,7 @@ class Header extends React.PureComponent {
id="search-type"
value={type.toString()}
onChange={handleSearchTypeChange}
aria-label="Search Type"
>
{reformatSearchTypes(TYPES).map(({ type, value }) => (
<option key={value} value={value}>
Expand Down Expand Up @@ -536,13 +536,13 @@ class Header extends React.PureComponent {
?.filter((e) =>
source === 'G' || source === 'A'
? !SOURCE_WRITER_FILTER[source].includes(
e.writerID
)
e.writerID
)
: source !== 'all'
? SOURCE_WRITER_FILTER[source].includes(
? SOURCE_WRITER_FILTER[source].includes(
e.writerID
)
: true
: true
)
.map((writer) => (
<option
Expand Down
57 changes: 40 additions & 17 deletions src/js/components/Modals/AskGurbaniBotQuestionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SearchIcon from '@/components/Icons/Search';
import { toSearchURL } from '@/util';

import Dialog from './Dialog';
import { SEARCH_TYPES } from '@/constants';
import { SEARCH_TYPES, SOURCES } from '@/constants';

interface Props {
isModalOpen: boolean;
Expand All @@ -22,24 +22,26 @@ const AskGurbaniBotQuestionModal = (props: Props) => {
({
handleFormSubmit,
query,
source,
}: {
handleFormSubmit: FormEventHandler;
query: string;
source: string;
}) =>
(e: FormEvent) => {
e.preventDefault();
typeof handleFormSubmit === 'function' && handleFormSubmit();
history.push(
toSearchURL({
query,
type: SEARCH_TYPES.ASK_A_QUESTION,
writer: 'all',
source: 'all',
offset: '',
})
);
dispatch(setModalOpen(''));
};
(e: FormEvent) => {
e.preventDefault();
typeof handleFormSubmit === 'function' && handleFormSubmit();
history.push(
toSearchURL({
query,
type: SEARCH_TYPES.ASK_A_QUESTION,
writer: 'all',
source,
offset: '',
})
);
dispatch(setModalOpen(''));
};

return (
<Dialog
Expand All @@ -51,8 +53,9 @@ const AskGurbaniBotQuestionModal = (props: Props) => {
defaultType={SEARCH_TYPES.ASK_A_QUESTION}
defaultSource="all"
defaultWriter={0}
isolateFromLocalStorage // helps to keep the bot search form state isolated from the main/normal search form
>
{({
{(({
pattern,
disabled,
title,
Expand All @@ -65,13 +68,17 @@ const AskGurbaniBotQuestionModal = (props: Props) => {
handleKeyDown,
handleSearchChange,
handleSubmit: handleFormSubmit,
source,
handleSearchSourceChange,
isSourceChanged,
}) => (
<form
className="search-form"
action={action}
onSubmit={handleSubmit({
handleFormSubmit: handleFormSubmit,
query,
source,
})}
>
<div className="search-container-wrapper">
Expand Down Expand Up @@ -102,8 +109,24 @@ const AskGurbaniBotQuestionModal = (props: Props) => {
</button>
</div>
</div>
<div className="search-options">
<div className="search-option">
<select
name="source"
value={source}
className={[isSourceChanged ? 'selected' : null]}
onChange={handleSearchSourceChange}
>
{Object.entries(SOURCES).map(([value, children]) => (
<option key={value} value={value}>
{children}
</option>
))}
</select>
</div>
</div>
</form>
)}
))}
</SearchForm>
</div>
</Dialog>
Expand Down
Loading
Loading