-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from khyrulAlam/feature/user-search
Feature/user search
- Loading branch information
Showing
14 changed files
with
189 additions
and
61 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 |
---|---|---|
|
@@ -28,4 +28,7 @@ dist-ssr | |
/dist | ||
|
||
#config | ||
/src/config.ts | ||
/src/config.ts | ||
|
||
.firebase | ||
.vscode |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { LuSearch } from "react-icons/lu"; | ||
import { InputGroup } from "../ui/input-group"; | ||
import { Input } from "@chakra-ui/react/input"; | ||
import { useEffect, useState } from "react"; | ||
import useDebounce from "@/utils/useDebounce"; | ||
|
||
interface SearchBoxProps { | ||
setSearch: (value: string) => void; | ||
setLoading: (value: boolean) => void; | ||
} | ||
|
||
const SearchBox = ({ setSearch, setLoading }: SearchBoxProps) => { | ||
const [searchToken, setSearchToken] = useState<string | null>(null); | ||
const debouncedSearchToken = useDebounce(searchToken, 500); | ||
|
||
useEffect(() => { | ||
setSearch(debouncedSearchToken || ""); | ||
}, [debouncedSearchToken]); | ||
|
||
return ( | ||
<InputGroup flex="1" startElement={<LuSearch />}> | ||
<Input | ||
placeholder="Search contacts" | ||
value={searchToken || ""} | ||
onChange={(e) => { | ||
setLoading(true); | ||
setSearchToken(e.currentTarget.value) | ||
} | ||
} | ||
/> | ||
</InputGroup> | ||
); | ||
}; | ||
|
||
export default SearchBox; |
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// unregister previously registered service worker | ||
|
||
if ("serviceWorker" in navigator) { | ||
navigator.serviceWorker.getRegistrations().then(function (registrations) { | ||
for (let registration of registrations) { | ||
if ( | ||
registration.active && | ||
registration.active.scriptURL == | ||
"https://chatroom-67e21.web.app/service-worker.js" | ||
) { | ||
registration.unregister(); | ||
} | ||
} | ||
}); | ||
} |
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,11 +1,22 @@ | ||
export const dateFormatter = new Intl.DateTimeFormat(navigator.language, { | ||
month: "short", | ||
day: "numeric", | ||
year: "numeric", | ||
hour: "numeric", | ||
minute: "2-digit", | ||
month: "short", | ||
day: "numeric", | ||
year: "numeric", | ||
hour: "numeric", | ||
minute: "2-digit", | ||
}); | ||
|
||
export const dateFormatterShort = new Intl.DateTimeFormat(navigator.language, { | ||
month: "short", | ||
day: "numeric", | ||
year: "numeric", | ||
}); | ||
|
||
export const numberFormatter = new Intl.NumberFormat(navigator.language, { | ||
notation: "compact", | ||
}); | ||
notation: "compact", | ||
}); | ||
|
||
export const DB_NAME: { [key: string]: string } = { | ||
USER_TABLE: "usersTable", | ||
CHAT_ROOM: "chatRoom", | ||
}; |
Oops, something went wrong.