create a appwriteconfig file and define all the initial content there
Don't know much about web but you could make a global variable
and just pass this everywhere
and import things like databaseID projectId and client
whatever u need
but i want to store different inputs from different components
thats not a issue since client will be same
i want to user in one collection
https://printfc.in/ is my website once go through it please Printfc.in Web site created using create-react-app In my website user will signup and uploads his files and he will enter number of copies and next component he needs to select print type like b/w or color I need to store all the user details to get them print All the user inputs should store in an order 1.username 2.emailid 3.userfiles 4.number of pages 5.number of copies 6.b/w or color 7.front or both sides 8.price 9.total price In which section of appwrite can I store all of this except files cause that will be stored in storage
@Hmm once go through it
looks like you are creating a form. It's all about how you manage your state. Either get all the information at first and then store in the database or write to the database when data is given to every component. In the latter approach you need to keep hold of the database id so you can update it later
How to implement it
You should lift the state and only write to the document when the user submit the data
until then store the user emails and other preferences inside global state
and pass the handlers as prop to specfic components
Iam not using preferences
by preferences I mean the color , side etc
Ok
import { Client, Databases,ID } from "appwrite";
const Select = () => {
const[color,setcolor]=useState("");
const[side,setside]=useState("");
const handleChange = (event) => {
event.preventDefault();
const client = new Client()
client.setEndpoint('https://api.printfc.in/v1') // Your API Endpoint
.setProject('');
const databases = new Databases(client);
const promise = databases.updateDocument(
'',
'',
ID.unique(),
{
color,
side
}
);
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
}```
can you say how to implement in this code
First of all create a separate file for appwrite initialisation and make the file cleaner and create handler on main file , all the specific states should be present in their components and pass the data to handler
1.created a seperate file for appwrite initialisation
done
2.create handler on main file????
@Binyamin help me please
Recommended threads
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Streamlit UI and local DB
I want to use Appwrite for automation, like run watchdog service every morning 3 am. Anyone got suggestions, already explored github and documentation no luck. ...