-
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.
cleanup: commit all changes before now
- Loading branch information
Showing
10 changed files
with
173 additions
and
62 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
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,8 @@ | ||
import imageUrlBuilder from '@sanity/image-url'; | ||
import client from '../../sanity/client'; | ||
|
||
const builder = imageUrlBuilder(client); | ||
|
||
export function urlFor(source: any) { | ||
return builder.image(source); | ||
} |
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,30 +1,28 @@ | ||
import { LoaderFunctionArgs, json } from "react-router-dom"; | ||
import client from "../sanity/client"; | ||
import { LoaderFunctionArgs, json, useSearchParams } from "react-router-dom"; | ||
import * as React from "react"; | ||
|
||
export async function Loader({ request }: LoaderFunctionArgs) { | ||
// const data = await client.fetch(`*[_type == "event"]`) | ||
// { | ||
// title, | ||
// slug, | ||
// body, | ||
// publishedAt, | ||
// mainImage { | ||
// asset -> { | ||
// _id, | ||
// url | ||
// }, | ||
// alt, | ||
// } | ||
// } | order(publishedAt desc) | ||
// console.log(data); | ||
return json({ user: "user" }); | ||
} | ||
|
||
export default function LearnAppwrite() { | ||
// const data = useLoaderData(); | ||
const [input, setInput] = React.useState("") | ||
let [searchParams, setSearchParams] = useSearchParams(); | ||
|
||
console.log(searchParams); | ||
|
||
function handleSubmit(event: any) { | ||
event.preventDefault(); | ||
console.log(input); | ||
} | ||
|
||
return ( | ||
<main className="min-h-[50vh]"> | ||
<main className="min-h-[50vh] px-8"> | ||
<p>Bro this is learn appwrite</p> | ||
<form onSubmit={handleSubmit}> | ||
<input className="mt-2 border border-red-600 rounded-md" type="text" onChange={(e) => setInput(e.target.value)} /> | ||
</form> | ||
</main> | ||
); | ||
} |
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 { ChangeEvent } from "react"; | ||
import { useSearchParams } from "react-router-dom"; | ||
|
||
// Temporary key of my query parameter | ||
const MY_QUERY_PARAMETER: string = "myQueryParameter"; | ||
|
||
export const Query = (props: any) => { | ||
// Hook which returns a tuple. First element is the current URLSearchParams object and second element is the function to take in the new URLSearchParams object alongside a configuration object to either replace the query parameters or not alongside state. | ||
const [currentQueryParameters, setSearchParams] = useSearchParams(); | ||
const newQueryParameters: URLSearchParams = new URLSearchParams(); | ||
|
||
console.log(currentQueryParameters.get(MY_QUERY_PARAMETER)); | ||
|
||
const onInputValueChangeEventHandler: ( | ||
event: ChangeEvent<HTMLInputElement> | ||
) => void = ({ target: { value } }: ChangeEvent<HTMLInputElement>): void => { | ||
if (value) newQueryParameters.set(MY_QUERY_PARAMETER, value); | ||
|
||
setSearchParams(newQueryParameters); | ||
}; | ||
|
||
return ( | ||
<div className="max-w-[800px] mx-auto px-8"> | ||
|
||
<input | ||
className="mt-2 border" | ||
type="text" | ||
onChange={onInputValueChangeEventHandler} | ||
/> | ||
</div> | ||
); | ||
}; |
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,22 @@ | ||
import client from "../sanity/client"; | ||
// update denim jackets tag from best-seller to best selling | ||
|
||
export async function getAllCloths() { | ||
try { | ||
const query = `{ | ||
"allCloths": *[_type == "cloth" && "all-products" in tags]{name, _id, slug, price, image,tags, colors, sizes}, | ||
"bestSelling": *[_type == "cloth" && "best-selling" in tags]{name, _id, slug, price, image,tags, colors, sizes}, | ||
"newArrival": *[_type == "cloth" && "new-arrivals" in tags]{name, _id, slug, price, image,tags, colors, sizes}, | ||
}` | ||
const cloth = await client.fetch(query); | ||
|
||
return cloth; | ||
} catch (error) { | ||
console.log(error); | ||
return error; | ||
} | ||
} | ||
|
||
export const fetched = { | ||
async fetch() {}, | ||
}; |